@@ -213,7 +213,6 @@ void CLR_RT_SignatureParser::Initialize_TypeSpec(CLR_RT_Assembly *assm, CLR_PMET
213213 Flags = 0 ;
214214 ParamCount = 1 ;
215215 GenParamCount = 0 ;
216- IsGenericInst = false ;
217216}
218217
219218void CLR_RT_SignatureParser::Initialize_TypeSpec (CLR_RT_TypeSpec_Instance tsInstance)
@@ -227,7 +226,6 @@ void CLR_RT_SignatureParser::Initialize_TypeSpec(CLR_RT_TypeSpec_Instance tsInst
227226 Flags = 0 ;
228227 ParamCount = 1 ;
229228 GenParamCount = 0 ;
230- IsGenericInst = false ;
231229}
232230// --//
233231
@@ -253,7 +251,6 @@ void CLR_RT_SignatureParser::Initialize_Interfaces(CLR_RT_Assembly *assm, const
253251 Assembly = assm;
254252
255253 GenParamCount = 0 ;
256- IsGenericInst = false ;
257254}
258255
259256// --//
@@ -274,7 +271,6 @@ void CLR_RT_SignatureParser::Initialize_FieldSignature(CLR_RT_Assembly *assm, CL
274271 Signature = fd;
275272
276273 GenParamCount = 0 ;
277- IsGenericInst = false ;
278274}
279275
280276void CLR_RT_SignatureParser::Initialize_FieldDef (CLR_RT_Assembly *assm, const CLR_RECORD_FIELDDEF *fd)
@@ -295,7 +291,6 @@ void CLR_RT_SignatureParser::Initialize_FieldDef(CLR_RT_Assembly *assm, CLR_PMET
295291 Signature = fd;
296292
297293 GenParamCount = 0 ;
298- IsGenericInst = false ;
299294}
300295
301296// --//
@@ -339,8 +334,6 @@ void CLR_RT_SignatureParser::Initialize_MethodSignature(CLR_RT_Assembly *assm, C
339334
340335 Assembly = assm;
341336 Signature = md;
342-
343- IsGenericInst = false ;
344337}
345338
346339void CLR_RT_SignatureParser::Initialize_MethodSignature (CLR_RT_MethodSpec_Instance *ms)
@@ -366,8 +359,6 @@ void CLR_RT_SignatureParser::Initialize_MethodSignature(CLR_RT_MethodSpec_Instan
366359 Assembly = ms->assembly ;
367360
368361 GenParamCount = ParamCount;
369-
370- IsGenericInst = false ;
371362}
372363
373364// --//
@@ -397,7 +388,6 @@ bool CLR_RT_SignatureParser::Initialize_GenericParamTypeSignature(
397388 Flags = 0 ;
398389
399390 GenParamCount = 0 ;
400- IsGenericInst = false ;
401391
402392 // done here
403393 return true ;
@@ -422,7 +412,6 @@ void CLR_RT_SignatureParser::Initialize_MethodLocals(CLR_RT_Assembly *assm, cons
422412 ParamCount = md->localsCount ;
423413
424414 GenParamCount = 0 ;
425- IsGenericInst = false ;
426415}
427416
428417void CLR_RT_SignatureParser::Initialize_LocalVar (CLR_RT_Assembly *assm, const CLR_PMETADATA sig)
@@ -437,7 +426,6 @@ void CLR_RT_SignatureParser::Initialize_LocalVar(CLR_RT_Assembly *assm, const CL
437426 ParamCount = 1 ;
438427
439428 GenParamCount = 0 ;
440- IsGenericInst = false ;
441429}
442430
443431// --//
@@ -452,7 +440,6 @@ void CLR_RT_SignatureParser::Initialize_Objects(CLR_RT_HeapBlock *lst, int count
452440 ParamCount = count;
453441
454442 GenParamCount = 0 ;
455- IsGenericInst = false ;
456443}
457444
458445// --//
@@ -608,16 +595,20 @@ HRESULT CLR_RT_SignatureParser::Advance(Element &res)
608595 NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
609596 }
610597
611- if (IsGenericInst)
598+ // check if this type is a generic instance
599+ CLR_RT_TypeDef_Instance cls{};
600+ cls.InitializeFromIndex (res.Class );
601+
602+ if (cls.target ->genericParamCount > 0 )
612603 {
613- // get generic arguments count
614- GenParamCount = ( int )*Signature++ ;
604+ // reset the generic instance flag
605+ res. IsGenericInst = false ;
615606
616- // need to update the parser counter too
617- ParamCount = GenParamCount ;
607+ // get generic arguments count
608+ res. GenParamCount = ( int )*Signature++ ;
618609
619- // reset the generic instance flag
620- IsGenericInst = false ;
610+ // update parser param counter
611+ ParamCount += res. GenParamCount ;
621612 }
622613
623614 NANOCLR_SET_AND_LEAVE (S_OK);
@@ -634,7 +625,11 @@ HRESULT CLR_RT_SignatureParser::Advance(Element &res)
634625 case DATATYPE_GENERICINST:
635626 {
636627 // set flag for GENERICINST
637- IsGenericInst = true ;
628+ res.IsGenericInst = true ;
629+
630+ // update parser param counter
631+ ParamCount++;
632+
638633 NANOCLR_SET_AND_LEAVE (S_OK);
639634 }
640635
@@ -6527,100 +6522,44 @@ bool CLR_RT_TypeSystem::MatchSignatureElement(
65276522 }
65286523 else
65296524 {
6530- if (parserLeft.IsGenericInst && parserRight.IsGenericInst )
6531- {
6532- // TODO: we can do better here by checking the actual type of the generic parameters
6533- // CLR_RT_TypeDef_Index leftTypeDef;
6534- // NanoCLRDataType leftDT;
6535- // CLR_RT_TypeDef_Index rightTypeDef;
6536- // NanoCLRDataType rightDT;
6537-
6538- // parserLeft.Assembly->FindGenericParamAtTypeSpec(
6539- // resLeft.TypeSpec.TypeSpec(),
6540- // resLeft.GenericParamPosition,
6541- // leftTypeDef,
6542- // leftDT);
6543-
6544- // parserRight.Assembly->FindGenericParamAtTypeSpec(
6545- // resRight.TypeSpec.TypeSpec(),
6546- // resRight.GenericParamPosition,
6547- // rightTypeDef,
6548- // rightDT);
6549-
6550- // if (leftTypeDef.data != rightTypeDef.data || leftDT != rightDT)
6551- // {
6552- // return false;
6553- // }
6554- }
6525+ return true ;
65556526 }
65566527 }
65576528
6558- if (parserLeft. IsGenericInst != parserRight. IsGenericInst )
6529+ if (resLeft. DataType == DATATYPE_GENERICINST && resRight. DataType == DATATYPE_GENERICINST )
65596530 {
6560- return false ;
6561- }
6531+ // processing generic instance signature
6532+ // need to advance to get generic type and param count
6533+ if (FAILED (parserLeft.Advance (resLeft)) || FAILED (parserRight.Advance (resRight)))
6534+ {
6535+ return false ;
6536+ }
65626537
6563- if (parserLeft.IsGenericInst || parserRight.IsGenericInst )
6564- {
6565- if (resLeft.DataType == DATATYPE_GENERICINST && resRight.DataType == DATATYPE_GENERICINST)
6538+ // need to check if type of generic parameters match, if there are more
6539+ if (resLeft.GenParamCount > 0 && resRight.GenParamCount > 0 )
65666540 {
6567- // processing generic instance signature
6568- // need to advance to get generic type and param count
6569- if (FAILED (parserLeft.Advance (resLeft)) || FAILED (parserRight.Advance (resRight)))
6541+ if (resLeft.GenParamCount != resRight.GenParamCount )
65706542 {
65716543 return false ;
65726544 }
65736545
6574- // need to check if type of generic parameters match, if there are more
6575- if (parserLeft.ParamCount > 0 && parserRight.ParamCount > 0 )
6546+ if (resLeft.DataType != resRight.DataType )
65766547 {
6577- if (parserLeft.ParamCount != parserRight.ParamCount )
6578- {
6579- return false ;
6580- }
6581-
6582- if (resLeft.DataType != resRight.DataType )
6583- {
6584- return false ;
6585- }
6548+ return false ;
65866549 }
65876550 }
6588- else
6551+ }
6552+ else
6553+ {
6554+ if (parserLeft.GenParamCount != parserRight.GenParamCount )
65896555 {
6590- if (parserLeft.GenParamCount != parserRight.GenParamCount )
6591- {
6592- return false ;
6593- }
6594- else if (resLeft.GenericParamPosition != resRight.GenericParamPosition )
6595- {
6596- return false ;
6597- }
6556+ return false ;
6557+ }
6558+ else if (resLeft.GenericParamPosition != resRight.GenericParamPosition )
6559+ {
6560+ return false ;
65986561 }
65996562 }
6600-
6601- // if (parserLeft.IsGenericInst || parserRight.IsGenericInst)
6602- // {
6603- // if (resLeft.GenericParamPosition == 0xFFFF && resRight.GenericParamPosition == 0xFFFF)
6604- // {
6605- // // need to check if type of generic parameters match, if there are more
6606- // if (parserLeft.ParamCount > 0 && parserRight.ParamCount > 0)
6607- // {
6608- // if (FAILED(parserLeft.Advance(resLeft)) || FAILED(parserRight.Advance(resRight)))
6609- // {
6610- // return false;
6611- // }
6612- // }
6613-
6614- // if (resLeft.DataType != resRight.DataType)
6615- // {
6616- // return false;
6617- // }
6618- // }
6619- // else if (resLeft.GenericParamPosition != resRight.GenericParamPosition)
6620- // {
6621- // return false;
6622- // }
6623- // }
66246563 }
66256564
66266565 return true ;
0 commit comments