Beispiel #1
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);
        }
Beispiel #2
0
        PrologVariableList GetTemporaryVariables()
        {
            var result = new PrologVariableList();

            for (var index = 0; index < WamMachine.TemporaryRegisters.Count; ++index)
            {
                var value           = "*";
                var referenceTarget = WamMachine.TemporaryRegisters[index];
                if (referenceTarget != null)
                {
                    value = referenceTarget.ToString();
                }
                result.Add(string.Format("X{0}", index)).Text = value;
            }
            return(result);
        }
Beispiel #3
0
        private PrologVariableList GetArgumentVariables()
        {
            PrologVariableList result = new PrologVariableList();

            for (int index = 0; index < WamMachine.ArgumentRegisters.Count; ++index)
            {
                string             value           = "*";
                WamReferenceTarget referenceTarget = WamMachine.ArgumentRegisters[index];
                if (referenceTarget != null)
                {
                    value = referenceTarget.ToString();
                }

                result.Add(string.Format("A{0}", index)).Text = value;
            }

            return(result);
        }