public void PushContext(WamInstructionStream instructionStream) { if (instructionStream == null) { throw new ArgumentNullException("instructionStream"); } var context = new WamContext(); _contextStack.Push(context); CurrentContext = context; State = WamMachineStates.Run; InstructionPointer = new WamInstructionPointer(instructionStream); ReturnInstructionPointer = WamInstructionPointer.Undefined; StackIndex = 0; Environment = null; ChoicePoint = null; ArgumentRegisters.Clear(); TemporaryRegisters.Clear(); CurrentStructure = null; CurrentStructureIndex = -1; }
ExecutionResults OnProceed(WamInstruction instruction) { StackIndex -= 1; InstructionPointer = ReturnInstructionPointer; ReturnInstructionPointer = WamInstructionPointer.Undefined; TemporaryRegisters.Clear(); return(ExecutionResults.None); }
public void SetInstructionStream(WamInstructionStream instructionStream) { if (instructionStream == null) { throw new ArgumentNullException("instructionStream"); } ReturnInstructionPointer = InstructionPointer.GetNext(); CutChoicePoint = ChoicePoint; TemporaryRegisters.Clear(); StackIndex += 1; InstructionPointer = new WamInstructionPointer(instructionStream); }
ExecutionResults OnExecute(WamInstruction instruction) { var instructionPointer = GetInstructionPointer(instruction.Functor, 0); if (instructionPointer == WamInstructionPointer.Undefined) { return(ExecutionResults.Failure); } if (StackIndex >= StackSizeLimit) { return(ExecutionResults.Failure); } CutChoicePoint = ChoicePoint; TemporaryRegisters.Clear(); InstructionPointer = instructionPointer; return(ExecutionResults.None); }