awto/effectfuljs

changing parent scope in `eval`

awto opened this issue · 0 comments

awto commented

Expressions like eval("var m = 10") should add variable` into its parent scope. This doesn't work now (if the variable isn't already defined in that scope), because the variables are accessed by index not by name.

To make this work each frame should also store reference of a global object, and each global variable access is converted to member access expression in that object. If some function uses eval it should also Object.create(parentGlobal). This way the eval will add the variable into the parent's global object and it can be accessed.