Mosa.Compiler.Framework.InstructionNode.GetResult C# (CSharp) Method

GetResult() public method

Gets the result.
public GetResult ( int index ) : Operand
index int The index.
return Operand
        public Operand GetResult(int index)
        {
            switch (index)
            {
                case 0: return Result;
                case 1: return Result2;
                default: throw new IndexOutOfRangeException();
            }
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <param name="node">The context.</param>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public string ToString(InstructionNode node)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("L_{0:X4}", node.Label);

            if (node.Marked)
                sb.Append('*');
            else
                sb.Append(' ');

            sb.Append(ToString());

            var size = GetSizeString(node.Size);

            if (size != string.Empty)
                sb.Append("/" + size);

            if (node.ConditionCode != ConditionCode.Undefined)
            {
                sb.Append(" [");
                sb.Append(GetConditionString(node.ConditionCode));
                sb.Append("]");
            }

            if (node.MosaType != null)
            {
                sb.Append(" [[");
                sb.Append(node.MosaType.FullName);
                sb.Append("]]");
            }

            if (node.MosaField != null)
            {
                sb.Append(" [[");
                sb.Append(node.MosaField.FullName);
                sb.Append("]]");
            }

            string mod = GetModifier(node);
            if (mod != null)
            {
                sb.Append(" [");
                sb.Append(mod);
                sb.Append("]");
            }

            for (int i = 0; i < node.ResultCount; i++)
            {
                var op = node.GetResult(i);
                sb.Append(" ");
                sb.Append(op == null ? "[NULL]" : op.ToString());
                sb.Append(",");
            }

            if (node.ResultCount > 0)
            {
                sb.Length = sb.Length - 1;
            }

            if (node.ResultCount > 0 && node.OperandCount > 0)
            {
                sb.Append(" <=");
            }

            for (int i = 0; i < node.OperandCount; i++)
            {
                var op = node.GetOperand(i);
                sb.Append(" ");
                sb.Append(op == null ? "[NULL]" : op.ToString());
                sb.Append(",");
            }

            if (node.OperandCount > 0)
            {
                sb.Length = sb.Length - 1;
            }

            if (node.BranchTargets != null)
            {
                sb.Append(' ');

                for (int i = 0; (i < 2) && (i < node.BranchTargetsCount); i++)
                {
                    if (i != 0)
                    {
                        sb.Append(", ");
                    }

                    sb.Append(node.BranchTargets[i].ToString());
                }

                if (node.BranchTargetsCount > 2)
                {
                    sb.Append(", [more]");
                }
            }

            if (node.InvokeMethod != null)
            {
                sb.Append(" {");
                sb.Append(node.InvokeMethod.FullName);
                sb.Append("}");
            }

            if (node.MosaField != null)
            {
                sb.Append(" {");
                sb.Append(node.MosaField.FullName);
                sb.Append("}");
            }

            return sb.ToString();
        }
All Usage Examples Of Mosa.Compiler.Framework.InstructionNode::GetResult