Re: Writing a compiler to handles, but filter seems to executed in reverse

2018-01-02 Thread Charles Oliver Nutter
So I have some basic expressions working in my pseudo-compiler, and the experiment has been interesting so far. A few things I've learned: (for code "a = 1; b = 2; (a + b) > 1", here's the assembly output: https://gist.github.com/headius/f765260a00590fc2b4cd033b5a657e6b) * The approac

Re: Writing a compiler to handles, but filter seems to executed in reverse

2018-01-02 Thread Charles Oliver Nutter
I have released invokebinder 1.11, which includes Binder.filterForward that guarantees left-to-right evaluation of the filters (by doing them individually). I'd still like to understand if this is intentional behavior in OpenJDK or if it is perhaps a bug. - Charlie On Tue, Jan 2, 2018 at 3:10 PM

Re: Writing a compiler to handles, but filter seems to executed in reverse

2018-01-02 Thread Charles Oliver Nutter
Yes, I figured I would need it for that too, but this filter behavior sent me off on a weird tangent. It is gross in code to do the filters manually in forward order, but perhaps it's not actually a big deal? OpenJDK's impl applies each filter as its own layer anyway. - Charlie On Tue, Jan 2, 20

Re: Writing a compiler to handles, but filter seems to executed in reverse

2018-01-02 Thread Remi Forax
You also need the loop combinator for implementing early return (the return keyword), I think i have an example of how to map a small language to a loop combinator somewhere, i will try to find that (or rewrite it) tomorrow. cheers, Rémi > De: "Charles Oliver Nutter" > À: "Da Vinci Machin

Re: Writing a compiler to handles, but filter seems to executed in reverse

2018-01-02 Thread Charles Oliver Nutter
An alternative workaround: I do the filters myself, manually, in the order that I want them to executed. Also gross. On Tue, Jan 2, 2018 at 2:35 PM Charles Oliver Nutter wrote: > Ahh I believe I see it now. > > filterArguments starts with the first filter, and wraps the incoming > target handle

Re: Writing a compiler to handles, but filter seems to executed in reverse

2018-01-02 Thread Charles Oliver Nutter
Ahh I believe I see it now. filterArguments starts with the first filter, and wraps the incoming target handle with each in turn. However, because it's starting at the target, you get the filters stacked up in reverse order: filter(target, 0, a, b, c, d) ends up as d_filter(c_filter(b_filter(a_

Writing a compiler to handles, but filter seems to executed in reverse

2018-01-02 Thread Charles Oliver Nutter
Hello all, long time no write! I'm finally playing with writing a "compiler" for JRuby that uses only method handles to represent code structure. For most simple expressions, this obviously works well. However I'm having trouble with blocks of code that contain multiple expressions. Starting with