File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -1364,6 +1364,52 @@ bool CLR_RT_HeapBlock::ObjectsEqual(
13641364 }
13651365 break ;
13661366
1367+ case DATATYPE_CLASS:
1368+ {
1369+ const CLR_RT_HeapBlock *objLeft = &pArgLeft;
1370+ const CLR_RT_HeapBlock *objRight = &pArgRight;
1371+
1372+ CLR_RT_TypeDef_Instance classLeftObj;
1373+ classLeftObj.InitializeFromIndex (objLeft->ObjectCls ());
1374+ CLR_RT_TypeDef_Instance classRightObj;
1375+ classRightObj.InitializeFromIndex (objRight->ObjectCls ());
1376+
1377+ if (classLeftObj.m_data == classRightObj.m_data )
1378+ {
1379+ // this has been already checked above, still adding it here for completeness
1380+ if (&pArgLeft == &pArgRight)
1381+ {
1382+ return true ;
1383+ }
1384+
1385+ // check if the objects have the same number of fields
1386+ int leftClassTotFields = classLeftObj.CrossReference ().m_totalFields ;
1387+ int rightClassTotFields = classRightObj.CrossReference ().m_totalFields ;
1388+
1389+ if (leftClassTotFields > 0 && rightClassTotFields > 0 && leftClassTotFields == rightClassTotFields)
1390+ {
1391+ int equalFieldsCount = 0 ;
1392+
1393+ // loop through the fields and compare them
1394+ do
1395+ {
1396+ if (ObjectsEqual (
1397+ objLeft[leftClassTotFields + CLR_RT_HeapBlock::HB_Object_Fields_Offset],
1398+ objRight[rightClassTotFields + CLR_RT_HeapBlock::HB_Object_Fields_Offset],
1399+ false ))
1400+ {
1401+ // fields are equal
1402+ equalFieldsCount++;
1403+ }
1404+ } while (--leftClassTotFields > 0 );
1405+
1406+ // check if all fields are equal
1407+ return equalFieldsCount == leftClassTotFields;
1408+ }
1409+ }
1410+ }
1411+ break ;
1412+
13671413 default :
13681414
13691415 if ((leftDataType == rightDataType) && fSameReference == false )
You can’t perform that action at this time.
0 commit comments