Esempio n. 1
0
        /*-------------------- Constructors ---------------------------------*/

        internal FieldMarshal(MetaDataElement field, NativeType nType)
        {
            Contract.Requires(field != null);
            this.field = field;
            this.nt = nType;
            tabIx = MDTable.FieldMarshal;
        }
Esempio n. 2
0
        /*-------------------- Constructors ---------------------------------*/

        internal FieldMarshal(MetaDataElement field, NativeType nType)
        {
            Contract.Requires(field != null);
            this.field = field;
            this.nt    = nType;
            tabIx      = MDTable.FieldMarshal;
        }
Esempio n. 3
0
 internal GenericParam(PEReader buff)
     : base(VAR)
 {
     Contract.Requires(buff != null);
     index    = buff.ReadUInt16();
     flags    = buff.ReadUInt16();
     parentIx = buff.GetCodedIndex(CIx.TypeOrMethodDef);
     name     = buff.GetString();
     if (extraField)
     {
         kind = buff.ReadUInt16();
     }
     tabIx = MDTable.GenericParam;
     // resolve generic param immediately for signature resolution
     parent = buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx);
     if (parent != null)
     {
         if (parent is MethodDef)
         {
             typeIndex = MVAR;
             ((MethodDef)parent).AddGenericParam(this);
         }
         else
         {
             ((ClassDef)parent).AddGenericParam(this);
         }
     }
 }
Esempio n. 4
0
 /*-------------------- Constructors ---------------------------------*/
 internal DeclSecurity(MetaDataElement paren, SecurityAction act, byte[] perSet)
 {
     Contract.Requires(perSet != null);
     parent = paren;
     action = act;
     permissionSet = perSet;
     tabIx = MDTable.DeclSecurity;
 }
Esempio n. 5
0
        /*-------------------- Constructors ---------------------------------*/

        internal ExternClass(TypeAttr attr, string ns, string name, MetaDataElement paren)
        {
            flags          = (uint)attr;
            NameSpace      = ns;
            this.Name      = name;
            implementation = paren;
            tabIx          = MDTable.ExportedType;
        }
Esempio n. 6
0
 /*-------------------- Constructors ---------------------------------*/
 internal ExternClass(TypeAttr attr, string ns, string name, MetaDataElement paren)
 {
     flags = (uint)attr;
     NameSpace = ns;
     this.Name = name;
     implementation = paren;
     tabIx = MDTable.ExportedType;
 }
Esempio n. 7
0
 internal override void Resolve(PEReader buff)
 {
     implementation = buff.GetCodedElement(CIx.Implementation, implIx);
     while (implementation is ExternClass)
     {
         implementation = ((ExternClass)implementation).implementation;
     }
     ((ModuleFile)implementation).fileModule.AddExternClass(this);
 }
Esempio n. 8
0
 internal void CheckParent(MethodDef paren, PEReader buff)
 {
     Contract.Requires(buff != null);
     if (paren == buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx))
     {
         parent = paren;
         paren.InsertGenericParam(this);
     }
 }
Esempio n. 9
0
        internal void ConditionalAddTypeSpec(MetaDataElement elem)
        {
            ArrayList table = GetTable(MDTable.TypeSpec);

            if (!table.Contains(elem))
            {
                elem.Row = (uint)table.Count + 1;
                table.Add(elem);
            }
        }
Esempio n. 10
0
        /*-------------------- Constructors ---------------------------------*/

        internal CustomAttribute(MetaDataElement paren, Method constrType,
                                 Constant[] val)
        {
            Contract.Requires(constrType != null);
            parent  = paren;
            type    = constrType;
            argVals = val;
            changed = true;
            tabIx   = MDTable.CustomAttribute;
        }
Esempio n. 11
0
        /*-------------------- Constructors ---------------------------------*/

        internal CustomAttribute(MetaDataElement paren, Method constrType,
            Constant[] val)
        {
            Contract.Requires(constrType != null);
            parent = paren;
            type = constrType;
            argVals = val;
            changed = true;
            tabIx = MDTable.CustomAttribute;
        }
Esempio n. 12
0
 private static Type SubstituteType(Type origType, MetaDataElement paren, Type[] genTypes)
 {
     Contract.Requires(origType != null);
     Contract.Requires(paren != null);
     Contract.Requires(genTypes != null);
     if ((origType is GenericParam) && (((GenericParam)origType).GetParent() == paren))
     {
         return(genTypes[((GenericParam)origType).Index]);
     }
     return(origType);
 }
Esempio n. 13
0
        internal override Member ResolveParent(PEReader buff)
        {
            if (parent != null)
            {
                return(this);
            }
            buff.currentMethodScope = this;
            MetaDataElement paren = buff.GetCodedElement(CIx.MemberRefParent, parentIx);

            buff.currentMethodScope = null;
            if (paren is MethodDef)
            {
                parent       = null;
                varArgParent = (MethodDef)paren;
                //this.sig = buff.ReadMethSig(this,name,sigIx);
                ((MethodDef)paren).AddVarArgSig(this);
                return(this);
            }
            else if (paren is ClassSpec)
            {
                ((ClassSpec)paren).AddMethod(this);
                return(this);
            }
            else if (paren is PrimitiveType)
            {
                paren = MSCorLib.mscorlib.GetDefaultClass();
            }
            else if (paren is ClassDef)
            {
                this.sig = buff.ReadMethSig(this, name, sigIx);
                return(((ClassDef)paren).GetMethod(this.sig));
            }
            else if (paren is TypeSpec)
            {
                paren = new ConstructedTypeSpec((TypeSpec)paren);
                //Console.WriteLine("Got TypeSpec as parent of Member");
                //return this;
                //throw new Exception("Got TypeSpec as parent of Member");
                //((TypeSpec)paren).AddMethod(buff,this);
            }
            if (paren is ReferenceScope)
            {
                parent = ((ReferenceScope)paren).GetDefaultClass();
            }
            parent = (Class)paren;
            //if ((MethodRef)parent.GetMethodDesc(name) != null) throw new PEFileException("Existing method!!");
            //sig = buff.ReadMethSig(this,name,sigIx);
            //MethodRef existing = (MethodRef)parent.GetMethod(sig);
            //if (existing != null)
            //  return existing;
            parent.AddToMethodList(this);
            return(this);
        }
Esempio n. 14
0
 internal static DeclSecurity FindSecurity(PEReader buff, MetaDataElement paren, uint codedParIx)
 {
     buff.SetElementPosition(MDTable.DeclSecurity, 0);
     for (int i = 0; i < buff.GetTableSize(MDTable.DeclSecurity); i++)
     {
         uint act = buff.ReadUInt16();
         if (buff.GetCodedIndex(CIx.HasDeclSecurity) == codedParIx)
             return new DeclSecurity(paren, (SecurityAction)act, buff.GetBlob());
         uint junk = buff.GetBlobIx();
     }
     return null;
 }
Esempio n. 15
0
 internal sealed override void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.ExportedType, this);
     nameSpaceIx = md.AddToStringsHeap(NameSpace);
     nameIx      = md.AddToStringsHeap(Name);
     if (implementation is ModuleRef)
     {
         ModuleFile mFile = ((ModuleRef)implementation).modFile;
         mFile.BuildMDTables(md);
         implementation = mFile;
     }
 }
Esempio n. 16
0
 internal override void Resolve(PEReader buff)
 {
     field = buff.GetCodedElement(CIx.HasFieldMarshal, parentIx);
     nt    = buff.GetBlobNativeType(ntIx);
     if (field is FieldDef)
     {
         ((FieldDef)field).SetMarshalType(nt);
     }
     else
     {
         ((Param)field).SetMarshalType(nt);
     }
 }
Esempio n. 17
0
 private static Type[] ReplaceGenPars([CanBeNull] Type[] typeList, MetaDataElement paren, Type[] genTypes)
 {
     if (typeList == null)
     {
         return(null);
     }
     Type[] newList = new Type[typeList.Length];
     for (int i = 0; i < typeList.Length; i++)
     {
         newList[i] = SubstituteType(typeList[i], paren, genTypes);
     }
     return(newList);
 }
Esempio n. 18
0
 internal GenericParam(string name, MetaDataElement parent, int index)
     : base(VAR)
 {
     Contract.Requires(name != null);
     Contract.Requires(parent != null);
     this.name   = name;
     this.parent = parent;
     this.index  = (ushort)index;
     if (parent is Method)
     {
         typeIndex = MVAR;
     }
     tabIx = MDTable.GenericParam;
 }
Esempio n. 19
0
        internal void AddToTable(MDTable tableIx, MetaDataElement elem)
        {
            // Console.WriteLine("Adding element to table " + (uint)tableIx);

            ArrayList table = GetTable(tableIx);

            if (table.Contains(elem))
            {
                Console.Out.WriteLine("ERROR - element already in table " + tableIx);
                return;
            }
            elem.Row = (uint)table.Count + 1;
            table.Add(elem);
        }
Esempio n. 20
0
        internal void WriteCodedIndex(CIx code, MetaDataElement elem, PEWriter output)
        {
            uint ix = 0;

            if (elem != null)
            {
                ix = (elem.Row << CIxShiftMap[(uint)code]) | elem.GetCodedIx(code);
                // Console.WriteLine("coded index = " + ix + " row = " + elem.Row);
                //} else {
                // Console.WriteLine("elem for coded index is null");
            }
            if (lgeCIx[(uint)code])
            {
                output.Write(ix);
            }
            else
            {
                output.Write((ushort)ix);
            }
        }
Esempio n. 21
0
        internal virtual void ResolveParent(PEReader buff, bool isExtern)
        {
            CIx cIx = CIx.ResolutionScope;

            if (isExtern)
            {
                cIx = CIx.Implementation;
            }
            if (scope != null)
            {
                return;
            }
            MetaDataElement parentScope = buff.GetCodedElement(cIx, resScopeIx);

            if (parentScope is Module)
            {  // special code for glitch in Everett ilasm
                ClassDef newDef = new ClassDef((PEFile)parentScope, 0, NameSpace, Name);
                ((Module)parentScope).AddToClassList(newDef);
                buff.InsertInTable(MDTable.TypeRef, Row, newDef);
            }
            else
            {
                scope = (ReferenceScope)buff.GetCodedElement(cIx, resScopeIx);
                ClassRef existing = (ClassRef)scope.GetExistingClass(NameSpace, Name);
                if (existing == null)
                {
                    scope.AddToClassList(this);
                }
                else
                {
                    if (isExtern)
                    {
                        buff.InsertInTable(MDTable.ExportedType, Row, existing);
                    }
                    else
                    {
                        buff.InsertInTable(MDTable.TypeRef, Row, existing);
                    }
                }
            }
        }
Esempio n. 22
0
        internal override Member ResolveParent(PEReader buff)
        {
            if (parent != null)
            {
                return(this);
            }
            MetaDataElement paren = buff.GetCodedElement(CIx.MemberRefParent, parentIx);

            //Console.WriteLine("parentIx = " + parentIx);
            //Console.WriteLine("paren = " + paren);
            if (paren is ClassDef)
            {
                return(((ClassDef)paren).GetField(this.name));
            }
            //if (paren is ClassSpec)
            // paren = ((ClassSpec)paren).GetParent();
            if (paren is ReferenceScope)
            {
                parent = ((ReferenceScope)paren).GetDefaultClass();
            }
            if (paren is TypeSpec)
            {
                parent = new ConstructedTypeSpec((TypeSpec)paren);
            }
            else
            {
                parent = (Class)paren;
            }
            if (parent != null)
            {
                Field existing = (Field)((Class)parent).GetFieldDesc(name);
                if (existing != null)
                {
                    return(existing);
                }
            }
            parent.AddToFieldList(this);
            return(this);
        }
Esempio n. 23
0
 internal void SetClassParam(Class paren, int ix)
 {
     typeIndex = VAR;
     parent    = paren;
     index     = (ushort)ix;
 }
Esempio n. 24
0
 internal override void Resolve(PEReader buff)
 {
     field = buff.GetCodedElement(CIx.HasFieldMarshal, parentIx);
     nt = buff.GetBlobNativeType(ntIx);
     if (field is FieldDef)
     {
         ((FieldDef)field).SetMarshalType(nt);
     }
     else
     {
         ((Param)field).SetMarshalType(nt);
     }
 }
Esempio n. 25
0
 internal void WriteCodedIndex(CIx code, MetaDataElement elem, PEWriter output)
 {
     uint ix = 0;
     if (elem != null)
     {
         ix = (elem.Row << CIxShiftMap[(uint)code]) | elem.GetCodedIx(code);
         // Console.WriteLine("coded index = " + ix + " row = " + elem.Row);
         //} else {
         // Console.WriteLine("elem for coded index is null");
     }
     if (lgeCIx[(uint)code])
         output.Write(ix);
     else
         output.Write((ushort)ix);
 }
Esempio n. 26
0
 internal void ConditionalAddTypeSpec(MetaDataElement elem)
 {
     ArrayList table = GetTable(MDTable.TypeSpec);
       if (!table.Contains(elem)) {
     elem.Row = (uint)table.Count + 1;
     table.Add(elem);
       }
 }
Esempio n. 27
0
 internal CustomAttribute(MetaDataElement paren, Method constrType,
                          byte[] val)
Esempio n. 28
0
 internal void ResolveType(MetaData md)
 {
     exceptType = ((Type)exceptType).GetTypeSpec(md);
 }
Esempio n. 29
0
 internal void DescriptorError(MetaDataElement elem)
 {
     Contract.Requires(elem != null);
     throw new DescriptorException(elem.NameString());
 }
Esempio n. 30
0
 internal override void Resolve(PEReader buff)
 {
     parent = buff.GetCodedElement(CIx.HasDeclSecurity, parentIx);
     if (parent != null)
     {
         if (parent is ClassDef) ((ClassDef)parent).AddSecurity(this);
         if (parent is Assembly) ((Assembly)parent).AddSecurity(this);
         if (parent is MethodDef) ((MethodDef)parent).AddSecurity(this);
     }
 }
Esempio n. 31
0
 internal void SetMethParam(Method paren, int ix)
 {
     typeIndex = MVAR;
     parent = paren;
     index = (ushort)ix;
 }
Esempio n. 32
0
 /*-------------------- Constructors ---------------------------------*/
 internal ConstantElem(MetaDataElement parent, Constant val)
 {
     Contract.Requires(val != null);
     this.parent = parent;
     cValue = val;
     tabIx = MDTable.Constant;
 }
Esempio n. 33
0
 internal void SetClassParam(Class paren, int ix)
 {
     typeIndex = VAR;
     parent = paren;
     index = (ushort)ix;
 }
Esempio n. 34
0
 internal void CheckParent(MethodDef paren, PEReader buff)
 {
     Contract.Requires(buff != null);
     if (paren == buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx))
     {
         parent = paren;
         paren.InsertGenericParam(this);
     }
 }
Esempio n. 35
0
 internal GenericParam(PEReader buff)
     : base(VAR)
 {
     Contract.Requires(buff != null);
     index = buff.ReadUInt16();
     flags = buff.ReadUInt16();
     parentIx = buff.GetCodedIndex(CIx.TypeOrMethodDef);
     name = buff.GetString();
     if (extraField) kind = buff.ReadUInt16();
     tabIx = MDTable.GenericParam;
     // resolve generic param immediately for signature resolution
     parent = buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx);
     if (parent != null)
     {
         if (parent is MethodDef)
         {
             typeIndex = MVAR;
             ((MethodDef)parent).AddGenericParam(this);
         }
         else
         {
             ((ClassDef)parent).AddGenericParam(this);
         }
     }
 }
Esempio n. 36
0
 private static Type[] ReplaceGenPars([CanBeNull] Type[] typeList, MetaDataElement paren, Type[] genTypes)
 {
     if (typeList == null) return null;
     Type[] newList = new Type[typeList.Length];
     for (int i = 0; i < typeList.Length; i++)
     {
         newList[i] = SubstituteType(typeList[i], paren, genTypes);
     }
     return newList;
 }
Esempio n. 37
0
 public string GetMetaDataLanguage() => MetaDataElement.GetAttribute("data-meta-language");
Esempio n. 38
0
 internal GenericParam(string name, MetaDataElement parent, int index)
     : base(VAR)
 {
     Contract.Requires(name != null);
     Contract.Requires(parent != null);
     this.name = name;
     this.parent = parent;
     this.index = (ushort)index;
     if (parent is Method) typeIndex = MVAR;
     tabIx = MDTable.GenericParam;
 }
Esempio n. 39
0
 internal override void Resolve(PEReader buff)
 {
     implementation = buff.GetCodedElement(CIx.Implementation, implIx);
     while (implementation is ExternClass)
         implementation = ((ExternClass)implementation).implementation;
     ((ModuleFile)implementation).fileModule.AddExternClass(this);
 }
Esempio n. 40
0
 internal TypeInstr(int inst, Type aType, MetaData md) : base(inst)
 {
     theType = aType.GetTypeSpec(md);
     size   += 4;
 }
Esempio n. 41
0
 internal void SetEntryPoint(MetaDataElement ep)
 {
     entryPoint = ep;
 }
Esempio n. 42
0
 internal void ClassToken(MetaDataElement cToken)
 {
     Contract.Requires(cToken != null);
     classToken = cToken;
 }
Esempio n. 43
0
 internal override sealed void BuildTables(MetaDataOut md)
 {
     md.AddToTable(MDTable.ExportedType, this);
     nameSpaceIx = md.AddToStringsHeap(NameSpace);
     nameIx = md.AddToStringsHeap(Name);
     if (implementation is ModuleRef)
     {
         ModuleFile mFile = ((ModuleRef)implementation).modFile;
         mFile.BuildMDTables(md);
         implementation = mFile;
     }
 }
Esempio n. 44
0
        internal void AddToTable(MDTable tableIx, MetaDataElement elem)
        {
            // Console.WriteLine("Adding element to table " + (uint)tableIx);

              ArrayList table = GetTable(tableIx);
              if (table.Contains(elem)) {
            Console.Out.WriteLine("ERROR - element already in table " + tableIx);
            return;
              }
              elem.Row = (uint)table.Count + 1;
              table.Add(elem);
        }
Esempio n. 45
0
 internal void WriteCodedIndex(CIx code, MetaDataElement elem)
 {
     Contract.Requires(elem != null);
     metaData.WriteCodedIndex(code, elem, this);
 }
Esempio n. 46
0
 internal void SetEntryPoint(MetaDataElement ep)
 {
     entryPoint = ep;
 }
Esempio n. 47
0
 internal void ClassToken(MetaDataElement cToken)
 {
     Contract.Requires(cToken != null);
     classToken = cToken;
 }
Esempio n. 48
0
 internal void SetMethParam(Method paren, int ix)
 {
     typeIndex = MVAR;
     parent    = paren;
     index     = (ushort)ix;
 }
Esempio n. 49
0
 internal void InsertInTable(MDTable tabIx, uint ix, MetaDataElement elem)
 {
     Contract.Requires(elem != null);
     tables[(int)tabIx][ix - 1] = elem;
 }
Esempio n. 50
0
 internal void WriteCodedIndex(CIx code, MetaDataElement elem)
 {
     Contract.Requires(elem != null);
     metaData.WriteCodedIndex(code, elem, this);
 }
Esempio n. 51
0
        private void RenderInfoGroupElement(ComponentController paComponentController, String paInfoLabel, MetaDataElement paMetaDataElement)
        {
            if ((paMetaDataElement != null) && (paMetaDataElement.ValueCount > 0))
            {
                paComponentController.AddAttribute(HtmlAttribute.Class, ctCLSInfoRow);
                paComponentController.RenderBeginTag(HtmlTag.Div);

                paComponentController.AddAttribute(HtmlAttribute.Class, ctCLSInfoLabel);
                paComponentController.RenderBeginTag(HtmlTag.Div);
                paComponentController.Write(paInfoLabel);
                paComponentController.RenderEndTag();

                paComponentController.AddAttribute(HtmlAttribute.Class, clCLSInfoData);
                paComponentController.RenderBeginTag(HtmlTag.Div);

                for (int lcCount = 0; lcCount < paMetaDataElement.ValueCount; lcCount++)
                {
                    paComponentController.RenderBeginTag(HtmlTag.Span);
                    paComponentController.Write(paMetaDataElement[lcCount].Replace(".", " "));
                    paComponentController.RenderEndTag();
                }


                paComponentController.RenderEndTag();

                paComponentController.RenderEndTag();
            }
        }
Esempio n. 52
0
 internal CustomAttribute(MetaDataElement paren, Method constrType,
     byte[] val)
Esempio n. 53
0
 public Catch(Type except, CILLabel handlerStart, CILLabel handlerEnd)
     : base(handlerStart, handlerEnd)
 {
     exceptType = except;
 }
Esempio n. 54
0
 private static Type SubstituteType(Type origType, MetaDataElement paren, Type[] genTypes)
 {
     Contract.Requires(origType != null);
     Contract.Requires(paren != null);
     Contract.Requires(genTypes != null);
     if ((origType is GenericParam) && (((GenericParam)origType).GetParent() == paren))
         return genTypes[((GenericParam)origType).Index];
     return origType;
 }
Esempio n. 55
0
 internal override void Resolve(PEReader buff)
 {
     parent = buff.GetCodedElement(CIx.HasConstant, parentIx);
     if (parent != null)
     {
         if (parent is Param) ((Param)parent).AddDefaultValue(cValue);
         else if (parent is FieldDef) ((FieldDef)parent).AddValue(cValue);
         else ((Property)parent).AddInitValue(cValue);
     }
 }