internal sealed override void BuildCILInfo(CILWriter output) { if (!type.isDef()) { type.BuildCILInfo(output); } }
internal override void WriteType(CILWriter output) { type.WriteType(output); output.Write(" "); parent.WriteName(output); output.Write("::" + name); }
internal void WriteCallConv(CILWriter output) { Contract.Requires(output != null); 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(" .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(); }
internal override void BuildCILInfo(CILWriter output) { if (!(exceptType is ClassDef)) { exceptType.BuildCILInfo(output); } }
internal sealed override void BuildCILInfo(CILWriter output) { if (!(elemType is ClassDef)) { elemType.BuildCILInfo(output); } }
internal override void BuildCILInfo(CILWriter output) { if (!special && scope != null) { output.AddRef(scope); } }
/// <summary> /// Write out a CIL text file for this PE file /// </summary> /// <param name="debug">include debug information</param> public void WriteCILFile(bool debug) { string cilFile = fileName.Substring(0, fileName.IndexOf('.')) + ".il"; CILWriter writer = new CILWriter(cilFile, debug, this); writer.BuildCILInfo(); writer.WriteFile(debug); }
internal void BuildCILInfo(CILWriter output) { Contract.Requires(output != null); if (!(type is ClassDef)) { type.BuildCILInfo(output); } }
internal override void BuildCILInfo(CILWriter output) { returnType.BuildCILInfo(output); for (int i = 0; i < numPars; i++) { parList[i].BuildCILInfo(output); } }
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 void BuildCILInfo(CILWriter output) { Contract.Requires(output != null); // FIXME Contract.Requires(handlers != null); foreach (HandlerBlock handler in handlers) { handler.BuildCILInfo(output); } }
internal override void WriteType(CILWriter output) { if (String.IsNullOrEmpty(NameSpace)) { output.Write("[" + scope.Name() + "]" + Name); } else { output.Write("[" + scope.Name() + "]" + NameSpace + "." + Name); } }
internal override void BuildCILInfo(CILWriter output) { foreach (Type conType in constraintTypes) { Class cClass = (Class)conType; if (!cClass.isDef()) { cClass.BuildCILInfo(output); } } }
internal void BuildCILInfo(CILWriter output) { Contract.Requires(output != null); if (!retType.isDef()) retType.BuildCILInfo(output); for (int i = 0; i < numPars; i++) { if (!parTypes[i].isDef()) parTypes[i].BuildCILInfo(output); } for (int i = 0; i < numOptPars; i++) { if (!optParTypes[i].isDef()) optParTypes[i].BuildCILInfo(output); } }
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 sealed override void BuildCILInfo(CILWriter output) { Type[] types = meth.GetParTypes(); if (types != null) { foreach (Type typ in types) { typ.BuildCILInfo(output); } } types = meth.GetOptParTypes(); if (types != null) { foreach (Type typ in types) { typ.BuildCILInfo(output); } } }
internal sealed override void BuildCILInfo(CILWriter output) { if (genericParams != null) { foreach (object gp in genericParams) { ((GenericParam)gp).BuildCILInfo(output); } } if (security != null) { foreach (object sec in security) { ((DeclSecurity)sec).BuildCILInfo(output); } } if (pinvokeImpl != null) { pinvokeImpl.BuildCILInfo(output); } if (locals != null) { foreach (Local lcl in locals) { lcl.BuildCILInfo(output); } } try { if (code != null) { code.BuildCILInfo(output); } } catch (InstructionException ex) { throw new Exception(ex.AddMethodName(name)); } sig.BuildCILInfo(output); }
internal void BuildCILInfo(CILWriter output) { Contract.Requires(output != null); if (!retType.isDef()) { retType.BuildCILInfo(output); } for (int i = 0; i < numPars; i++) { if (!parTypes[i].isDef()) { parTypes[i].BuildCILInfo(output); } } for (int i = 0; i < numOptPars; i++) { if (!optParTypes[i].isDef()) { optParTypes[i].BuildCILInfo(output); } } }
internal void WriteParTypes(CILWriter output) { Contract.Requires(output != null); 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 virtual void BuildCILInfo(CILWriter output) { Contract.Requires(output != null); }
private void WriteFlags(CILWriter output) { Contract.Requires(output != null); 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 virtual void Write(CILWriter output) { Contract.Requires(output != null); throw new NotYetImplementedException("Constant values for CIL"); }
internal override void Write(CILWriter output) { output.Write(GetInstrString()); theType.WriteName(output); output.WriteLine(); }
internal override void WriteName(CILWriter output) { if ((NameSpace == null) || (NameSpace == "")) { output.Write(Name); } else { output.Write(NameSpace + "." + Name); } }
internal override void BuildCILInfo(CILWriter output) { parent.BuildCILInfo(output); }
internal override void Write(CILWriter output) { output.WriteLine(".assembly " + name + " { }"); }
internal override void Write(CILWriter output) { throw new NotYetImplementedException("Write CIL for property"); }
internal void Write(CILWriter output) { Contract.Requires(output != null); throw new NotYetImplementedException("Native types for CIL"); }
internal override void BuildCILInfo(CILWriter output) { eventType.BuildCILInfo(output); }
internal virtual void Write(CILWriter output) { Contract.Requires(output != null); }
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) { throw new NotImplementedException("Switch instruction for CIL"); }
internal override void BuildCILInfo(CILWriter output) { if (signature == null) throw new InstructionException(IType.specialOp, instr); signature.BuildCILInfo(output); }
internal override sealed void BuildCILInfo(CILWriter output) { if (genericParams != null) { foreach (object gp in genericParams) { ((GenericParam)gp).BuildCILInfo(output); } } if (security != null) { foreach (object sec in security) { ((DeclSecurity)sec).BuildCILInfo(output); } } if (pinvokeImpl != null) pinvokeImpl.BuildCILInfo(output); if (locals != null) { foreach (Local lcl in locals) { lcl.BuildCILInfo(output); } } try { if (code != null) code.BuildCILInfo(output); } catch (InstructionException ex) { throw new Exception(ex.AddMethodName(name)); } sig.BuildCILInfo(output); }
internal override void BuildCILInfo(CILWriter output) { if (theType == null) throw new InstructionException(IType.typeOp, instr); if (!theType.isDef()) { theType.BuildCILInfo(output); } }
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 BuildCILInfo(CILWriter output) { if (!(exceptType is ClassDef)) exceptType.BuildCILInfo(output); }
internal override void Write(CILWriter output) { output.Write(".class "); WriteFlags(output); if (!string.IsNullOrEmpty(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 void Write(CILWriter output) { Contract.Requires(output != null); WriteCallConv(output); retType.WriteType(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(); }
internal override void BuildCILInfo(CILWriter output) { if ((superType != null) && !(superType is ClassDef)) { superType.BuildCILInfo(output); } for (int i = 0; i < genericParams.Count; i++) { ((GenericParam)genericParams[i]).BuildCILInfo(output); } if (security != null) { for (int i = 0; i < security.Count; i++) { ((DeclSecurity)security[i]).BuildCILInfo(output); } } // Console.WriteLine("Building CIL info for " + name); // Console.WriteLine("adding methods " + methods.Count); for (int i = 0; i < methods.Count; i++) { ((MethodDef)methods[i]).BuildCILInfo(output); } // Console.WriteLine("adding fields"); foreach (object field in fields) { ((FieldDef)field).BuildCILInfo(output); } // Console.WriteLine("adding interfaceimpls and methodimpls"); if (interfaces.Count > 0) { foreach (object iface in interfaces) { ((InterfaceImpl)iface).BuildCILInfo(output); } } if (methodImpls.Count > 0) { foreach (object methodImpl in methodImpls) { ((MethodImpl)methodImpl).BuildCILInfo(output); } } foreach (object evnt in events) { ((Event)evnt).BuildCILInfo(output); } for (int i = 0; i < properties.Count; i++) { ((Property)properties[i]).BuildCILInfo(output); } // Console.WriteLine("Adding nested classes"); foreach (object nestedClass in nestedClasses) { ((ClassDef)nestedClass).BuildCILInfo(output); } // Console.WriteLine("End of building tables"); }
internal virtual void WriteName(CILWriter output) { Contract.Requires(output != null); WriteType(output); }
internal void WriteParTypes(CILWriter output) { Contract.Requires(output != null); 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) { 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 Write(CILWriter output) { output.WriteLine("ldstr \"" + val + "\""); }
internal void Write(CILWriter output) { Contract.Requires(output != null); type.WriteType(output); output.Write("\t" + Name); }
internal override sealed void BuildCILInfo(CILWriter output) { if (!type.isDef()) type.BuildCILInfo(output); }
internal override void BuildCILInfo(CILWriter output) { if (meth == null) throw new InstructionException(IType.methOp, instr); if ((meth is MethodRef) || (meth is MethodSpec)) meth.BuildCILInfo(output); }