예제 #1
0
        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);
        }
예제 #2
0
        public void RequestStep(EXECommand Command, EXEScope SuperScope, AnimationCommandStorage ACS)
        {
            lock (this.Syncer)
            {
                Debug.Log("Got into Thread Syncer");
                //If the room has been entered previously and has not been emptied yet, we must wait until it's emptied
                while (this.Blocked)
                {
                    Monitor.Wait(this.Syncer);
                }

                //If someone changed number of threads, let's do it
                PerformThreadCountChange();

                //Let us let know everyone of our presence
                this.InLockCount++;
                this.UntilLockResetCount--;
                if (this.InLockCount == 1)
                {
                    //AnimationCommandStorage.GetInstance();//.NewAnimationSequence();
                    ACS.NewAnimationSequence();
                }
                /*Animation.Instance.AddAnimationStep(new AnimationCommand(SuperScope, Command));*/
                ACS.AddAnimationStep(new AnimationCommand(SuperScope, Command));

                //If we have to wait for more threads, let's sleep until they come
                while (this.UntilLockResetCount > 0)
                {
                    //If someone changed number of threads, let's do it
                    PerformThreadCountChange();
                    Monitor.Wait(this.Syncer);
                }
                //If we are the last thread to come, let's block the room until everyone leaves and wake everyone up
                if (this.UntilLockResetCount == 0)
                {
                    this.Blocked = true;
                    OALProgram.RequestNextStep();
                    Monitor.PulseAll(this.Syncer);
                }

                //Let know that we are leaving
                this.InLockCount--;
                //If we are the last one leaving, unblock the room and reset counters. And wake up possible sleepers
                if (this.InLockCount == 0)
                {
                    this.Blocked             = false;
                    this.UntilLockResetCount = this.ThreadCount;
                    //Animation.Instance.NewAnimationSequence();
                    ACS.NewAnimationSequence();
                    Monitor.PulseAll(this.Syncer);
                }
            }
        }
예제 #3
0
        public bool PreExecute(AnimationCommandStorage ACS)
        {
            bool Result = false;

            this.ThreadSyncer.RegisterThread(1);

            Result = this.SuperScope.PreExecute(ACS, this, this.SuperScope);

            this.ThreadSyncer.UnregisterThread();
            this.SuperScope.ClearVariablesRecursive();

            return(Result);
        }
예제 #4
0
        public bool PreExecute(AnimationCommandStorage ACS)
        {
            bool Result = false;

            this.ThreadSyncer.RegisterThread(1);

            Result = this.SuperScope.PreExecute(ACS, this, null);   //predtym bol v tretom parametri this.Superscope

            this.ThreadSyncer.UnregisterThread();
            this.SuperScope.ClearVariablesRecursive();

            return(Result);
        }
예제 #5
0
        public override Boolean PreExecute(AnimationCommandStorage ACS, OALProgram OALProgram, EXEScope Scope)
        {
            this.OALProgram = OALProgram;
            this.OALProgram.ThreadSyncer.RegisterThread((uint)this.Threads.Count);
            EXEScopeParallel ParallelScope = this;
            Boolean          Success       = true;

            lock (this.MyThreadEndSyncer)
            {
                this.ActiveThreadCount = this.Threads.Count;
            }

            OALProgram.ThreadSyncer.UnregisterThread();

            foreach (EXEScope ThreadScope in this.Threads)
            {
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = false;

                    Boolean MySuccess = ThreadScope.PreExecute(ACS, OALProgram, ParallelScope);

                    OALProgram.ThreadSyncer.UnregisterThread();

                    lock (ParallelScope.MyThreadEndSyncer)
                    {
                        Success &= MySuccess;
                        ParallelScope.ActiveThreadCount--;
                        if (ParallelScope.ActiveThreadCount == 0)
                        {
                            Monitor.PulseAll(this.MyThreadEndSyncer);
                        }
                    }
                }).Start();
            }

            lock (this.MyThreadEndSyncer)
            {
                while (this.ActiveThreadCount > 0)
                {
                    Monitor.Wait(this.MyThreadEndSyncer);
                }
            }

            OALProgram.ThreadSyncer.RegisterThread(1);

            return(Success);
        }
예제 #6
0
        public override Boolean PreExecute(AnimationCommandStorage ACS, OALProgram OALProgram, EXEScope Scope)
        {
            OALProgram.ThreadSyncer.RequestStep(this, Scope, ACS);

            //ACS.AddAnimationStep(new AnimationCommand(Scope, this));

            //Filip, ak mas null v executablecode tak vrat true inak toto dole
            EXEScopeMethod ExecutableCode = OALProgram.ExecutionSpace.getClassByName(this.CalledClass).getMethodByName(this.CalledMethod).ExecutableCode;

            if (ExecutableCode != null)
            {
                return(ExecutableCode.PreExecute(ACS, OALProgram, Scope));
            }

            return(true);
        }
예제 #7
0
        public override Boolean PreExecute(AnimationCommandStorage ACS, OALProgram OALProgram, EXEScope Scope)
        {
            this.OALProgram = OALProgram;

            Boolean Success = true;

            foreach (EXECommand Command in this.Commands)
            {
                Success = Command.PreExecute(ACS, OALProgram, this);
                if (!Success)
                {
                    break;
                }
            }

            return(Success);
        }
예제 #8
0
        public override Boolean PreExecute(AnimationCommandStorage ACS, 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.PreExecute(ACS, 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);
        }
예제 #9
0
 public override Boolean PreExecute(AnimationCommandStorage ACS, OALProgram OALProgram, EXEScope Scope)
 {
     OALProgram.ThreadSyncer.RequestStep(this, Scope, ACS);
     //ACS.AddAnimationStep(new AnimationCommand(Scope, this));
     return(true);
 }
예제 #10
0
        public override Boolean PreExecute(AnimationCommandStorage ACS, 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.PreExecute(ACS, 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);
        }
예제 #11
0
        public override Boolean PreExecute(AnimationCommandStorage ACS, 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.PreExecute(ACS, 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.PreExecute(ACS, OALProgram, CurrentElif);
                        AScopeWasExecuted = true;
                        break;
                    }
                }
            }

            if (AScopeWasExecuted)
            {
                return(Result);
            }

            if (this.ElseScope != null)
            {
                Result = this.ElseScope.PreExecute(ACS, OALProgram, ElseScope);
            }

            return(Result);
        }