/*-------------------- Constructors ---------------------------------*/ internal FieldMarshal(MetaDataElement field, NativeType nType) { Contract.Requires(field != null); this.field = field; this.nt = nType; tabIx = MDTable.FieldMarshal; }
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); } } }
/*-------------------- Constructors ---------------------------------*/ internal DeclSecurity(MetaDataElement paren, SecurityAction act, byte[] perSet) { Contract.Requires(perSet != null); parent = paren; action = act; permissionSet = perSet; tabIx = MDTable.DeclSecurity; }
/*-------------------- Constructors ---------------------------------*/ internal ExternClass(TypeAttr attr, string ns, string name, MetaDataElement paren) { flags = (uint)attr; NameSpace = ns; this.Name = name; implementation = paren; tabIx = MDTable.ExportedType; }
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); }
internal void CheckParent(MethodDef paren, PEReader buff) { Contract.Requires(buff != null); if (paren == buff.GetCodedElement(CIx.TypeOrMethodDef, parentIx)) { parent = paren; paren.InsertGenericParam(this); } }
internal void ConditionalAddTypeSpec(MetaDataElement elem) { ArrayList table = GetTable(MDTable.TypeSpec); if (!table.Contains(elem)) { elem.Row = (uint)table.Count + 1; table.Add(elem); } }
/*-------------------- Constructors ---------------------------------*/ internal CustomAttribute(MetaDataElement paren, Method constrType, Constant[] val) { Contract.Requires(constrType != null); parent = paren; type = constrType; argVals = val; changed = true; tabIx = MDTable.CustomAttribute; }
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); }
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); }
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; }
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; } }
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); } }
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); }
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; }
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); }
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); } }
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); } } } }
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); }
internal void SetClassParam(Class paren, int ix) { typeIndex = VAR; parent = paren; index = (ushort)ix; }
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); }
internal CustomAttribute(MetaDataElement paren, Method constrType, byte[] val)
internal void ResolveType(MetaData md) { exceptType = ((Type)exceptType).GetTypeSpec(md); }
internal void DescriptorError(MetaDataElement elem) { Contract.Requires(elem != null); throw new DescriptorException(elem.NameString()); }
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); } }
internal void SetMethParam(Method paren, int ix) { typeIndex = MVAR; parent = paren; index = (ushort)ix; }
/*-------------------- Constructors ---------------------------------*/ internal ConstantElem(MetaDataElement parent, Constant val) { Contract.Requires(val != null); this.parent = parent; cValue = val; tabIx = MDTable.Constant; }
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); } } }
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; }
public string GetMetaDataLanguage() => MetaDataElement.GetAttribute("data-meta-language");
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; }
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); }
internal TypeInstr(int inst, Type aType, MetaData md) : base(inst) { theType = aType.GetTypeSpec(md); size += 4; }
internal void SetEntryPoint(MetaDataElement ep) { entryPoint = ep; }
internal void ClassToken(MetaDataElement cToken) { Contract.Requires(cToken != null); classToken = cToken; }
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; } }
internal void WriteCodedIndex(CIx code, MetaDataElement elem) { Contract.Requires(elem != null); metaData.WriteCodedIndex(code, elem, this); }
internal void InsertInTable(MDTable tabIx, uint ix, MetaDataElement elem) { Contract.Requires(elem != null); tables[(int)tabIx][ix - 1] = elem; }
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(); } }
public Catch(Type except, CILLabel handlerStart, CILLabel handlerEnd) : base(handlerStart, handlerEnd) { exceptType = except; }
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; }
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); } }