public virtual bool PreExecute(AnimationCommandStorage ACS, OALProgram OALProgram, EXEScope Scope) { OALProgram.AccessInstanceDatabase(); Boolean Success = this.Execute(OALProgram, Scope); ACS.AddAnimationStep(new AnimationCommand(Scope, this)); OALProgram.LeaveInstanceDatabase(); return(Success); }
public virtual Boolean SynchronizedExecute(OALProgram OALProgram, EXEScope Scope) { OALProgram.AccessInstanceDatabase(); Console.WriteLine(this.ToCode()); Boolean Success = this.Execute(OALProgram, Scope); Console.WriteLine("Done"); OALProgram.LeaveInstanceDatabase(); return(Success); }
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 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 override Boolean Execute(OALProgram OALProgram, EXEScope Scope) { this.OALProgram = OALProgram; Boolean Result = true; Boolean AScopeWasExecuted = false; if (this.Condition == null) { return(false); } OALProgram.AccessInstanceDatabase(); String ConditionResult = this.Condition.Evaluate(Scope, OALProgram.ExecutionSpace); OALProgram.LeaveInstanceDatabase(); if (ConditionResult == null) { return(false); } if (!EXETypes.BooleanTypeName.Equals(EXETypes.DetermineVariableType("", ConditionResult))) { return(false); } Boolean IfConditionResult = EXETypes.BooleanTrue.Equals(ConditionResult) ? true : false; if (IfConditionResult) { foreach (EXECommand Command in this.Commands) { Result = Command.SynchronizedExecute(OALProgram, this); if (!Result) { break; } } AScopeWasExecuted = true; } if (AScopeWasExecuted) { return(Result); } if (this.ElifScopes != null) { foreach (EXEScopeCondition CurrentElif in this.ElifScopes) { if (CurrentElif.Condition == null) { return(false); } OALProgram.AccessInstanceDatabase(); ConditionResult = CurrentElif.Condition.Evaluate(Scope, OALProgram.ExecutionSpace); OALProgram.LeaveInstanceDatabase(); if (ConditionResult == null) { return(false); } if (!EXETypes.BooleanTypeName.Equals(EXETypes.DetermineVariableType("", ConditionResult))) { return(false); } IfConditionResult = EXETypes.BooleanTrue.Equals(ConditionResult) ? true : false; if (IfConditionResult) { Result = CurrentElif.SynchronizedExecute(OALProgram, CurrentElif); AScopeWasExecuted = true; break; } } } if (AScopeWasExecuted) { return(Result); } if (this.ElseScope != null) { Result = this.ElseScope.SynchronizedExecute(OALProgram, ElseScope); } return(Result); }