One issue is that there isn't any kind of JIT in Espruino - it just runs the source code directly. I had wondered about trying to tokenise it and pull out the variable names, but that is quite a big undertaking.
My worry is that if you have some kind of cache, you have to make sure it's in the right state. I'm struggling to think, but I could imagine that halfway through a function you might be able to call another function which changed which variable something like foo actually pointed to.
Perhaps I'm wrong about that though - if so then life could be a lot easier.
I like your variable name suggestion @DrAzzy - that could be very easy to add a special-case for, and it would be very easy for users to take advantage of.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
One issue is that there isn't any kind of JIT in Espruino - it just runs the source code directly. I had wondered about trying to tokenise it and pull out the variable names, but that is quite a big undertaking.
My worry is that if you have some kind of cache, you have to make sure it's in the right state. I'm struggling to think, but I could imagine that halfway through a function you might be able to call another function which changed which variable something like
foo
actually pointed to.Perhaps I'm wrong about that though - if so then life could be a lot easier.
I like your variable name suggestion @DrAzzy - that could be very easy to add a special-case for, and it would be very easy for users to take advantage of.