public static MethodSignatureTag CreateMethodSignature(CLRMethodSignatureInstance methodSignature) { List<MethodSignatureParam> paramTags = new List<MethodSignatureParam>(); foreach (CLRMethodSignatureInstanceParam p in methodSignature.ParamTypes) paramTags.Add(CreateMethodSignatureParam(p)); return new MethodSignatureTag(methodSignature.NumGenericParameters, CreateTypeTag(methodSignature.RetType), paramTags.ToArray()); }
public void Add(CLRMethodSignatureInstance methodSig) { CppMangleBuilder builder = new CppMangleBuilder(); builder.Add(methodSig.RetType); builder.Cycle(); foreach (CLRMethodSignatureInstanceParam param in methodSig.ParamTypes) { builder.Add((int)param.TypeOfType); builder.Add(param.Type); builder.Cycle(); } AddBytes(builder.FinishAsBytes()); }
public static List<int> FindOverrideIndexes(List<CppVtableSlot> visible, string name, CLRMethodSignatureInstance sig) { List<int> removeIndexes = new List<int>(); for (int i = 0; i < visible.Count; i++) { CppVtableSlot candidate = visible[i]; if (candidate.Name == name && candidate.Signature.Equals(sig)) removeIndexes.Add(i); } return removeIndexes; }
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(); }