public virtual bool PropagateControlCommand(LoopControlStructure PropagatedCommand) { if (this.SuperScope == null) { return(false); } return(this.SuperScope.PropagateControlCommand(PropagatedCommand)); }
public override bool PropagateControlCommand(LoopControlStructure PropagatedCommand) { if (this.CurrentLoopControlCommand != LoopControlStructure.None) { return(false); } this.CurrentLoopControlCommand = PropagatedCommand; return(true); }
public override Boolean Execute(OALProgram OALProgram, EXEScope Scope) { this.OALProgram = OALProgram; OALProgram.AccessInstanceDatabase(); EXEReferencingVariable IteratorVariable = this.FindReferencingVariableByName(this.IteratorName); EXEReferencingSetVariable IterableVariable = this.FindSetReferencingVariableByName(this.IterableName); OALProgram.LeaveInstanceDatabase(); Boolean Success = true; // We cannot iterate over not existing reference set if (Success && IterableVariable == null) { Success = false; } // If iterator already exists and its class does not match the iterable class, we cannot do this if (Success && IteratorVariable != null && !IteratorVariable.ClassName.Equals(IterableVariable.ClassName)) { Success = false; } // If iterator name is already taken for another variable, we quit again. Otherwise we create the iterator variable if (Success && IteratorVariable == null) { IteratorVariable = new EXEReferencingVariable(this.IteratorName, IterableVariable.ClassName, -1); Success = this.GetSuperScope().AddVariable(IteratorVariable); } if (Success) { foreach (EXEReferencingVariable CurrentItem in IterableVariable.GetReferencingVariables()) { //!!NON-RECURSIVE!! this.ClearVariables(); IteratorVariable.ReferencedInstanceId = CurrentItem.ReferencedInstanceId; Console.WriteLine("ForEach: " + CurrentItem.ReferencedInstanceId); foreach (EXECommand Command in this.Commands) { if (this.CurrentLoopControlCommand != LoopControlStructure.None) { break; } Success = Command.SynchronizedExecute(OALProgram, this); if (!Success) { break; } } if (!Success) { break; } if (this.CurrentLoopControlCommand == LoopControlStructure.Break) { this.CurrentLoopControlCommand = LoopControlStructure.None; break; } else if (this.CurrentLoopControlCommand == LoopControlStructure.Continue) { this.CurrentLoopControlCommand = LoopControlStructure.None; continue; } } } return(Success); }
public EXEScopeForEach(EXEScope SuperScope, EXECommand[] Commands, String Iterator, String Iterable) : base(SuperScope, Commands) { this.IteratorName = Iterator; this.IterableName = Iterable; this.CurrentLoopControlCommand = LoopControlStructure.None; }
public override Boolean Execute(OALProgram OALProgram, EXEScope Scope) { Boolean Success = true; this.OALProgram = OALProgram; bool ConditionTrue = true; String ConditionResult; int IterationCounter = 0; while (ConditionTrue) { OALProgram.AccessInstanceDatabase(); ConditionResult = this.Condition.Evaluate(Scope, OALProgram.ExecutionSpace); OALProgram.LeaveInstanceDatabase(); //!!NON-RECURSIVE!! this.ClearVariables(); if (ConditionResult == null) { return(false); } if (!EXETypes.BooleanTypeName.Equals(EXETypes.DetermineVariableType("", ConditionResult))) { return(false); } ConditionTrue = EXETypes.BooleanTrue.Equals(ConditionResult); if (!ConditionTrue) { break; } if (IterationCounter >= EXEExecutionGlobals.LoopIterationCap) { Success = false; break; } foreach (EXECommand Command in this.Commands) { if (this.CurrentLoopControlCommand != LoopControlStructure.None) { break; } Success = Command.SynchronizedExecute(OALProgram, this); if (!Success) { break; } } if (!Success) { break; } IterationCounter++; if (this.CurrentLoopControlCommand == LoopControlStructure.Break) { this.CurrentLoopControlCommand = LoopControlStructure.None; break; } else if (this.CurrentLoopControlCommand == LoopControlStructure.Continue) { this.CurrentLoopControlCommand = LoopControlStructure.None; continue; } } return(Success); }
public EXEScopeLoopWhile(EXEScope SuperScope, EXECommand[] Commands, EXEASTNode Condition) : base(SuperScope, Commands) { this.Condition = Condition; this.CurrentLoopControlCommand = LoopControlStructure.None; }
public EXEScopeLoopWhile(EXEASTNode Condition) : base() { this.Condition = Condition; this.CurrentLoopControlCommand = LoopControlStructure.None; }
public override bool PropagateControlCommand(LoopControlStructure PropagatedCommand) { return(false); }