internal override void Write(CILWriter output) { output.Write(".class "); WriteFlags(output); if ((nameSpace != null) && (nameSpace != "")) { output.Write(nameSpace + "."); } output.WriteLine(name); if (superType != null) { output.Write(" extends "); superType.WriteName(output); } if (interfaces.Count > 0) { output.Write(" implements "); for (int i=0; i < interfaces.Count; i++) { InterfaceImpl impl = (InterfaceImpl)interfaces[i]; if (i > 0) output.Write(", "); impl.TheInterface().WriteName(output); } } output.WriteLine(); output.WriteLine("{"); for (int i=0; i < fields.Count; i++) { ((Field)fields[i]).Write(output); output.WriteLine(); } for (int i=0; i < methods.Count; i++) { ((MethodDef)methods[i]).Write(output); output.WriteLine(); } for (int i=0; i < methodImpls.Count; i++) { ((MethodImpl)methodImpls[i]).Write(output); output.WriteLine(); } for (int i=0; i < events.Count; i++) { ((Event)events[i]).Write(output); output.WriteLine(); } for (int i=0; i < properties.Count; i++) { ((Property)properties[i]).Write(output); output.WriteLine(); } output.WriteLine("}"); output.WriteLine(); }
internal override void WriteName(CILWriter output) { if ((nameSpace == null) || (nameSpace == "")) { output.Write(name); } else { output.Write(nameSpace + "." + name); } }
internal override void WriteType(CILWriter output) { elemType.WriteType(output); output.Write("[]"); }
internal void Write(CILWriter output) { for (int i=0; i < tide; i++) { if (!(buffer[i] is CILLabel)) { output.Write(" "); } output.Write(" "); buffer[i].Write(output); } if (exceptions != null) { throw new NotYetImplementedException("Exceptions not yet implemented for CIL Instructions"); // Console.WriteLine("Writing exceptions"); // Console.WriteLine("header = " + Hex.Short(exceptHeader) + " exceptSize = " + Hex.Int(exceptSize)); //output.Write(exceptHeader); //output.Write3Bytes((uint)exceptSize); //for (int i = 0; i < exceptions.Count; i++) { // TryBlock tryBlock = (TryBlock)exceptions[i]; // tryBlock.Write(output, fatExceptionFormat); //} } }
internal override void Write(CILWriter output) { output.Write(" .field "); if (hasOffset) { output.Write("[ {0} ] ", offset); } WriteFlags(output, flags); if (marshalType != null) { output.Write("marshal "); marshalType.Write(output); } type.WriteType(output); output.Write(" " + name); if (initVal != null) { initVal.Write(output); } else if (constVal != null) { constVal.Write(output); } output.WriteLine(); }
protected void WriteFlags(CILWriter output, uint flags) { uint vis = (flags & 0x07); // visibility mask switch (vis) { case 0 : output.Write("compilercontrolled "); break; case 1 : output.Write("private "); break; case 2 : output.Write("famandassem "); break; case 3 : output.Write("assembly "); break; case 4 : output.Write("family "); break; case 5 : output.Write("famorassem "); break; case 6 : output.Write("public "); break; } if ((flags & (ushort)FieldAttr.Static) != 0) { output.Write("static "); } if ((flags & (ushort)FieldAttr.Initonly) != 0) { if (this is MethodDef) { output.Write("final "); } else { output.Write("initonly "); } } if ((flags & (ushort)FieldAttr.Literal) != 0) { if (this is MethodDef) { output.Write("virtual "); } else { output.Write("literal "); } } if ((flags & (ushort)FieldAttr.Notserialized) != 0) { if (this is MethodDef) { output.Write("hidebysig "); } else { output.Write("notserialized "); } } if (this is MethodDef) { // more flags required here if ((flags & (ushort)MethAttr.Abstract) != 0) { output.Write("abstract "); } if ((flags & (ushort)MethAttr.SpecialName) != 0) { output.Write("specialname "); } if ((flags & (ushort)MethAttr.RTSpecialName) != 0) { output.Write("rtspecialname "); } } else { // more flags required here if ((flags & (ushort)FieldAttr.SpecialName) != 0) { output.Write("specialname "); } if ((flags & (ushort)FieldAttr.RTSpecialName) != 0) { output.Write("rtsspecialname "); } } }
internal override void WriteType(CILWriter output) { //if (typeIndex == 0x0E) { // output.Write("[mscorlib]System.String"); //} else switch (typeIndex) { case (0x1C) : output.Write("[mscorlib]System.Object"); break; case (0x02) : output.Write("bool"); break; case (0x0C) : output.Write("float32"); break; case (0x0D) : output.Write("float64"); break; default : output.Write(name.ToLower()); break; } }
internal override void WriteType(CILWriter output) { if ((nameSpace == null) || (nameSpace == "")) { output.Write("[" + scope.Name() +"]" + name); } else { output.Write("[" + scope.Name() +"]" + nameSpace + "." + name); } }
internal void WriteParTypes(CILWriter output) { output.Write("("); for (int i=0; i < numPars; i++) { parTypes[i].WriteType(output); if ((i < numPars-1) || (numOptPars > 0)) output.Write(", "); } for (int i=0; i < numOptPars; i++) { optParTypes[i].WriteType(output); if (i < numPars-1) output.Write(", "); } output.Write(")"); }
internal override void Write(CILWriter output) { pType.WriteType(output); output.Write(" " + pName); }
internal void WriteCallConv(CILWriter output) { if ((callConv & CallConv.Instance) != 0) { output.Write("instance "); if ((callConv & CallConv.InstanceExplicit) == CallConv.InstanceExplicit) { output.Write("explicit "); } } uint callKind = (uint)callConv & 0x07; switch (callKind) { case 0 : break; case 1 : output.Write("unmanaged cdecl "); break; case 2 : output.Write("unmanaged stdcall "); break; case 3 : output.Write("unmanaged thiscall "); break; case 4 : output.Write("unmanaged fastcall "); break; case 5 : output.Write("vararg "); break; } }
internal override void Write(CILWriter output) { output.Write(" .method "); WriteFlags(output, methFlags); sig.Write(output); output.Write(" " + name + "("); if (parList != null) { for (int i=0; i < parList.Length; i++) { parList[i].Write(output); if (i < parList.Length-1) { output.Write(", "); } } } output.Write(") "); uint codeType = implFlags & (uint)0x11; if (codeType == 0) { output.Write("cil "); } else if (codeType == 1) { output.Write("native "); } else if (codeType == 3) { output.Write("runtime "); } if ((implFlags & (uint)ImplAttr.Unmanaged) == 0) { output.Write("managed "); } else { output.Write("unmanaged "); } if ((implFlags & (uint)ImplAttr.ForwardRef) != 0) { output.Write("forwardref "); } if ((implFlags & (uint)ImplAttr.InternalCall) != 0) { output.Write("internalcall "); } if ((implFlags & (uint)ImplAttr.Synchronized) != 0) { output.Write("synchronized "); } if ((implFlags & (uint)ImplAttr.NoInLining) != 0) { output.Write("noinlining "); } output.WriteLine(" {"); if ((locals != null) && (locals.Length > 0)) { output.Write(" .locals ("); for (int i=0; i < locals.Length; i++) { if (i > 0) { output.Write(" "); } locals[i].Write(output); if (i < locals.Length-1) { output.WriteLine(","); } } output.WriteLine(" )"); } if (entryPoint) { output.WriteLine(" .entrypoint"); } if (code != null) code.Write(output); output.WriteLine(" }"); }
internal override void WriteType(CILWriter output) { sig.WriteCallConv(output); sig.retType.WriteType(output); output.Write(" "); parent.WriteName(output); output.Write("::" + name); sig.WriteParTypes(output); }
internal override void WriteType(CILWriter output) { output.Write("class "); WriteName(output); }
internal override void Write(CILWriter output) { output.Write(GetInstrString()); signature.Write(output); output.WriteLine(); }
private void WriteFlags(CILWriter output) { uint vis = flags & VisibilityMask; switch (vis) { case 0 : output.Write("private "); break; case 1 : output.Write("public "); break; case 2 : output.Write("nested public "); break; case 3 : output.Write("nested private "); break; case 4 : output.Write("nested family "); break; case 5 : output.Write("nested assembly "); break; case 6 : output.Write("nested famandassem "); break; case 7 : output.Write("nested famorassem "); break; } uint layout = flags & LayoutMask; if (layout == 0) { output.Write("auto "); } else if (layout == (uint)TypeAttr.ExplicitLayout) { output.Write("explicit "); } else { output.Write("sequential "); } if ((flags & (uint)TypeAttr.Interface) != 0) { output.Write("interface "); } if ((flags & (uint)TypeAttr.Abstract) != 0) { output.Write("abstract "); } else if ((flags & (uint)TypeAttr.Sealed) != 0) { output.Write("sealed "); } uint strForm = flags & StringFormatMask; if (strForm == 0) { output.Write("ansi "); } else if (strForm == (uint)TypeAttr.UnicodeClass) { output.Write("unicode "); } else { output.Write("autochar "); } if ((flags & (uint)TypeAttr.BeforeFieldInit) != 0) { output.Write("beforefieldinit "); } if ((flags & (uint)TypeAttr.Serializable) != 0) { output.Write("serializable "); } if ((flags & (uint)TypeAttr.SpecialName) != 0) { output.Write("specialname "); } if ((flags & (uint)TypeAttr.RTSpecialName) != 0) { output.Write("rtsspecialname "); } }
internal override void Write(CILWriter output) { output.Write(GetInstrString()); theType.WriteName(output); output.WriteLine(); }
internal override void WriteType(CILWriter output) { type.WriteType(output); output.Write(" "); parent.WriteName(output); output.Write("::" + name); }
internal override void Write(CILWriter output) { if (twoByteInstr) { output.Write(FEopcode[instr]); } else { output.Write(opcode[instr]); } output.WriteLine(" " + val); }
internal override void Write(CILWriter output) { output.Write(GetInstrString()); field.WriteType(output); output.WriteLine(); }
internal void Write(CILWriter output) { type.WriteType(output); output.Write("\t" + name); }