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; }
public WamInstructionPointer(WamInstructionStream instructionStream) { if (instructionStream == null) { throw new ArgumentNullException("instructionStream"); } _instructionStream = instructionStream; _index = 0; }
internal void InvalidateInstructionStream() { _wamInstructionStream = null; if (_prologInstructionStream != null) { _prologInstructionStream = null; RaisePropertyChanged(new PropertyChangedEventArgs("PrologInstructionStream")); } }
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); }
internal PrologInstructionStream(IPrologInstructionStreamContainer container) { if (container == null) { throw new ArgumentNullException("container"); } m_container = container; m_wamInstructionStream = m_container.WamInstructionStream; for (int idx = 0; idx < m_wamInstructionStream.Length; ++idx) { Items.Add(new PrologInstruction(this, idx)); } }
private PrologVariableList GetPermanentVariables(int stackIndex, bool getCodeTerm) { PrologVariableList result = new PrologVariableList(); WamEnvironment environment = WamMachine.GetEnvironment(stackIndex); if (environment != null) { // Retrieve register name assignments from instruction stream. // Dictionary <int, string> variableNames; WamInstructionStream wamInstructionStream = WamMachine.GetInstructionPointer(stackIndex).InstructionStream; if (wamInstructionStream != null) { variableNames = wamInstructionStream.GetPermanentVariableAssignments(); } else { variableNames = new Dictionary <int, string>(); } for (int index = 0; index < environment.PermanentRegisters.Count; ++index) { PrologVariable variable = result.Add(string.Format("Y{0}", index)); string name; if (variableNames.TryGetValue(index, out name)) { variable.Name = name; } WamReferenceTarget referenceTarget = environment.PermanentRegisters[index]; if (referenceTarget != null) { if (getCodeTerm) { variable.CodeTerm = referenceTarget.GetCodeTerm(); } else { variable.Text = referenceTarget.ToString(); } } } } return(result); }
public WamInstructionPointer(WamInstructionStream instructionStream, int index) { _instructionStream = instructionStream; _index = index; }