private MethSig ReadMethSig(Method currMeth, bool firstByteRead)
{
//Class currClass = null;
//if (currMeth != null) currClass = (Class)currMeth.GetParent();
MethSig meth = new MethSig(null);
if (!firstByteRead) {
byte firstByte = blob.ReadByte();
if (firstByte == Field.FieldTag)
return null;
meth.callConv =(CallConv)firstByte;
}
if ((meth.callConv & CallConv.Generic) != 0){
meth.numGenPars = blob.ReadCompressedNum();
if (currMeth is MethodRef) {
((MethodRef)currMeth).MakeGenericPars(meth.numGenPars);
} //else if (currMeth is MethodDef) {
//GetGenericParams((MethodDef)currMeth);
//}
}
uint parCount = blob.ReadCompressedNum();
if (Diag.DiagOn) Console.WriteLine("Method sig has " + parCount + " parameters");
meth.retType = GetBlobType();//currClass,currMeth);
if (meth.retType == null)
System.Diagnostics.Debug.Assert(meth.retType != null);
int optParStart = -1;
ArrayList pTypes = new ArrayList();
for (int i=0; i < parCount; i++) {
Type pType = GetBlobType();//currClass,currMeth);
if (pType == sentinel) {
optParStart = i;
pType = GetBlobType();//currClass,currMeth);
}
if (Diag.DiagOn) if (pType == null) Console.WriteLine("Param type is null");
pTypes.Add(pType);
}
if (optParStart > -1) {
meth.numPars = (uint)optParStart;
meth.numOptPars = parCount - meth.numPars;
meth.optParTypes = new Type[meth.numOptPars];
for (int i=0; i < meth.numOptPars; i++) {
meth.optParTypes[i] = (Type)pTypes[i+optParStart];
}
} else
meth.numPars = parCount;
meth.parTypes = new Type[meth.numPars];
for (int i=0; i < meth.numPars; i++) {
meth.parTypes[i] = (Type)pTypes[i];
}
return meth;
}