Пример #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
        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);
        }
Пример #3
0
        public WamChoicePoint(WamChoicePoint predecessor, WamEnvironment environment, int stackIndex, WamInstructionPointer returnInstructionPointer, IEnumerable <WamReferenceTarget> argumentRegisters, WamChoicePoint cutChoicePoint)
        {
            Generation = NextGeneration++;

            Predecessor = predecessor;
            Environment = environment;
            StackIndex  = stackIndex;
            ReturnInstructionPointer = returnInstructionPointer;
            ArgumentRegisters        = new WamReferenceTargetList(argumentRegisters);
            CutChoicePoint           = cutChoicePoint;

            BacktrackInstructionPointer = WamInstructionPointer.Undefined;
            PredicateEnumerator         = null;

            Trail = new List <WamVariable>();
        }
Пример #4
0
        public WamChoicePoint(WamChoicePoint predecessor, WamEnvironment environment, int stackIndex, WamInstructionPointer returnInstructionPointer, IEnumerable <WamReferenceTarget> argumentRegisters, WamChoicePoint cutChoicePoint)
        {
            m_generation = s_nextGeneration++;

            m_predecessor = predecessor;
            m_environment = environment;
            m_stackIndex  = stackIndex;
            m_returnInstructionPointer = returnInstructionPointer;
            m_argumentRegisters        = new WamReferenceTargetList(argumentRegisters);
            m_cutChoicePoint           = cutChoicePoint;

            m_backtrackInstructionPointer = WamInstructionPointer.Undefined;
            m_predicateEnumerator         = null;

            m_trail = new List <WamVariable>();
        }
Пример #5
0
        internal void Synchronize()
        {
            WamInstructionPointer wamInstructionPointer = Container.Machine.WamMachine.GetInstructionPointer(StackIndex);

            PrologInstruction currentInstruction = InstructionStream[wamInstructionPointer.Index];

            if (CurrentInstruction != currentInstruction)
            {
                if (CurrentInstruction != null)
                {
                    CurrentInstruction.IsCurrentInstruction = false;
                }
                CurrentInstruction = currentInstruction;
                if (CurrentInstruction != null)
                {
                    CurrentInstruction.IsCurrentInstruction = true;
                }
            }
        }
Пример #6
0
 bool IsBreakpoint(WamInstructionPointer wamInstructionPointer)
 {
     //HACK: Implement
     return(false);
 }