private Type GetBlobType() { //Class currClass, Method currMeth) { byte typeIx = blob.ReadByte(); if (Diag.DiagOn) Console.WriteLine("Getting blob type " + (ElementType)typeIx); if (typeIx < PrimitiveType.primitives.Length) return PrimitiveType.primitives[typeIx]; switch (typeIx) { case ((int)ElementType.Ptr) : return new UnmanagedPointer(GetBlobType()); //currClass,currMeth)); case ((int)ElementType.ByRef) : return new ManagedPointer(GetBlobType()); //currClass,currMeth)); case ((int)ElementType.ValueType) : //Console.WriteLine("Reading value type"); uint vcIx = blob.ReadCompressedNum(); Class vClass = (Class)GetCodedElement(CIx.TypeDefOrRef,vcIx); vClass.MakeValueClass(); return vClass; case ((int)ElementType.Class) : return (Class)GetCodedElement(CIx.TypeDefOrRef,blob.ReadCompressedNum()); case ((int)ElementType.Array) : Type elemType = GetBlobType(); //currClass,currMeth); int rank = (int)blob.ReadCompressedNum(); int numSizes = (int)blob.ReadCompressedNum(); int[] sizes = null; if (numSizes > 0){ sizes = new int[numSizes]; for (int i=0; i < numSizes; i++) sizes[i] = (int)blob.ReadCompressedNum(); } int numBounds = (int)blob.ReadCompressedNum(); int[] loBounds = null, hiBounds = null; if ((numBounds > 0) && (numSizes > 0)){ loBounds = new int[numBounds]; hiBounds = new int[numBounds]; for (int i=0; i < numBounds; i++) { loBounds[i] = (int)blob.ReadCompressedNum(); hiBounds[i] = loBounds[i] + sizes[i] - 1; } } if (numSizes == 0) return new BoundArray(elemType,rank); if (numBounds == 0) return new BoundArray(elemType,rank,sizes); return new BoundArray(elemType,rank,loBounds,hiBounds); case ((int)ElementType.TypedByRef) : return PrimitiveType.TypedRef; case ((int)ElementType.I) : return PrimitiveType.IntPtr; case ((int)ElementType.U) : return PrimitiveType.UIntPtr; case ((int)ElementType.FnPtr) : MethSig mSig = ReadMethSig(null,false); return new MethPtrType(mSig); case ((int)ElementType.Object) : return PrimitiveType.Object; case ((int)ElementType.SZArray) : return new ZeroBasedArray(GetBlobType()); //currClass,currMeth)); case ((int)ElementType.CmodReqd) : case ((int)ElementType.CmodOpt) : Class modType = (Class)GetCodedElement(CIx.TypeDefOrRef,blob.ReadCompressedNum()); return new CustomModifiedType(GetBlobType(),(CustomModifier)typeIx,modType); case ((int)ElementType.Sentinel) : return sentinel; case ((int)ElementType.Pinned) : return pinned; case ((int)ElementType.GenericInst) : Class instType = (Class)GetBlobType(); Class scopeSave = currentClassScope; if (genInstNestLevel > 0) { currentClassScope = instType; } genInstNestLevel++; ClassSpec newClassSpec = new ClassSpec(instType,GetListOfType()); genInstNestLevel--; if (genInstNestLevel > 0) { currentClassScope = scopeSave; } return newClassSpec; case ((int)ElementType.Var) : if (currentClassScope == null) { //Console.WriteLine("GenericParam with currClass == null"); return GenericParam.AnonClassPar(blob.ReadCompressedNum()); //throw new Exception("No current class set"); } return currentClassScope.GetGenPar(blob.ReadCompressedNum()); case ((int)ElementType.MVar) : if (currentMethodScope == null) { //Console.WriteLine("GenericParam with currMeth == null"); return GenericParam.AnonMethPar(blob.ReadCompressedNum()); //throw new Exception("No current method set"); } return currentMethodScope.GetGenericParam((int)blob.ReadCompressedNum()); default: break; } return null; }
internal FieldDef(FieldAttr attrSet, string name, Type fType, ClassSpec paren) : base(name, fType,paren) { flags = (ushort)attrSet; tabIx = MDTable.Field; }
internal MethodDef(ClassSpec paren, MethSig mSig, Param[] pars) : base(mSig.name) { parent = paren; parList = pars; sig = mSig; tabIx = MDTable.Method; }