protected override void OnExecuteFrame(Engine engine) { engine.SetBreakFrame(); while (TypeHelper.ConvertToBool(Condition.Get(engine))) { Body.Execute(engine); engine.ClearShouldContinue(); if (engine.ShouldInterrupt) break; } }
protected override void OnExecuteFrame(Engine engine) { engine.SetBreakFrame(); foreach (var item in Collection.Get(engine) as IEnumerable) { engine.DefineVariable(VariableName, item); Body.Execute(engine); engine.ClearShouldContinue(); if (engine.ShouldInterrupt) break; } }
protected override void OnExecuteFrame(Engine engine) { engine.SetBreakFrame(); Initial.Execute(engine); while (Condition != null ? TypeHelper.ConvertToBool(Condition.Get(engine)) : true) { Body.Execute(engine); engine.ClearShouldContinue(); if (engine.ShouldInterrupt) break; if (Next != null) Next.Get(engine); } }
protected override void OnExecute(Engine engine) { var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree); var value = engine.Get(ValueProperty, Path, CodeTree) as IEnumerable; var name = engine.GetVariable(Var, VarCodeTree); foreach (object item in value) { engine.DefineVariable(name, TypeHelper.Convert(item, type)); Body.Execute(engine); engine.ClearShouldContinue(); if (engine.ShouldInterrupt) break; } }
protected override void OnExecute(Engine engine) { // Use the same name and type for the whole loop. var name = engine.GetVariable(Var, VarCodeTree); var type = engine.GetType(TypeProperty, TypePath, TypeCodeTree); if (type == null && (UpperLimit != null || Increment != null)) type = typeof(int); // If no name is specified then forever. if (name == null) { engine.SetBreakFrame(); while (true) { Body.Execute(engine); engine.ClearShouldContinue(); if (engine.ShouldInterrupt) break; } return; } // Normal loop processing. SetLoopValue(name, engine.Get(ValueProperty, Path, CodeTree, type), type, engine); engine.SetBreakFrame(); while (true) { if (While != null) { if (!(bool)engine.Get(WhileProperty, WhilePath, WhileCodeTree, typeof(bool))) break; } else if (UpperLimit != null) { var limit = engine.Get(UpperLimitProperty, UpperLimitPath, UpperLimitCodeTree, type); if (!(bool)engine.Operator(Op.LessThan, GetLoopValue(name, type, engine), limit)) break; } Body.Execute(engine); engine.ClearShouldContinue(); if (engine.ShouldInterrupt) break; if (Next.Count != 0) Next.Execute(engine); else if (Increment != null) { var increment = engine.Get(IncrementProperty, IncrementPath, IncrementCodeTree, type); SetLoopValue(name, engine.Operator(Op.Plus, GetLoopValue(name, type, engine), increment), type, engine); } } }