Exemple #1
0
        internal void OldRun(PsudoProgram psudoProgram)
        {
            for (int i = 0; i < this.Instructions.Count; i++)
            {
                psudoProgram.OnBeforeInstruction(this.Instructions[i]);

                if (this.Instructions[i] == null)
                {
                    psudoProgram.OnError("Null Instruction on Line " + i + "\n");
                    continue;
                }
                PsudoInstruction jump = this.Instructions[i].Run();

                psudoProgram.OnAfterInstruction(this.Instructions[i]);

                if (jump != null)
                {
                    int jumpLine = this.Instructions.FindIndex(item => item != null && item.Line >= jump.Line) - 1;
                    // if (jumpLine >= 0)
                    i = jumpLine;
                }

                // if returning break out of the loop
                if (this.Instructions[i] is ReturnInstruction)
                {
                    break;
                }
            }
        }
Exemple #2
0
        internal void Run(PsudoProgram psudoProgram)
        {
            // Handle empty blocks of code cleanly
            if (this.Instructions.Count == 0)
            {
                return;
            }

            PsudoInstruction curIns = this.Instructions[0];

            while (curIns != null)
            {
                psudoProgram.OnBeforeInstruction(curIns);

                PsudoInstruction jump = curIns.Run();

                psudoProgram.OnAfterInstruction(curIns);

                // if returning break out of the loop
                if (curIns is ReturnInstruction)
                {
                    curIns = null;
                }
                else if (jump == null)
                {
                    curIns = this.Instructions.Find(item => item != null && item.Line > curIns.Line);
                }
                else
                {
                    curIns = jump;
                }
            }
        }
        internal void OnBeforeInstruction(PsudoInstruction instruction)
        {
            if (this.abortRun)
            {
                throw new Exception("Run Aborted. Exiting.");
            }

            if (instruction == null)
            {
                return;
            }

            if (this.BeforeInstruction != null)
            {
                this.BeforeInstruction(this, new Instruction_EventArgs(instruction.Line));
            }
        }
Exemple #4
0
 public FlowChartItemControl(PsudoInstruction instruction)
     : this(instruction.ToString())
 {
     inst = instruction;
 }