protected override object DoExecute(CodeContext context) { object ret = NextStatement; while (_test == null || (bool)_test.Evaluate(context)) { ret = _body.Execute(context); if (ret == Statement.Break) { return(NextStatement); } else if (!(ret is ControlFlow)) { return(ret); } if (_increment != null) { _increment.Evaluate(context); } } if (_else != null) { return(_else.Execute(context)); } return(NextStatement); }
protected override object DoExecute(CodeContext context) { IAttributesCollection scopeObject = _scope.Evaluate(context) as IAttributesCollection; CodeContext scopeContext = RuntimeHelpers.CreateNestedCodeContext(scopeObject, context, true); _body.Execute(scopeContext); return(NextStatement); }
protected override object DoEvaluate(CodeContext context) { object ret = _statement.Execute(context); // The interpreter is not able to deal with control flow inside of expressions if (ret != Statement.NextStatement) { throw new ExpressionReturnException(ret); } return(null); }
protected override object DoExecute(CodeContext context) { bool rethrow = false; Exception savedExc = null; object ret = Statement.NextStatement; try { ret = _body.Execute(context); } catch (Exception exc) { rethrow = true; savedExc = exc; if (_handlers != null) { PushEvalException(exc); try { foreach (CatchBlock handler in _handlers) { if (handler.Test.IsInstanceOfType(exc)) { rethrow = false; if (handler.Variable != null) { BoundAssignment.EvaluateAssign(context, handler.Variable, exc); } ret = handler.Body.Execute(context); break; } } } finally { PopEvalException(); } } } finally { if (_finally != null) { object finallyRet = _finally.Execute(context); if (finallyRet != Statement.NextStatement) { ret = finallyRet; rethrow = false; } } if (rethrow) { throw ExceptionHelpers.UpdateForRethrow(savedExc); } } return(ret); }
protected override object DoExecute(CodeContext context) { foreach (IfStatementTest t in _tests) { object val = t.Test.Evaluate(context); if (context.LanguageContext.IsTrue(val)) { return(t.Body.Execute(context)); } } if (_else != null) { return(_else.Execute(context)); } return(NextStatement); }
protected override object DoExecute(CodeContext context) { object ret = NextStatement; do { ret = _body.Execute(context); if (ret == Statement.Break) { break; } else if (!(ret is ControlFlow)) { return(ret); } } while (context.LanguageContext.IsTrue(_test.Evaluate(context))); return(NextStatement); }