Example #1
0
 public void RunNextInstruction()
 {
     if (!CodeIsRunning())
     {
         ResetCodeState();
     }
     else
     {
         if (curInstruction == StartCodeBlock.instance.GetMyInternalIArgument() as Instruction)
         {
             MemoryManager.instance.SaveMemoryState();
         }
         try {
             ++numInstructionsRun;
             LoggingManager.instance.UpdateLogColumn(instructionRunCol, curInstruction?.DescriptiveInstructionToString());
             lastInstructionReturn = curInstruction.RunInstruction();
             UpdateCurInstruction();
             if (numInstructionsRun > instructionRunLimit)
             {
                 throw new Exception("Too man instructions run, maybe an infinite loop?");
             }
         }
         catch (Exception ex) {
             string lineToAdd = ex.ToString();
             if (lineToAdd.Contains("NULL"))
             {
                 lineToAdd = "Instruction Block Incomplete";
             }
             ConsoleManager.instance.AddLine(string.Join("", lineToAdd, ", Code Resetting"));
             Debug.LogWarning(ex.ToString());
             ResetCodeState();
         }
     }
 }
Example #2
0
 public void ResetCodeState()
 {
     if (instructionStack == null)
     {
         instructionStack = new Stack <Instruction>();
     }
     fullSteppingCode = false;
     ExerciseManager.instance.AlertCodeReset();
     ConsoleManager.instance.ClearConsole();
     curInstruction?.GetCodeBlock()?.ToggleOutline(false);
     instructionStack.Clear();
     lastInstructionReturn = null;
     curInstruction        = StartCodeBlock.instance.GetMyInternalIArgument() as Instruction;
     StartCodeBlock.instance.ToggleOutline(true);
     CodeBlockManager.instance.ResetAllCodeBlockInternalState();
     MemoryManager.instance.ResetMemoryState();
     numInstructionsRun = 0;
 }