pvginkel / Jint2

Jint improved
0 stars 0 forks source link

Remove JsScope #5

Closed pvginkel closed 11 years ago

pvginkel commented 11 years ago

It looks like the entire JsScope system can be removed and replaced with compiled scopes. The only exception may be the global scope, because that's used to pass parameters from JintEngine to the application. This however can also be replaced by a different mechanism which is only used to communicate the values from JintEngine to the program and back.

Note that we don't create native variables for parameters that we pass from JintEngine. The reason for this is in the current implementation, we can cache the compilation based only on the compiled text. This means that we will always need an interpreted mechanism for JintEngine parameters.

With this change, the scope stack must also be removed (so also EnterScope, ExitScope and GetScope). This will be replaced by hard linking of the scopes. A scope will get a parent scope field which is used to link scopes upwards. At the beginning of the function, this list will be walked to create local variables that reference all scopes that are used. The last step is to give a hard reference to the current scope to the JsFunction. That way we can completely get rid of the stack and only work with direct references, all strongly typed.