private IType Resolve(int index, Context context) { var row = _loader.Metadata.GetRow(TableId.TypeSpec, index); var blob = row[Schema.TypeSpec.Signature].Blob; var sig = TypeSignature.Decode(blob); var type = _loader.ResolveType(sig, context); if (type == null) { throw new BadMetadataException(string.Format("Unable to resolve signature {0}", sig)); } return(type); }
public IVariableCollection ResolveLocalVariables(IMethod method, int sig, out bool hasGenericVars) { hasGenericVars = false; var list = new VariableCollection(); if (sig == 0) { return(list); } var context = new Context(method); SimpleIndex idx = sig; var row = Metadata.GetRow(TableId.StandAloneSig, idx.Index - 1); var reader = row[Schema.StandAloneSig.Signature].Blob; int prolog = reader.ReadPackedInt(); if (prolog != 0x07) { throw new BadSignatureException("Invalid local variable signature."); } int varCount = reader.ReadPackedInt(); for (int i = 0; i < varCount; ++i) { var typeSig = TypeSignature.Decode(reader); var type = ResolveType(typeSig, context); if (!hasGenericVars && type.IsGenericContext()) { hasGenericVars = true; } var v = new Variable { Index = i, Type = type, Name = string.Format("v{0}", i) }; list.Add(v); } return(list); }
private IType[] ReadMethodSpecArgs(BufferedBinaryReader reader, Context context) { if (reader.ReadByte() != 0x0A) { throw new BadSignatureException("Invalid MethodSpec signature"); } int n = reader.ReadPackedInt(); var args = new IType[n]; for (int i = 0; i < n; ++i) { var sig = TypeSignature.Decode(reader); args[i] = _loader.ResolveType(sig, context); } return(args); }