Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/CLR/Core/CLR_RT_HeapBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,31 +294,6 @@ HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_MethodDef_Index &md)
NANOCLR_NOCLEANUP();
}

HRESULT CLR_RT_HeapBlock::SetReflection(const CLR_RT_GenericParam_Index &gp)
{
NATIVE_PROFILE_CLR_CORE();
NANOCLR_HEADER();

CLR_RT_GenericParam_Instance genericParam;
CLR_RT_TypeDef_Index typeDef;

if (genericParam.InitializeFromIndex(gp) == false)
{
NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE);
}

// grab the type definition from the generic param
typeDef = genericParam.CrossReference().classTypeDef;

m_id.raw = CLR_RT_HEAPBLOCK_RAW_ID(DATATYPE_REFLECTION, 0, 1);
m_data.reflection.levels = 0;
m_data.reflection.kind = REFLECTION_TYPE;
// set the type definition in the reflection block
m_data.reflection.data.type.Set(typeDef.Assembly(), typeDef.Type());

NANOCLR_NOCLEANUP();
}

HRESULT CLR_RT_HeapBlock::SetObjectCls(const CLR_RT_TypeDef_Index &cls)
{
NATIVE_PROFILE_CLR_CORE();
Expand Down
25 changes: 24 additions & 1 deletion src/CLR/Core/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,30 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE);
}

evalPos[0].SetReflection(param);
if (stack->m_call.genericType != nullptr)
{
// For a method in a generic type, caller->genericType points to the TypeSpec of the
// closed type
CLR_UINT32 closedTypeSpecRow = stack->m_call.genericType->TypeSpec();

CLR_RT_TypeDef_Index resolvedTypeDef;
NanoCLRDataType resolvedDataType;

CLR_UINT32 index = CLR_DataFromTk(arg);

assm->FindGenericParamAtTypeSpec(
closedTypeSpecRow,
index,
resolvedTypeDef,
resolvedDataType);

evalPos[0].SetReflection(resolvedTypeDef);
}
else
{
// No caller context??
NANOCLR_SET_AND_LEAVE(CLR_E_WRONG_TYPE);
}
}
break;

Expand Down
1 change: 0 additions & 1 deletion src/CLR/Include/nanoCLR_Runtime__HeapBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,6 @@ struct CLR_RT_HeapBlock
HRESULT SetReflection(const CLR_RT_TypeDef_Index &cls);
HRESULT SetReflection(const CLR_RT_FieldDef_Index &fd);
HRESULT SetReflection(const CLR_RT_MethodDef_Index &md);
HRESULT SetReflection(const CLR_RT_GenericParam_Index &gp);

HRESULT InitializeArrayReference(CLR_RT_HeapBlock &ref, int index);
void InitializeArrayReferenceDirect(CLR_RT_HeapBlock_Array &array, int index);
Expand Down