Example #1
0
        public override string ToString()
        {
            if (m_target == null)
            {
                return("_");
            }

            return(m_target.ToString());
        }
Example #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);
        }
Example #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);
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(OpCode.ToString());

            string prefix = " ";

            if (m_sourceRegister.IsUsed)
            {
                sb.Append(prefix); prefix = ", ";
                sb.Append(m_sourceRegister.ToString());
            }

            if (m_functor != null)
            {
                sb.Append(prefix); prefix = ", ";
                sb.Append(m_functor.ToString());
            }

            if (m_index >= 0)
            {
                sb.Append(prefix); prefix = ", ";
                sb.Append(m_index.ToString());
            }

            if (m_referenceTarget != null)
            {
                sb.Append(prefix); prefix = ", ";
                sb.Append(m_referenceTarget.ToString());
            }

            if (m_targetRegister.IsUsed)
            {
                sb.Append(prefix); prefix = ", ";
                sb.Append(m_targetRegister.ToString());
            }

            return(sb.ToString());
        }