This project has moved and is read-only. For the latest updates, please go here.


Jan 30, 2012 at 1:00 AM

  Does ScriptEngine allow re-entrancy?  For example, Suppose I evaluate some script on a ScriptEngine, and that script runs some .NET function I've made global.  Can that global function call Evaluate() or Execute() on the same ScriptEngine?  

Jan 30, 2012 at 1:04 AM
This can be done, and is totally unproblematic. However, do keep in mind that ScriptEngine is not threadsafe.
Jan 30, 2012 at 2:56 AM

I wouldn't say that this is safe in general, but in the specific case of Evaluate() and Execute(), yes, re-entrancy is fine.

Jan 31, 2012 at 6:13 AM

  Ok, I am seeing re-entrancy work.  There is an issue though as I need to evaluate code within some of these .NET callbacks, and evaluate them at the same scope where the .NET runs.  I believe what I need is to make this test pass:

  It fails, result1 and result2 are 32, while I expected them to be 4.

  If this helps clarify my requirement in this case...  I was trying to port to C#.  In the load method, evaluateReader runs.  Looking at the docs for evaluateReader, I believe it would return 32 in the type of scenario above.

  If this is not supported in some way already...  Maybe if Jurassic had a JSFunctionFlags.HasScopeParameter, which causes JSFunctions to be passed a Jurassic.Compiler.Scope.  It looks like I could then use GlobalObject.Eval to make the evaluation with that scope context.

Jan 31, 2012 at 7:28 AM

Allowing methods to access local variables would make a lot of basic optimizations much more problematic, so it's not something I am willing to add.


Incidentally Scope only contains accurate information when optimizations are disabled for a function - like for example if "eval" is detected within the function.

(Of course, this is an open-source project, you are welcome to fork it and add whatever you want!)

Feb 4, 2012 at 9:50 PM

Just a note, it turned out to be a good thing you said no.  Before migrating the code to something like IronJS, I found a different approach to the problem altogether that should be simpler/easier to maintain.  So anyhow, keep up the good work.

Feb 6, 2012 at 9:38 PM

I like happy endings :-)