Skip to content

Commit

Permalink
Reuse "literal" keyword in IL and get rid of "const"
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Aug 6, 2023
1 parent edab29d commit 902e196
Show file tree
Hide file tree
Showing 8 changed files with 6,327 additions and 4,949 deletions.
7 changes: 3 additions & 4 deletions src/coreclr/ilasm/asmparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@

/* newly added tokens go here */
%token CONSTRAINT_
%token CONST_

/* nonTerminals */
%type <string> dottedName id methodName atOpt slashedName
Expand Down Expand Up @@ -504,8 +503,8 @@ conTyparAttribs : /* EMPTY */ { $$ = 0; }
| conTyparAttrib conTyparAttribs { $$ = $1 | $2; }
;

typars : CONST_ conTyparAttribs type tyBound dottedName typarsRest {$$ = new TyParList($2, $3, $4, $5, $6); }
| CONST_ conTyparAttribs type dottedName typarsRest {$$ = new TyParList($2, $3, NULL, $4, $5); }
typars : LITERAL_ conTyparAttribs type tyBound dottedName typarsRest {$$ = new TyParList($2, $3, $4, $5, $6); }
| LITERAL_ conTyparAttribs type dottedName typarsRest {$$ = new TyParList($2, $3, NULL, $4, $5); }
| typarAttribs tyBound dottedName typarsRest {$$ = new TyParList($1, $2, $3, $4);}
| typarAttribs dottedName typarsRest {$$ = new TyParList($1, NULL, $2, $3);}
;
Expand Down Expand Up @@ -1727,7 +1726,7 @@ type : CLASS_ className { if($2 == PASM->m
| OBJECT_ { $$ = new BinStr(); $$->appendInt8(ELEMENT_TYPE_OBJECT); }
| VALUE_ CLASS_ className { $$ = parser->MakeTypeClass(ELEMENT_TYPE_VALUETYPE, $3); }
| VALUETYPE_ className { $$ = parser->MakeTypeClass(ELEMENT_TYPE_VALUETYPE, $2); }
| CONST_ constTypeArg { $$ = $2; $$->insertInt8(ELEMENT_TYPE_CTARG); }
| constTypeArg { $$ = $1; $$->insertInt8(ELEMENT_TYPE_CTARG); }
| type '[' ']' { $$ = $1; $$->insertInt8(ELEMENT_TYPE_SZARRAY); }
| type '[' bounds1 ']' { $$ = parser->MakeTypeArray(ELEMENT_TYPE_ARRAY, $1, $3); }
| type '&' { $$ = $1; $$->insertInt8(ELEMENT_TYPE_BYREF); }
Expand Down
11,259 changes: 6,322 additions & 4,937 deletions src/coreclr/ilasm/prebuilt/asmparse.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/coreclr/ildasm/dasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3123,7 +3123,7 @@ char *DumpGenericPars(_Inout_updates_(SZSTRING_SIZE) char* szString, mdToken tok
if (RidFromToken(tkType))
{
CQuickBytes out;
szptr += sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr),"const %s ",PrettyPrintClass(&out, tkType, g_pImport));
szptr += sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr),"literal %s ",PrettyPrintClass(&out, tkType, g_pImport));
}
if (chName)
{
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/inc/formattype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ PCCOR_SIGNATURE PrettyPrintType(
str = "class ";
goto DO_CLASS;
case ELEMENT_TYPE_CTARG :
appendStr(out, KEYWORD("const "));
Reiterate = TRUE;
HasData = TRUE;
break;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/inc/il_kywd.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@
/* Null reference keyword for InitOpt */
KYWD( "nullref", NULLREF_, NO_VALUE )
KYWD( "type", TYPE_, NO_VALUE )
KYWD( "const", CONST_, NO_VALUE )
KYWD( ".interfaceimpl", _INTERFACEIMPL, NO_VALUE )
/* Header flags keywords */
KYWD( ".subsystem", _SUBSYSTEM, NO_VALUE )
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/eeinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void Compiler::eePrintJitType(StringPrinter* printer, var_types jitType)
//
void Compiler::eePrintConstValue(StringPrinter* printer, CorInfoType valueType, uint64_t value)
{
printer->Append("const ");
printer->Append(varTypeName(JitType2PreciseVarType(valueType)));
printer->Append("(");
char buffer[64];
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/sigformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ void SigFormat::AddTypeString(Module* pModule, SigPointer sig, const SigTypeCont

void SigFormat::AddConstValueTypeString(CorElementType constValueType, uint64_t constValue)
{
AddString("const ");
char buffer[42];
switch (constValueType)
{
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/vm/typestring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ void TypeString::AppendType(TypeNameBuilder& tnb, TypeHandle ty, Instantiation t
PCCOR_SIGNATURE pSig;
ULONG cSig;
IfFailThrow(ty.GetModule()->GetMDImport()->GetTypeSpecFromToken(mdType, &pSig, &cSig));
SmallStackSString typeName(SString::Utf8, "const ");
SmallStackSString typeName(SString::Utf8, "literal ");
LPCSTR str;
switch (*pSig++)
{
Expand Down Expand Up @@ -890,7 +890,6 @@ void TypeString::AppendType(TypeNameBuilder& tnb, TypeHandle ty, Instantiation t
// or a const value
else if (ty.IsConstValue())
{
tnb.Append(W("const "));
AppendType(tnb, ty.AsConstValue()->GetConstValueType(), Instantiation(), format & ~FormatAssembly);
tnb.Append(W("("));
AppendConstValue(tnb, ty.AsConstValue()->GetConstValueType().GetInternalCorElementType(), ty.AsConstValue()->GetConstValue());
Expand Down Expand Up @@ -1231,7 +1230,6 @@ void TypeString::AppendTypeKey(TypeNameBuilder& tnb, TypeKey *pTypeKey, DWORD fo
}
else if (kind == ELEMENT_TYPE_CTARG)
{
tnb.Append(W("const "));
TypeHandle valueType = pTypeKey->GetConstValueType();
AppendType(tnb, valueType, Instantiation(), format & ~FormatAssembly);
tnb.Append(W("("));
Expand Down

0 comments on commit 902e196

Please sign in to comment.