Skip to content

Commit 70151e0

Browse files
committed
Remove duplicated TypeDescriptorsMatch implementation
1 parent 4eb7a30 commit 70151e0

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

src/CLR/Core/Execution.cpp

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,54 +3253,7 @@ bool CLR_RT_ExecutionEngine::IsInstanceOfToken(
32533253
}
32543254

32553255
// Delegate to the CLR built-in type-compatibility test
3256-
return TypeDescriptorsMatch(expectedDesc, actualDesc);
3257-
}
3258-
3259-
bool CLR_RT_ExecutionEngine::TypeDescriptorsMatch(const CLR_RT_TypeDescriptor &exp, const CLR_RT_TypeDescriptor &act)
3260-
{
3261-
// Quick check on the raw element kind
3262-
if (exp.GetDataType() != act.GetDataType())
3263-
{
3264-
return false;
3265-
}
3266-
3267-
switch (exp.GetDataType())
3268-
{
3269-
// Closed‐generic instantiation: compare the TypeSpec head
3270-
case DATATYPE_GENERICINST:
3271-
case DATATYPE_VAR:
3272-
{
3273-
auto &eSpec = exp.m_handlerGenericType;
3274-
auto &aSpec = act.m_handlerGenericType;
3275-
return eSpec.Assembly() == aSpec.Assembly() && eSpec.typeDefIndex == aSpec.typeDefIndex;
3276-
}
3277-
3278-
// Plain object or value‐type: compare the TypeDef_Index
3279-
case DATATYPE_CLASS:
3280-
case DATATYPE_VALUETYPE:
3281-
case DATATYPE_SZARRAY:
3282-
{
3283-
auto &eCls = exp.m_handlerCls;
3284-
auto &aCls = act.m_handlerCls;
3285-
3286-
if (eCls.data != aCls.data)
3287-
{
3288-
return false;
3289-
}
3290-
3291-
// for array we may need to compare element‐types
3292-
if (exp.GetDataType() == DATATYPE_SZARRAY)
3293-
{
3294-
// recurse into element descriptors
3295-
return TypeDescriptorsMatch(exp, act);
3296-
}
3297-
return true;
3298-
}
3299-
3300-
// All the primitives (I4, I8, R4, etc.) don't carry extra metadata
3301-
default:
3302-
return true;
3303-
}
3256+
return CLR_RT_HeapBlock::TypeDescriptorsMatch(expectedDesc, actualDesc);
33043257
}
33053258

33063259
HRESULT CLR_RT_ExecutionEngine::CastToType(

src/CLR/Include/nanoCLR_Runtime.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4072,7 +4072,6 @@ struct CLR_RT_ExecutionEngine
40724072
static bool IsInstanceOf(CLR_RT_HeapBlock &obj, const CLR_RT_TypeDef_Index &clsTarget);
40734073
static bool IsInstanceOf(CLR_RT_HeapBlock &obj, CLR_RT_Assembly *assm, CLR_UINT32 token, bool isInstInstruction);
40744074
bool IsInstanceOfToken(CLR_UINT32 token, CLR_RT_HeapBlock &obj, const CLR_RT_MethodDef_Instance &caller);
4075-
static bool TypeDescriptorsMatch(const CLR_RT_TypeDescriptor &exp, const CLR_RT_TypeDescriptor &act);
40764075

40774076
static HRESULT CastToType(CLR_RT_HeapBlock &ref, CLR_UINT32 tk, CLR_RT_Assembly *assm, bool isInstInstruction);
40784077

0 commit comments

Comments
 (0)