예제 #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
        private WamMachine(Program program, Query query)
        {
            if (program == null)
            {
                throw new ArgumentNullException("program");
            }
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            m_program = program;
            m_query = query;

            m_contextStack = new Stack<WamContext>();
            m_currentContext = null;

            m_performanceStatistics = new PerformanceStatistics();
        }
예제 #3
0
 private void ClearContextStack()
 {
     m_contextStack.Clear();
     m_currentContext = null;
 }
예제 #4
0
        public void PopContext(bool unwindTrail)
        {
            if (m_contextStack.Count == 0)
            {
                throw new InvalidOperationException("Context stack is empty.");
            }

            if (unwindTrail)
            {
                while (ChoicePoint != null)
                {
                    UnwindTrail();
                    ChoicePoint = ChoicePoint.Predecessor;
                }
            }

            m_contextStack.Pop();

            if (m_contextStack.Count == 0)
            {
                m_currentContext = null;
            }
            else
            {
                m_currentContext = m_contextStack.Peek();
            }
        }
예제 #5
0
        public void PushContext(WamInstructionStream instructionStream)
        {
            if (instructionStream == null)
            {
                throw new ArgumentNullException("instructionStream");
            }

            WamContext context = new WamContext();
            m_contextStack.Push(context);
            m_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;
        }