コード例 #1
0
ファイル: Executor.cs プロジェクト: zbream/school-work
        public void Execute(Machine machine)
        {
            // something's wrong if we exceed this pointer
            int pointerMax = actions.Count - 1;

            // with no actions to perform, Pointer would start outside pointerMax
            if (pointerMax < 0)
            {
                return;
            }

            // begin execution
            while (machine.Pointer >= 0)
            {
                // assert that pointer remains within code
                if (machine.Pointer > pointerMax)
                {
                    throw new ExecuteException("Execution has left the written code, are you missing a halt or return?");
                }

                // perform, and move pointer if necessary
                IExecutorAction action         = actions[machine.Pointer];
                bool            advancePointer = action.Perform(machine);
                if (advancePointer)
                {
                    machine.Pointer++;
                }
            }
        }
コード例 #2
0
ファイル: Executor.cs プロジェクト: zbream/school-work
        public void ParseAndAddAction(string lval, string rval)
        {
            IExecutorAction action = parseAction(lval, rval);

            // some commands, like "label", do not have an associated action
            if (action != null)
            {
                actions.Add(action);
            }
        }