public override void Parse(CLRMetaDataParser parser) { Parent = parser.ReadHasCustomAttribute(); Constructor = parser.ReadCustomAttributeType(); m_rawValue = parser.ReadBlob(); m_tables = parser.Tables; }
public CLRSigCustomAttribute(CLRSignatureParser parser, CLRTableRow constructor) { Constructor = constructor; if (parser.ReadU16() != 0x0001) throw new NotSupportedException("Unusual CA prolog"); CLRSigMethodDefOrRefSig methodSig = null; if (constructor is CLRMethodDefRow) { CLRMethodDefRow methodDef = (CLRMethodDefRow)constructor; methodSig = methodDef.Signature; } else if (constructor is CLRMemberRefRow) { CLRMemberRefRow memberRef = (CLRMemberRefRow)constructor; methodSig = memberRef.MethodSig; if (methodSig == null) throw new ParseFailedException("Bad CA constructor"); } else throw new ParseFailedException("Missing CA constructor"); int numFixedArgs = methodSig.ParamTypes.Length; FixedArgs = new CLRSigCustomAttributeFixedArg[numFixedArgs]; for (int i = 0; i < numFixedArgs; i++) { CLRSigType paramType = methodSig.ParamTypes[i].Type; CLRSigType containedType = paramType; if (paramType is CLRSigTypeArray) containedType = ((CLRSigTypeArray)paramType).ContainedType; FixedArgs[i] = new CLRSigCustomAttributeFixedArg(parser, paramType); } uint numNamedArgs = parser.ReadU16(); NamedArgs = new CLRSigCustomAttributeNamedArg[numNamedArgs]; for (uint i = 0; i < numNamedArgs; i++) NamedArgs[i] = new CLRSigCustomAttributeNamedArg(parser); }
public override void ResolveSpans(CLRTableRow nextRow, CLRMetaDataParser parser) { PropertyList = CLRSpanResolver<CLRPropertyMapRow, CLRPropertyRow>.Resolve(this, nextRow, ref m_firstProperty, parser, CLRMetaDataTables.TableIndex.Property, nextRowTyped => { return nextRowTyped.m_firstProperty; }); }
public override void Parse(CLRMetaDataParser parser) { Class = (CLRTypeDefRow)parser.ReadTable(CLRMetaDataTables.TableIndex.TypeDef); Interface = parser.ReadTypeDefOrRefOrSpec(); }
private CppField ResolveField(CLRTableRow tableRow) { if (tableRow is CLRFieldRow) return new CppField(m_cppBuilder.Assemblies, (CLRFieldRow)tableRow); if (tableRow is CLRMemberRefRow) { CLRMemberRefRow memberRef = (CLRMemberRefRow)tableRow; CLRTypeSpec declaredIn = m_cppBuilder.ResolveTypeDefOrRefOrSpec(memberRef.Class); CLRTypeSpec fieldType = m_cppBuilder.Assemblies.InternVagueType(memberRef.FieldSig.Type); CppClass cachedClass = m_cppBuilder.GetCachedClass(declaredIn); foreach (CppField field in cachedClass.Fields) { if (field.Name == memberRef.Name && field.Type.Equals(fieldType)) return field; } throw new ParseFailedException("Unresolved field reference"); } throw new ArgumentException(); }
public override void Parse(CLRMetaDataParser parser) { Class = (CLRTypeDefRow)parser.ReadTable(CLRMetaDataTables.TableIndex.TypeDef); MethodBody = parser.ReadMethodDefOrRef(); MethodDeclaration = parser.ReadMethodDefOrRef(); }
public CLRSigTypeStructured(ElementType basicType, CLRTableRow type) { BasicType = basicType; TypeDefOrRefOrSpec = type; }
public override void Parse(CLRMetaDataParser parser) { Method = parser.ReadMethodDefOrRef(); Instantiation = new CLRSigMethodSpec(new CLRSignatureParser(parser.ReadBlob(), parser.Tables)); }
public virtual void ResolveSpans(CLRTableRow nextRow, CLRMetaDataParser parser) { }
public override void ResolveSpans(CLRTableRow nextRow, CLRMetaDataParser parser) { Fields = CLRSpanResolver<CLRTypeDefRow, CLRFieldRow>.Resolve(this, nextRow, ref m_firstField, parser, CLRMetaDataTables.TableIndex.Field, nextRowTyped => { return nextRowTyped.m_firstField; }); MethodDefs = CLRSpanResolver<CLRTypeDefRow, CLRMethodDefRow>.Resolve(this, nextRow, ref m_firstMethodDef, parser, CLRMetaDataTables.TableIndex.MethodDef, nextRowTyped => { return nextRowTyped.m_firstMethodDef; }); }
public void AddInterfaceImplementation(CLRTableRow ii) { m_implementedInterfaces.Add(ii); }
public CLRTypeSpec ResolveTypeDefOrRefOrSpec(CLRTableRow tableRow) { return m_assemblies.InternTypeDefOrRefOrSpec(tableRow); }
public CppVtableSlot ResolveMethodImplReference(CLRTableRow methodDecl) { if (methodDecl is CLRMethodDefRow) { CLRMethodDefRow mdef = (CLRMethodDefRow)methodDecl; CppClass cls = GetCachedClass(CreateInstanceTypeSpec(m_assemblies, mdef.Owner)); CLRMethodSignatureInstance sig = new CLRMethodSignatureInstance(m_assemblies, mdef.Signature); foreach (CppMethod method in cls.Methods) { if (method.MethodDef == mdef) { if (method.CreatesSlot != null) return method.CreatesSlot; if (method.ReplacesStandardSlot != null) return method.ReplacesStandardSlot; throw new ParseFailedException("Override was linked to a non-virtual method"); } } throw new ParseFailedException("Failed to match a MethodImpl"); } else if (methodDecl is CLRMemberRefRow) { CLRMemberRefRow mref = (CLRMemberRefRow)methodDecl; if (mref.MethodSig == null) throw new ParseFailedException("Strange method override encountered"); CppClass declaredInClass = this.GetCachedClass(m_assemblies.InternTypeDefOrRefOrSpec(mref.Class)); CLRMethodSignatureInstance sig = new CLRMethodSignatureInstance(m_assemblies, mref.MethodSig); foreach (CppVtableSlot slot in declaredInClass.OverrideVisibleVtableSlots) { if (slot.Name == mref.Name && sig.Equals(slot.DeclaredSignature)) return slot; } throw new ParseFailedException("Couldn't match method reference"); } else throw new NotSupportedException(); }
public CppMethodSpec ResolveMethodDefOrRef(CLRTableRow tableRow) { if (tableRow is CLRMethodDefRow) { CLRMethodDefRow methodDef = (CLRMethodDefRow)tableRow; return new CppMethodSpec(new CppMethod(this.Assemblies, methodDef.Owner, methodDef)); } if (tableRow is CLRMemberRefRow) { CLRMemberRefRow memberRef = (CLRMemberRefRow)tableRow; CLRTypeSpec declaredIn = this.ResolveTypeDefOrRefOrSpec(memberRef.Class); if (declaredIn is CLRTypeSpecComplexArray) throw new NotImplementedException(); CppClass cachedClass = this.GetCachedClass(declaredIn); CLRMethodSignatureInstance sig = new CLRMethodSignatureInstance(this.Assemblies, memberRef.MethodSig); foreach (CppMethod method in cachedClass.Methods) { if (method.Name == memberRef.Name && method.DeclaredMethodSignature.Equals(sig)) return new CppMethodSpec(method); } throw new ParseFailedException("Unresolved method reference"); } if (tableRow is CLRMethodSpecRow) { CLRMethodSpecRow methodSpec = (CLRMethodSpecRow)tableRow; CppMethod method = ResolveMethodDefOrRef(methodSpec.Method).CppMethod; List<CLRTypeSpec> types = new List<CLRTypeSpec>(); foreach (CLRSigType type in methodSpec.Instantiation.Types) types.Add(this.Assemblies.InternVagueType(type)); return new CppMethodSpec(method, types.ToArray()); } throw new ArgumentException(); }