Esempio n. 1
0
 ExecutionResults OnAllocate(WamInstruction instruction)
 {
     Environment = new WamEnvironment(Environment, ReturnInstructionPointer, CutChoicePoint);
     ReturnInstructionPointer = WamInstructionPointer.Undefined;
     InstructionPointer       = InstructionPointer.GetNext();
     return(ExecutionResults.None);
 }
Esempio n. 2
0
        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);
        }
Esempio n. 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>();
        }
Esempio n. 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>();
        }
Esempio n. 5
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>();
        }
        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>();
        }
Esempio n. 7
0
        private ExecutionResults OnAllocate(WamInstruction instruction)
        {
            Environment = new WamEnvironment(Environment, ReturnInstructionPointer, CutChoicePoint);
            ReturnInstructionPointer = WamInstructionPointer.Undefined;

            InstructionPointer = InstructionPointer.GetNext();

            return ExecutionResults.None;
        }