public virtual dynamic Apply(JavaScriptEvaluator e, dynamic self, params dynamic[] args) { var originalContext = e.env; var originalReturningState = e.isReturning; dynamic result = null; try { e.env = capture.AddBinding("this", self); e.isReturning = false; int i = 0; foreach (var p in parms.Nodes) { e.AddBinding(p.Text, args[i++]); } e.Eval(body); result = e.result; } finally { e.result = null; e.env = originalContext; e.isReturning = originalReturningState; } return(result); }
public static void Test(string s, dynamic expected = null) { try { if (expected != null) { Console.WriteLine("Testing: {0}", s); Console.WriteLine("Expecting {0}", expected); dynamic result = JavaScriptEvaluator.RunScript(s); Console.WriteLine("Result {0}", result); if (result != expected) { Console.WriteLine("ERROR!"); } } else { Console.WriteLine("Testing: {0}", s); JavaScriptEvaluator.RunScript(s); } } catch (Exception e) { Console.WriteLine("Error occured: " + e.Message); } }
public virtual dynamic Apply(JavaScriptEvaluator e, dynamic self, params dynamic[] args) { var originalContext = e.env; var originalReturningState = e.isReturning; dynamic result = null; try { e.env = capture.AddBinding("this", self); e.isReturning = false; int i = 0; foreach (var p in parms.Nodes) e.AddBinding(p.Text, args[i++]); e.Eval(body); result = e.result; } finally { e.result = null; e.env = originalContext; e.isReturning = originalReturningState; } return result; }
public override dynamic Apply(JavaScriptEvaluator e, dynamic self, params dynamic[] args) { return(func(self, args)); }
public override dynamic Apply(JavaScriptEvaluator e, dynamic self, params dynamic[] args) { return func(self, args); }