//TODO: reorganize switch public override void Evaluate(IScriptContext context) { switch (_operation) { case "break": if (context.Result == null) { context.Result = RuntimeHost.NullValue; } context.SetBreak(true); break; case "continue": if (context.Result == null) { context.Result = RuntimeHost.NullValue; } context.SetContinue(true); break; case "return": _expression.Evaluate(context); context.SetReturn(true); break; case "throw": _expression.Evaluate(context); throw (Exception)context.Result; default: throw new ScriptSyntaxErrorException(_operation); } }
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 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(); } }
protected static bool CheckCondition(ScriptAst cond, IScriptContext context) { cond.Evaluate(context); return (bool)context.Result; }
protected static bool CheckCondition(ScriptAst cond, IScriptContext context) { cond.Evaluate(context); return((bool)context.Result); }