Esempio n. 1
0
 internal sealed override void BuildCILInfo(CILWriter output)
 {
     if (!type.isDef())
     {
         type.BuildCILInfo(output);
     }
 }
Esempio n. 2
0
 internal override void WriteType(CILWriter output)
 {
     type.WriteType(output);
     output.Write(" ");
     parent.WriteName(output);
     output.Write("::" + name);
 }
Esempio n. 3
0
        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;
            }
        }
Esempio n. 4
0
 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();
 }
Esempio n. 5
0
 internal override void BuildCILInfo(CILWriter output)
 {
     if (!(exceptType is ClassDef))
     {
         exceptType.BuildCILInfo(output);
     }
 }
Esempio n. 6
0
 internal sealed override void BuildCILInfo(CILWriter output)
 {
     if (!(elemType is ClassDef))
     {
         elemType.BuildCILInfo(output);
     }
 }
Esempio n. 7
0
 internal override void BuildCILInfo(CILWriter output)
 {
     if (!special && scope != null)
     {
         output.AddRef(scope);
     }
 }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
 internal void BuildCILInfo(CILWriter output)
 {
     Contract.Requires(output != null);
     if (!(type is ClassDef))
     {
         type.BuildCILInfo(output);
     }
 }
Esempio n. 10
0
 internal override void BuildCILInfo(CILWriter output)
 {
     returnType.BuildCILInfo(output);
     for (int i = 0; i < numPars; i++)
     {
         parList[i].BuildCILInfo(output);
     }
 }
Esempio n. 11
0
 internal override void WriteType(CILWriter output)
 {
     sig.WriteCallConv(output);
     sig.retType.WriteType(output);
     output.Write(" ");
     parent.WriteName(output);
     output.Write("::" + name);
     sig.WriteParTypes(output);
 }
Esempio n. 12
0
 internal void BuildCILInfo(CILWriter output)
 {
     Contract.Requires(output != null);
     // FIXME Contract.Requires(handlers != null);
     foreach (HandlerBlock handler in handlers)
     {
         handler.BuildCILInfo(output);
     }
 }
Esempio n. 13
0
 internal override void WriteType(CILWriter output)
 {
     if (String.IsNullOrEmpty(NameSpace))
     {
         output.Write("[" + scope.Name() + "]" + Name);
     }
     else
     {
         output.Write("[" + scope.Name() + "]" + NameSpace + "." + Name);
     }
 }
Esempio n. 14
0
 internal override void BuildCILInfo(CILWriter output)
 {
     foreach (Type conType in constraintTypes)
     {
         Class cClass = (Class)conType;
         if (!cClass.isDef())
         {
             cClass.BuildCILInfo(output);
         }
     }
 }
Esempio n. 15
0
 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);
     }
 }
Esempio n. 16
0
        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;
            }
        }
Esempio n. 17
0
 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);
         }
     }
 }
Esempio n. 18
0
 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);
 }
Esempio n. 19
0
 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);
         }
     }
 }
Esempio n. 20
0
 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(")");
 }
Esempio n. 21
0
 internal virtual void BuildCILInfo(CILWriter output)
 {
     Contract.Requires(output != null);
 }
Esempio n. 22
0
 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 ");
     }
 }
Esempio n. 23
0
 internal virtual void Write(CILWriter output)
 {
     Contract.Requires(output != null);
     throw new NotYetImplementedException("Constant values for CIL");
 }
Esempio n. 24
0
 internal override void Write(CILWriter output)
 {
     output.Write(GetInstrString());
       theType.WriteName(output);
       output.WriteLine();
 }
Esempio n. 25
0
 internal override void WriteName(CILWriter output)
 {
     if ((NameSpace == null) || (NameSpace == ""))
     {
         output.Write(Name);
     }
     else
     {
         output.Write(NameSpace + "." + Name);
     }
 }
Esempio n. 26
0
 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();
 }
Esempio n. 27
0
 internal override void BuildCILInfo(CILWriter output)
 {
     parent.BuildCILInfo(output);
 }
Esempio n. 28
0
 internal override void Write(CILWriter output)
 {
     output.WriteLine(".assembly " + name + " { }");
 }
Esempio n. 29
0
 internal override void Write(CILWriter output)
 {
     throw new NotYetImplementedException("Write CIL for property");
 }
Esempio n. 30
0
 internal void Write(CILWriter output)
 {
     Contract.Requires(output != null);
     throw new NotYetImplementedException("Native types for CIL");
 }
Esempio n. 31
0
 internal override void BuildCILInfo(CILWriter output)
 {
     eventType.BuildCILInfo(output);
 }
Esempio n. 32
0
 internal void Write(CILWriter output)
 {
     Contract.Requires(output != null);
     throw new NotYetImplementedException("Native types for CIL");
 }
Esempio n. 33
0
 internal virtual void Write(CILWriter output)
 {
     Contract.Requires(output != null);
 }
Esempio n. 34
0
 internal override void Write(CILWriter output)
 {
     if (twoByteInstr) {
     output.Write(FEopcode[instr]);
       }
       else {
     output.Write(opcode[instr]);
       }
       output.WriteLine(" " + val);
 }
Esempio n. 35
0
 internal override void Write(CILWriter output)
 {
     throw new NotImplementedException("Switch instruction for CIL");
 }
Esempio n. 36
0
 internal virtual void BuildCILInfo(CILWriter output)
 {
     Contract.Requires(output != null);
 }
Esempio n. 37
0
 internal override void BuildCILInfo(CILWriter output)
 {
     if (signature == null) throw new InstructionException(IType.specialOp, instr);
       signature.BuildCILInfo(output);
 }
Esempio n. 38
0
 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);
 }
Esempio n. 39
0
 internal override void WriteType(CILWriter output)
 {
     type.WriteType(output);
     output.Write(" ");
     parent.WriteName(output);
     output.Write("::" + name);
 }
Esempio n. 40
0
 internal override void Write(CILWriter output)
 {
     output.WriteLine(".assembly " + name + " { }");
 }
Esempio n. 41
0
 internal override void WriteType(CILWriter output)
 {
     sig.WriteCallConv(output);
     sig.retType.WriteType(output);
     output.Write(" ");
     parent.WriteName(output);
     output.Write("::" + name);
     sig.WriteParTypes(output);
 }
Esempio n. 42
0
 internal override void BuildCILInfo(CILWriter output)
 {
     if (theType == null) throw new InstructionException(IType.typeOp, instr);
       if (!theType.isDef()) {
     theType.BuildCILInfo(output);
       }
 }
Esempio n. 43
0
 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("  }");
 }
Esempio n. 44
0
 internal override void BuildCILInfo(CILWriter output)
 {
     if (!(exceptType is ClassDef)) exceptType.BuildCILInfo(output);
 }
Esempio n. 45
0
        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();
        }
Esempio n. 46
0
 internal void Write(CILWriter output)
 {
     Contract.Requires(output != null);
     WriteCallConv(output);
     retType.WriteType(output);
 }
Esempio n. 47
0
 internal override void WriteType(CILWriter output)
 {
     output.Write("class ");
     WriteName(output);
 }
Esempio n. 48
0
 internal override void Write(CILWriter output)
 {
     output.Write(GetInstrString());
       signature.Write(output);
       output.WriteLine();
 }
Esempio n. 49
0
 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");
 }
Esempio n. 50
0
 internal void Write(CILWriter output)
 {
     Contract.Requires(output != null);
     WriteCallConv(output);
     retType.WriteType(output);
 }
Esempio n. 51
0
 internal virtual void WriteName(CILWriter output)
 {
     Contract.Requires(output != null);
     WriteType(output);
 }
Esempio n. 52
0
 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(")");
 }
Esempio n. 53
0
        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("  }");
        }
Esempio n. 54
0
 internal override void Write(CILWriter output)
 {
     output.WriteLine("ldstr \"" + val + "\"");
 }
Esempio n. 55
0
 internal void Write(CILWriter output)
 {
     Contract.Requires(output != null);
     type.WriteType(output);
     output.Write("\t" + Name);
 }
Esempio n. 56
0
 internal override void BuildCILInfo(CILWriter output)
 {
     parent.BuildCILInfo(output);
 }
Esempio n. 57
0
 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;
     }
 }
Esempio n. 58
0
 internal override sealed void BuildCILInfo(CILWriter output)
 {
     if (!type.isDef()) type.BuildCILInfo(output);
 }
Esempio n. 59
0
 internal void BuildCILInfo(CILWriter output)
 {
     Contract.Requires(output != null);
     // FIXME Contract.Requires(handlers != null);
     foreach (HandlerBlock handler in handlers)
     {
         handler.BuildCILInfo(output);
     }
 }
Esempio n. 60
0
 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);
 }