Open gfwilliams opened 11 months ago
There is now a partial implementation of this. digitalWrite(LED1,1);
now uses digitalWrite
and LED1
directly (rather than searching).
Handling g.drawLine
is more problematic as we're not sure if g
is going to change. It's pretty clear for g.drawLine
, but x.toString()
will expect to call the toString
function for whatever x
is. For console.log
/etc where console
is itself a builtin this makes a lot of sense though.
We currently store our vars
list as just a list of var names, but I think to do this properly we'd want to change it to include full paths, like "console.log"
- which then get appended only if we know that the first part was a builtin too. All a lot more work though.
Right now, JIT creates code on demand, but it looks everything up on the fly.
As an example:
roughly translates to:
digitalWrite
LED1
digitalWrite
with LED1 and 1or.....
roughly translates to:
g
drawLine
ong
drawLine
withthis=g,0,0,100,100
I think it's probably safe to assume that in both cases we could look the relevant thing up at JIT time and if it is built into the interpreter (or it's defined
const
), we could just use it direct?edit: sometimes code does overload an old implementation (eg maybe g.drawLine may be patched with a fixed version) but as long as that is done before JIT parses the function we'd be fine
It should translate to a pretty drastic speed improvement.