espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.77k stars 745 forks source link

Extra JIT features #2313

Closed gfwilliams closed 1 year ago

gfwilliams commented 1 year ago

Discussed at https://forum.espruino.com/conversations/382898/#comment16823779

It's not a bug, it's just not implemented yet. Because && is a short-circuiting operator it's not quite as simple as doing & with booleans, but it shouldn't be a huge problem (it's just the 'if' code).

This one shouldn't be too hard, and is very useful when trying to do stuff like draw polylines

Again, pretty useful especially when calling some built-in functions. Probably not that hard either.

fanoush commented 1 year ago

also array index access

>(function(){"jit";var i=0,a=Uint8Array(1);a[0]=1;return a[i];})();
Uncaught Error: Field or method "i" does not already exist, and can't create it on Uint8Array
 at line 1 col 65
...y(1);a[0]=1;return a[i];})();

workaround is using a[i.ToString()]

gfwilliams commented 1 year ago

Thanks @fanoush - just fixed that too