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