public DekiScriptLiteral Visit(DekiScriptSequence expr, DekiScriptEnv env) { if (expr.Kind != DekiScriptSequence.ScopeKind.None) { env = env.NewLocalScope(); } bool safe = env.IsSafeMode; DekiScriptEvaluationAccumulator accumulator = new DekiScriptEvaluationAccumulator(); foreach (DekiScriptExpression expression in expr.List) { try { accumulator.Add(expression.VisitWith(this, env), safe); } catch (DekiScriptAbort.Exception e) { // flow control exception occurred (e.g. break/continue) accumulator.Add(e.AccumulatedState, safe); switch (expr.Kind) { case DekiScriptSequence.ScopeKind.ScopeCatchContinue: if (e.FlowControl == DekiScriptAbort.Kind.Continue) { return(accumulator.Value); } break; case DekiScriptSequence.ScopeKind.ScopeCatchBreakAndContinue: return(accumulator.Value); } throw new DekiScriptAbort.Exception(e.FlowControl, accumulator.Value); } } return(accumulator.Value); }
public DekiScriptLiteral Visit(DekiScriptForeach expr, DekiScriptEnv env) { bool safe = env.IsSafeMode; try { DekiScriptEvaluationAccumulator accumulator = new DekiScriptEvaluationAccumulator(); DekiScriptGeneratorEvaluation.Instance.Generate(expr.Generator, delegate(DekiScriptEnv subEnv) { // iterate over block statements try { accumulator.Add(expr.Block.VisitWith(this, subEnv), safe); } catch (DekiScriptAbort.Exception e) { accumulator.Add(e.AccumulatedState, safe); if (e.FlowControl == DekiScriptAbort.Kind.Break) { throw new DekiScriptAbort.Exception(e.FlowControl, accumulator.Value); } } }, env.NewLocalScope()); return(accumulator.Value); } catch (DekiScriptAbort.Exception e) { return(e.AccumulatedState); } }