Skip to content

Commit

Permalink
Correctly format method name
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Aug 4, 2023
1 parent a2d4d3f commit edab29d
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/coreclr/inc/cor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1808,10 +1808,14 @@ FORCEINLINE ULONG CorSigUncompressData(
}

inline ULONG CorSigUncompressConstTypeArgData(
PCCOR_SIGNATURE & pData) // [IN,OUT] compressed const type argument data
PCCOR_SIGNATURE & pData, // [IN,OUT] compressed const type argument data
CorElementType* pType = NULL) // [OUT] const type argument type
{
ULONG size = 1;
switch (*pData++)
CorElementType type = (CorElementType)*pData++;
if (pType)
*pType = type;
switch (type)
{
case ELEMENT_TYPE_BOOLEAN :
case ELEMENT_TYPE_I1 :
Expand Down
83 changes: 81 additions & 2 deletions src/coreclr/vm/sigformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,86 @@ void SigFormat::AddTypeString(Module* pModule, SigPointer sig, const SigTypeCont
AddString(")");
break;
}

case ELEMENT_TYPE_CTARG:
{
CorElementType constValueType;
uint32_t cbSig;
PCCOR_SIGNATURE pSig;
IfFailThrow(sig.GetConstTypeArg(&constValueType, &cbSig, &pSig));
uint64_t constValue = 0;
memcpy(&constValue, pSig, cbSig);
AddConstValueTypeString(constValueType, constValue);
break;
}
default:
AddString("**UNKNOWN TYPE**");

}
}

void SigFormat::AddConstValueTypeString(CorElementType constValueType, uint64_t constValue)
{
AddString("const ");
char buffer[42];
switch (constValueType)
{
case ELEMENT_TYPE_BOOLEAN:
AddString("Boolean (");
sprintf_s(buffer, sizeof(buffer), *(uint8_t*)&constValue == 1 ? "true" : "false");
break;
case ELEMENT_TYPE_I1:
AddString("SByte (");
sprintf_s(buffer, sizeof(buffer), "%hhd", *(int8_t*)&constValue);
break;
case ELEMENT_TYPE_U1:
AddString("Byte (");
sprintf_s(buffer, sizeof(buffer), "%hhu", *(uint8_t*)&constValue);
break;
case ELEMENT_TYPE_I2:
AddString("Int16 (");
sprintf_s(buffer, sizeof(buffer), "%hd", *(int16_t*)&constValue);
break;
case ELEMENT_TYPE_U2:
AddString("UInt16 (");
sprintf_s(buffer, sizeof(buffer), "%hu", *(uint16_t*)&constValue);
break;
case ELEMENT_TYPE_CHAR:
AddString("Char (");
sprintf_s(buffer, sizeof(buffer), "0x%04hX", *(uint16_t*)&constValue);
break;
case ELEMENT_TYPE_I4:
AddString("Int32 (");
sprintf_s(buffer, sizeof(buffer), "%d", *(int32_t*)&constValue);
break;
case ELEMENT_TYPE_U4:
AddString("UInt32 (");
sprintf_s(buffer, sizeof(buffer), "%u", *(uint32_t*)&constValue);
break;
case ELEMENT_TYPE_I8:
AddString("Int64 (");
sprintf_s(buffer, sizeof(buffer), "%lld", *(int64_t*)&constValue);
break;
case ELEMENT_TYPE_U8:
AddString("UInt64 (");
sprintf_s(buffer, sizeof(buffer), "%llu", *(uint64_t*)&constValue);
break;
case ELEMENT_TYPE_R4:
AddString("Single (");
sprintf_s(buffer, sizeof(buffer), "%f", *(float*)&constValue);
break;
case ELEMENT_TYPE_R8:
AddString("Double (");
sprintf_s(buffer, sizeof(buffer), "%lf", *(double*)&constValue);
break;
default:
AddString("**UNKNOWN CONST VALUE TYPE** (");
sprintf_s(buffer, sizeof(buffer), "**UNKNOWN CONST VALUE**");
break;
}
AddString(buffer);
AddString(")");
}

void SigFormat::FormatSig(MetaSig &sig, LPCUTF8 szMemberName, LPCUTF8 szClassName, LPCUTF8 szNameSpace)
{
CONTRACTL
Expand Down Expand Up @@ -568,7 +641,13 @@ void SigFormat::AddType(TypeHandle th)

break;
}

case ELEMENT_TYPE_CTARG:
{
_ASSERTE(th.IsConstValue());
AddConstValueTypeString(th.AsConstValue()->GetConstValueType().GetInternalCorElementType(),
th.AsConstValue()->GetConstValue());
break;
}
default:
AddString("**UNKNOWN TYPE**");
}
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/sigformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SigFormat
size_t _pos;

void AddString(LPCUTF8 s);
void AddConstValueTypeString(CorElementType constValueType, uint64_t constValue);
void AddTypeString(Module* pModule, SigPointer sig, const SigTypeContext *pTypeContext);

};
Expand Down

0 comments on commit edab29d

Please sign in to comment.