public object Invoke(IScriptContext context, object[] args) { context.CreateScope(); context.SetItem("me", scriptable.Instance); context.SetItem("body", scriptable); object rez = RuntimeHost.NullValue; try { rez = dynamicMethod.Invoke(context, arguments); } finally { context.RemoveLocalScope(); } if (rez != RuntimeHost.NullValue) { return rez; } else { throw new ScriptException(string.Format("Dynamic method call failed in object {0}", scriptable.ToString())); } }
public object Invoke(IScriptContext context, object[] args) { bool scopeOwner = false; if (args != null) { if (args.Length > 1) throw new ArgumentException("Number of arguments "); if (args.Length == 1) { var assigner = args[0] as ISupportAssign; if (assigner == null) throw new NotSupportedException("Given type of argument is not supported"); assigner.AssignTo(context.CreateScope()); scopeOwner = true; } } try { _metaProg.Evaluate(context); return context.Result; } finally { if (scopeOwner) context.RemoveLocalScope(); } }
public object Invoke(IScriptContext context, object[] args) { var code = (String)args[0]; ScriptAst result; RuntimeHost.Lock(); try { result = Script.Parse(code + ";", false) as ScriptAst; //TODO: Create LocalOnlyScope that can't change Parent's variables //No, need for doing these. It is already done context.CreateScope(); } finally { RuntimeHost.UnLock(); } if (result != null) { result.Evaluate(context); } context.RemoveLocalScope(); return(context.Result); }
//TODO: Refactor public override void Evaluate(IScriptContext context) { if (ChildNodes.Count == 0) return; //Create local scope if (ShouldCreateScope) { IScriptScope scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope); context.CreateScope(scope); } try { int index = 0; while (index < ChildNodes.Count) { var node = (ScriptAst)ChildNodes[index]; node.Evaluate(context); if (context.IsBreak() || context.IsReturn() || context.IsContinue()) { break; } index++; } } finally { if (ShouldCreateScope) context.RemoveLocalScope(); } }
public object Invoke(IScriptContext context, object[] args) { string code = (String)args[0]; ScriptAst result = null; LanguageCompiler compiler = (LanguageCompiler)context.GetItem("Compiler", true); RuntimeHost.Lock(); try { result = Script.Parse(code + ";", false) as ScriptAst; //TODO: Create LocalOnlyScope that can't change Parent's variables //No, need for doing these. It is already done context.CreateScope(); } finally { RuntimeHost.UnLock(); } result.Evaluate(context); context.RemoveLocalScope(); return(context.Result); }
public object Invoke(IScriptContext context, object[] args) { var functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context); context.CreateScope(functionScope); Expando values = args.FirstOrDefault() as Expando; if (values != null) { foreach (var field in values.Fields) { context.SetItem(field, values[field]); } } else { if (args.Length > 0) { throw new ScriptExecutionException("Wrong type of arguments passed to Program Invokation"); } } try { Evaluate(context); } finally { context.RemoveLocalScope(); context.ResetControlFlags(); } return(context.Result); }
public object Invoke(IScriptContext context, object[] args) { string code = (String)args[0]; ScriptAst result = null; LanguageCompiler compiler = (LanguageCompiler) context.GetItem("Compiler", true); RuntimeHost.Lock(); try { result = Script.Parse(code + ";", false) as ScriptAst; //TODO: Create LocalOnlyScope that can't change Parent's variables //No, need for doing these. It is already done context.CreateScope(); } finally { RuntimeHost.UnLock(); } result.Evaluate(context); context.RemoveLocalScope(); return context.Result; }
public object Invoke(IScriptContext context, object[] args) { context.CreateScope(); context.SetItem("me", scriptable.Instance); context.SetItem("body", scriptable); object rez = RuntimeHost.NullValue; try { rez = dynamicMethod.Invoke(context, arguments); } finally { context.RemoveLocalScope(); } if (rez != RuntimeHost.NullValue) { return(rez); } else { throw new ScriptException(string.Format("Dynamic method call failed in object {0}", scriptable.ToString())); } }
public object Invoke(IScriptContext context, object[] args) { var functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context); context.CreateScope(functionScope); Expando values=args.FirstOrDefault() as Expando; if (values != null) { foreach (var field in values.Fields) { context.SetItem(field, values[field]); } } else { if (args.Length > 0) throw new ScriptExecutionException("Wrong type of arguments passed to Program Invokation"); } try { Evaluate(context); } finally { context.RemoveLocalScope(); context.ResetControlFlags(); } return context.Result; }
public override void Evaluate(IScriptContext context) { name.Evaluate(context); context.CreateScope(RuntimeHost.ScopeFactory.Create(ScopeTypes.Using, context.Scope, context.Result)); statement.Evaluate(context); context.RemoveLocalScope(); }
public override void Evaluate(IScriptContext context) { name.Evaluate(context); context.CreateScope(RuntimeHost.ScopeFactory.Create(ScopeTypes.Using, context.Scope, context.Result)); statement.Evaluate(context); context.RemoveLocalScope(); }
public void EventHandler(object sender, T e) { if (Target == null) { return; } IScriptContext context = GetContext(Target); context.CreateScope(RuntimeHost.ScopeFactory.Create(ScopeTypes.Event, context.Scope, context, Target)); Target.Invoke(context, new[] { sender, e }); }
public object Invoke(IScriptContext context, object[] args) { activeContext = context; object result = RuntimeHost.NullValue; INotifyingScope functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context); context.CreateScope(functionScope); try { if (Parameters != null) { context.Result = args; Parameters.Evaluate(context); } functionScope.BeforeSetItem += ScopeBeforeSetItem; if (Contract != null) { functionScope.AfterSetItem += CheckContractInvariant; Contract.CheckPre(context); Contract.CheckInv(context); } context.Result = RuntimeHost.NullValue; Body.Evaluate(context); result = context.Result; if (Contract != null) { functionScope.AfterSetItem -= CheckContractInvariant; Contract.CheckInv(context); Contract.CheckPost(context); } } finally { context.RemoveLocalScope(); context.SetBreak(false); context.SetContinue(false); context.SetReturn(false); context.Result = result; functionScope.BeforeSetItem -= ScopeBeforeSetItem; activeContext = null; } return(result); }
public object Invoke(IScriptContext context, object[] args) { _activeContext = context; var result = RuntimeHost.NullValue; var functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context); context.CreateScope(functionScope); try { if (_parameters != null) { context.Result = args; _parameters.Evaluate(context); } _globalNames = GetGlobalNames(_activeContext); functionScope.BeforeSetItem += ScopeBeforeSetItem; if (_contract != null) { functionScope.AfterSetItem += CheckContractInvariant; _contract.CheckPre(context); _contract.CheckInv(context); } context.Result = RuntimeHost.NullValue; _body.Evaluate(context); result = context.Result; if (_contract != null) { functionScope.AfterSetItem -= CheckContractInvariant; _contract.CheckInv(context); _contract.CheckPost(context); } } finally { context.RemoveLocalScope(); context.ResetControlFlags(); context.Result = result; functionScope.BeforeSetItem -= ScopeBeforeSetItem; _activeContext = null; } return(result); }
public override void Evaluate(IScriptContext context) { var result = RuntimeHost.NullValue; //Create local scope var scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope); context.CreateScope(scope); try { _init.Evaluate(context); _cond.Evaluate(context); bool condBool = context.Result == null ? true : (bool)context.Result; while (condBool) { _statement.Evaluate(context); result = context.Result; if (context.IsBreak() || context.IsReturn()) { context.SetBreak(false); break; } if (context.IsContinue()) { context.SetContinue(false); } _next.Evaluate(context); _cond.Evaluate(context); condBool = context.Result == null ? true : (bool)context.Result; } context.Result = result; } finally { context.RemoveLocalScope(); } }
public override void Evaluate(IScriptContext context) { var result = RuntimeHost.NullValue; //Create local scope var scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope); context.CreateScope(scope); try { _init.Evaluate(context); _cond.Evaluate(context); bool condBool = context.Result == null ? true : (bool)context.Result; while (condBool) { _statement.Evaluate(context); result = context.Result; if (context.IsBreak() || context.IsReturn()) { context.SetBreak(false); break; } if (context.IsContinue()) { context.SetContinue(false); } _next.Evaluate(context); _cond.Evaluate(context); condBool = context.Result == null ? true : (bool)context.Result; } context.Result = result; } finally { context.RemoveLocalScope(); } }
public object Invoke(IScriptContext context, object[] args) { bool scopeOwner = false; if (args != null) { if (args.Length > 1) { throw new ArgumentException("Number of arguments "); } if (args.Length == 1) { var assigner = args[0] as ISupportAssign; if (assigner == null) { throw new NotSupportedException("Given type of argument is not supported"); } assigner.AssignTo(context.CreateScope()); scopeOwner = true; } } try { context.ResetControlFlags(); _metaProg.Evaluate(context); return(context.Result); } finally { if (scopeOwner) { context.RemoveLocalScope(); } context.ResetControlFlags(); } }
//TODO: Refactor public override void Evaluate(IScriptContext context) { if (ChildNodes.Count == 0) { return; } //Create local scope if (ShouldCreateScope) { IScriptScope scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope); context.CreateScope(scope); } try { int index = 0; while (index < ChildNodes.Count) { var node = (ScriptAst)ChildNodes[index]; node.Evaluate(context); if (context.IsBreak() || context.IsReturn() || context.IsContinue()) { break; } index++; } } finally { if (ShouldCreateScope) { context.RemoveLocalScope(); } } }
public object Invoke(IScriptContext context, object[] args) { context.CreateScope(); context.SetItem("me", _scriptable.Instance); context.SetItem("body", _scriptable); var rez = RuntimeHost.NullValue; try { rez = _dynamicMethod.Invoke(context, _arguments); } finally { context.RemoveLocalScope(); } if (rez != RuntimeHost.NullValue) { return(rez); } throw new ScriptExecutionException(string.Format(Strings.DynamicObjectMethodCallError, _scriptable)); }
public object Invoke(IScriptContext context, object[] args) { activeContext = context; object result = RuntimeHost.NullValue; INotifyingScope functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context); context.CreateScope(functionScope); try { if (Parameters != null) { context.Result = args; Parameters.Evaluate(context); } functionScope.BeforeSetItem += ScopeBeforeSetItem; if (Contract != null) { functionScope.AfterSetItem += CheckContractInvariant; Contract.CheckPre(context); Contract.CheckInv(context); } context.Result = RuntimeHost.NullValue; Body.Evaluate(context); result = context.Result; if (Contract != null) { functionScope.AfterSetItem -= CheckContractInvariant; Contract.CheckInv(context); Contract.CheckPost(context); } } finally { context.RemoveLocalScope(); context.SetBreak(false); context.SetContinue(false); context.SetReturn(false); context.Result = result; functionScope.BeforeSetItem -= ScopeBeforeSetItem; activeContext = null; } return result; }
public object Invoke(IScriptContext context, object[] args) { context.CreateScope(); context.SetItem("me", _scriptable.Instance); context.SetItem("body", _scriptable); var rez = RuntimeHost.NullValue; try { rez = _dynamicMethod.Invoke(context, _arguments); } finally { context.RemoveLocalScope(); } if (rez != RuntimeHost.NullValue) return rez; throw new ScriptExecutionException(string.Format(Strings.DynamicObjectMethodCallError, _scriptable)); }