コード例 #1
0
        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;
        }
コード例 #2
0
        ExecutionResults OnProceed(WamInstruction instruction)
        {
            StackIndex        -= 1;
            InstructionPointer = ReturnInstructionPointer;

            ReturnInstructionPointer = WamInstructionPointer.Undefined;
            TemporaryRegisters.Clear();
            return(ExecutionResults.None);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }