/// <summary> /// Write human readable output. /// </summary> public override void WriteTo(ITextOutput output, FormattingOptions format) { if (format.HasFlag(FormattingOptions.ShowHasSeqPoint) && SourceLocation != NoSource) { output.Write(SourceLocation.IsSpecial ? "!" : "~"); } if (Operand is AstVariable && ((AstVariable)Operand).IsGenerated) { if (Code == AstCode.Stloc && InferredType == null) { output.Write(((AstVariable)Operand).Name); output.Write(" = "); Arguments.First().WriteTo(output, format); return; } if (Code == AstCode.Ldloc) { output.Write(((AstVariable)Operand).Name); if (InferredType != null) { output.Write(':'); InferredType.WriteTo(output, AstNameSyntax.ShortTypeName); if ((ExpectedType != null) && (ExpectedType.FullName != this.InferredType.FullName)) { output.Write("[exp:"); ExpectedType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write(']'); } } return; } } if (Prefixes != null) { foreach (var prefix in Prefixes) { output.Write(prefix.Code.GetName()); output.Write(". "); } } output.Write(Code.GetName()); if (InferredType != null) { output.Write(':'); InferredType.WriteTo(output, AstNameSyntax.ShortTypeName); if ((ExpectedType != null) && (ExpectedType.FullName != InferredType.FullName)) { output.Write("[exp:"); ExpectedType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write(']'); } } else if (ExpectedType != null) { output.Write("[exp:"); ExpectedType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write(']'); } output.Write('('); var first = true; if (Operand != null) { if (Operand is AstLabel) { output.WriteReference(((AstLabel)Operand).Name, Operand); } else if (Operand is AstLabel[]) { var labels = (AstLabel[])Operand; for (var i = 0; i < labels.Length; i++) { if (i > 0) { output.Write(", "); } output.WriteReference(labels[i].Name, labels[i]); } } else if (Operand is AstLabelKeyPair[]) { var pairs = (AstLabelKeyPair[])Operand; for (var i = 0; i < pairs.Length; i++) { if (i > 0) { output.Write(", "); } output.Write("{0} -> ", pairs[i].Key); output.WriteReference(pairs[i].Label.Name, pairs[i].Label); } } else if (Operand is XMethodReference) { var method = (XMethodReference)Operand; if (method.DeclaringType != null) { method.DeclaringType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write("::"); } output.WriteReference(method.Name, method); } else if (Operand is XFieldReference) { var field = (XFieldReference)Operand; field.DeclaringType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write("::"); output.WriteReference(field.Name, field); } else { DisassemblerHelpers.WriteOperand(output, Operand); } first = false; } bool firstArg = true; foreach (var arg in Arguments) { if (!first) { output.Write(", "); } if ((format & FormattingOptions.BreakExpressions) != 0) { if (firstArg) { output.Indent(); } output.WriteLine(); } arg.WriteTo(output, format); first = false; firstArg = false; } output.Write(')'); if ((format & FormattingOptions.BreakExpressions) != 0 && !firstArg) { output.Unindent(); } }
/// <summary> /// Write human readable output. /// </summary> public override void WriteTo(ITextOutput output) { if (Operand is AstVariable && ((AstVariable)Operand).IsGenerated) { if (Code == AstCode.Stloc && InferredType == null) { output.Write(((AstVariable)Operand).Name); output.Write(" = "); Arguments.First().WriteTo(output); return; } if (Code == AstCode.Ldloc) { output.Write(((AstVariable)Operand).Name); if (InferredType != null) { output.Write(':'); InferredType.WriteTo(output, AstNameSyntax.ShortTypeName); if ((ExpectedType != null) && (ExpectedType.FullName != this.InferredType.FullName)) { output.Write("[exp:"); ExpectedType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write(']'); } } return; } } if (Prefixes != null) { foreach (var prefix in Prefixes) { output.Write(prefix.Code.GetName()); output.Write(". "); } } output.Write(Code.GetName()); if (InferredType != null) { output.Write(':'); InferredType.WriteTo(output, AstNameSyntax.ShortTypeName); if ((ExpectedType != null) && (ExpectedType.FullName != InferredType.FullName)) { output.Write("[exp:"); ExpectedType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write(']'); } } else if (ExpectedType != null) { output.Write("[exp:"); ExpectedType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write(']'); } output.Write('('); var first = true; if (Operand != null) { if (Operand is AstLabel) { output.WriteReference(((AstLabel)Operand).Name, Operand); } else if (Operand is AstLabel[]) { var labels = (AstLabel[])Operand; for (var i = 0; i < labels.Length; i++) { if (i > 0) { output.Write(", "); } output.WriteReference(labels[i].Name, labels[i]); } } else if (Operand is AstLabelKeyPair[]) { var pairs = (AstLabelKeyPair[])Operand; for (var i = 0; i < pairs.Length; i++) { if (i > 0) { output.Write(", "); } output.Write("{0} -> ", pairs[i].Key); output.WriteReference(pairs[i].Label.Name, pairs[i].Label); } } else if (Operand is XMethodReference) { var method = (XMethodReference)Operand; if (method.DeclaringType != null) { method.DeclaringType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write("::"); } output.WriteReference(method.Name, method); } else if (Operand is XFieldReference) { var field = (XFieldReference)Operand; field.DeclaringType.WriteTo(output, AstNameSyntax.ShortTypeName); output.Write("::"); output.WriteReference(field.Name, field); } else { DisassemblerHelpers.WriteOperand(output, Operand); } first = false; } foreach (var arg in Arguments) { if (!first) { output.Write(", "); } arg.WriteTo(output); first = false; } output.Write(')'); }