/// <summary> /// Returns a string representation of <see cref="Operand" />. /// </summary> /// <param name="full">if set to <c>true</c> [full].</param> /// <returns> /// A string representation of the operand. /// </returns> public string ToString(bool full) { if (IsSSA) { string ssa = SSAParent.ToString(full); int pos = ssa.IndexOf(' '); if (pos < 0) { return(ssa + "<" + SSAVersion + ">"); } else { return(ssa.Substring(0, pos) + "<" + SSAVersion + ">" + ssa.Substring(pos)); } } var sb = new StringBuilder(); if (IsVirtualRegister) { if (!IsSplitChild) { sb.AppendFormat("V_{0}", Index); } else { sb.AppendFormat("<V_{0}_{1}_{2}>", Index, SplitParent.Index, (SplitParent.High == this) ? "H" : "L"); } } else if (IsParameter) { if (!IsSplitChild) { sb.AppendFormat("P_{0}", Index); } else { sb.AppendFormat("P_{0}_{1}", SplitParent.Index, (SplitParent.High == this) ? "H" : "L"); } } else if (IsStackLocal && Name == null) { if (!IsSplitChild) { sb.AppendFormat("T_{0}", Index); } else { sb.AppendFormat("T_{0}{1}", SplitParent.Index, (SplitParent.High == this) ? "h" : "l"); } } else if (IsStaticField) { sb.Append(" <"); sb.Append(Field.FullName); sb.Append("> "); } else if (Name != null) { sb.Append(" <"); sb.Append(Name); sb.Append("> "); } if (IsConstant) { sb.Append(" const="); if (!IsResolved) { sb.Append("unresolved"); } else if (IsNull) { sb.Append("null"); } else if (IsOnStack) { sb.AppendFormat("{0}", ConstantSignedLongInteger); } else if (IsUnsigned || IsBoolean || IsChar || IsPointer) { if (IsU8) { sb.AppendFormat("{0}", ConstantUnsignedLongInteger); } else { sb.AppendFormat("{0}", ConstantUnsignedInteger); } } else if (IsSigned) { if (IsI8) { sb.AppendFormat("{0}", ConstantSignedLongInteger); } else { sb.AppendFormat("{0}", ConstantSignedInteger); } } else if (IsR8) { sb.AppendFormat("{0}", ConstantDoubleFloatingPoint); } else if (IsR4) { sb.AppendFormat("{0}", ConstantSingleFloatingPoint); } sb.Append(' '); } else if (IsCPURegister) { sb.AppendFormat(" {0}", Register); } if (full) { sb.AppendFormat(" [{0}]", Type.FullName); } else { if (Type.IsReferenceType) { sb.AppendFormat(" [O]"); } else { sb.AppendFormat(" [{0}]", ShortenTypeName(Type.FullName)); } } return(sb.ToString().Replace(" ", " ").Trim()); }
/// <summary> /// Returns a string representation of <see cref="Operand"/>. /// </summary> /// <returns>A string representation of the operand.</returns> public string ToString(bool full) { if (IsSSA) { string ssa = SSAParent.ToString(full); int pos = ssa.IndexOf(' '); if (pos < 0) { return(ssa + "<" + SSAVersion + ">"); } else { return(ssa.Substring(0, pos) + "<" + SSAVersion + ">" + ssa.Substring(pos)); } } var sb = new StringBuilder(); if (IsVirtualRegister) { sb.AppendFormat("V_{0}", Index); } else if (IsStackLocal && Name == null) { sb.AppendFormat("T_{0}", Index); } else if (IsParameter && Name == null) { sb.AppendFormat("P_{0}", Index); } if (Name != null) { sb.Append(Name); sb.Append(' '); } if (IsField) { sb.Append(' '); sb.Append(Field.FullName); } if (IsSplitChild) { sb.Append(' '); sb.Append("(" + SplitParent.ToString(full) + ")"); if (SplitParent.High == this) { sb.Append("/high"); } else { sb.Append("/low"); } } if (IsConstant) { sb.Append(" const {"); if (IsNull) { sb.Append("null"); } else if (IsUnsigned || IsBoolean || IsChar || IsPointer) { if (IsU8) { sb.AppendFormat("{0}", ConstantUnsignedLongInteger); } else { sb.AppendFormat("{0}", ConstantUnsignedInteger); } } else if (IsSigned) { if (IsI8) { sb.AppendFormat("{0}", ConstantSignedLongInteger); } else { sb.AppendFormat("{0}", ConstantSignedInteger); } } if (IsR8) { sb.AppendFormat("{0}", ConstantDoubleFloatingPoint); } else if (IsR4) { sb.AppendFormat("{0}", ConstantSingleFloatingPoint); } sb.Append('}'); } if (IsCPURegister) { sb.AppendFormat(" {0}", Register); } else if (IsMemoryAddress) { sb.Append(' '); if (OffsetBase != null) { if (Displacement > 0) { sb.AppendFormat("[{0}+{1:X}h]", OffsetBase.ToString(full), Displacement); } else { sb.AppendFormat("[{0}-{1:X}h]", OffsetBase.ToString(full), -Displacement); } } else if (Register != null) { if (Displacement > 0) { sb.AppendFormat("[{0}+{1:X}h]", Register.ToString(), Displacement); } else { sb.AppendFormat("[{0}-{1:X}h]", Register.ToString(), -Displacement); } } else if (IsField && IsSplitChild) { if (Displacement > 0) { sb.AppendFormat("+{0:X}h", Displacement); } else { sb.AppendFormat("-{0:X}h", -Displacement); } } } if (full) { sb.AppendFormat(" [{0}]", Type.FullName); } return(sb.ToString().Replace(" ", " ").Trim()); }