On Thu, Jul 11, 2013 at 5:08 PM, Brendan Eich <[email protected]> wrote:

>
> Very messy, and primordial JS (the "Mocha" interpreter) violated ECMA-262
> Edition 1 on order of evaluation, e.g., o[x] = ++x where the RHS ++x must be
> evaluated *after* the Reference o[x] is evaluated. Fixing this prior to
> compiling to a parse tree required code buffering and reordering, just as
> the for loops (both of 'em) can.
>
> Again, this goes back to the dawn of JS. We're not making it any worse. I
> don't see finite lookahead helping in general for any of these cases, BTW.
>
> /be

Compiling this
   arr[x] = ++x;
does not require complete AST support as far as I can tell.

Consider this:

Some hypothetical bytecode:

PUSH arr;
PUSH x;
--
<RHS code> -> VAL in accumulator register
--
SETVI;  //  stack[TOP-1] <- arr
            //  stack[TOP] <- x, index, initial value of x
            //  accum  <- x, final RHS value, x after increment
DROP2;
// accum here contains x value after increment - result
// of the assignment expression.

So that can be compiled to stack machine strictly in order
it is defined.

Or do you mean something else here?

--
Andrew Fedoniouk.

http://terrainformatica.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to