static void WriteLong(this ITextOutput output, InstructionVM instr) { output.WriteShort(instr); output.WriteSpace(); output.Write(instr.Code.ToOpCode().Name, TextTokenType.OpCode); output.WriteSpace(); Write(output, instr.InstructionOperandVM); }
static void Write(this ITextOutput output, IList <InstructionVM> instrs) { output.Write('[', TextTokenType.Operator); for (int i = 0; i < instrs.Count; i++) { if (i > 0) { output.Write(',', TextTokenType.Operator); output.WriteSpace(); } output.WriteShort(instrs[i]); } output.Write(']', TextTokenType.Operator); }
public static void WriteObject(ITextOutput output, object obj, WriteObjectFlags flags = WriteObjectFlags.None) { if (IsNull(obj)) { output.Write("null", TextTokenType.Keyword); return; } var mr = obj as IMemberRef; if (mr != null) { if (ILLanguage.Write(output, mr)) { return; } } var local = obj as LocalVM; if (local != null) { output.Write(IdentifierEscaper.Escape(GetLocalName(local.Name, local.Index)), TextTokenType.Local); output.WriteSpace(); output.WriteLocalParameterIndex(local.Index); return; } var parameter = obj as Parameter; if (parameter != null) { if (parameter.IsHiddenThisParameter) { output.Write("this", TextTokenType.Keyword); } else { output.Write(IdentifierEscaper.Escape(GetParameterName(parameter.Name, parameter.Index)), TextTokenType.Parameter); output.WriteSpace(); output.WriteLocalParameterIndex(parameter.Index); } return; } var instr = obj as InstructionVM; if (instr != null) { if ((flags & WriteObjectFlags.ShortInstruction) != 0) { output.WriteShort(instr); } else { output.WriteLong(instr); } return; } var instrs = obj as IList <InstructionVM>; if (instrs != null) { output.Write(instrs); return; } var methodSig = obj as MethodSig; if (methodSig != null) { output.Write(methodSig); return; } if (obj is TypeSig) { (obj as TypeSig).WriteTo(output); return; } if (obj is Code) { output.Write(((Code)obj).ToOpCode().Name, TextTokenType.OpCode); return; } // This code gets called by the combobox and it sometimes passes in the empty string. // It's never shown in the UI. Debug.Assert(string.Empty.Equals(obj), "Shouldn't be here"); output.Write(obj.ToString(), TextTokenType.Text); }