Use PType for typing things in PSymbolConst.

This commit is contained in:
Randy Heit 2013-09-07 20:35:46 -05:00
parent 251cdacf26
commit 6584819d01
3 changed files with 11 additions and 12 deletions

View file

@ -38,7 +38,7 @@ class PSymbolConst : public PSymbol
{
DECLARE_CLASS(PSymbolConst, PSymbol);
public:
int ValueType;
class PType *ValueType;
union
{
int Value;

View file

@ -297,17 +297,16 @@ FxExpression *FxConstant::MakeConstant(PSymbol *sym, const FScriptPosition &pos)
PSymbolConst *csym = dyn_cast<PSymbolConst>(sym);
if (csym != NULL)
{
switch(csym->ValueType)
if (csym->ValueType->IsA(RUNTIME_CLASS(PInt)))
{
case VAL_Int:
x = new FxConstant(csym->Value, pos);
break;
case VAL_Float:
}
else if (csym->ValueType->IsA(RUNTIME_CLASS(PFloat)))
{
x = new FxConstant(csym->Float, pos);
break;
default:
}
else
{
pos.Message(MSG_ERROR, "Invalid constant '%s'\n", csym->SymbolName.GetChars());
return NULL;
}

View file

@ -205,12 +205,12 @@ static void ParseConstant (FScanner &sc, PSymbolTable *symt, PClassActor *cls)
PSymbolConst *sym = new PSymbolConst(symname);
if (type == TK_Int)
{
sym->ValueType = VAL_Int;
sym->ValueType = TypeSInt32;
sym->Value = val.GetInt();
}
else
{
sym->ValueType = VAL_Float;
sym->ValueType = TypeFloat64;
sym->Float = val.GetFloat();
}
if (symt->AddSymbol (sym) == NULL)
@ -261,7 +261,7 @@ static void ParseEnum (FScanner &sc, PSymbolTable *symt, PClassActor *cls)
delete expr;
}
PSymbolConst *sym = new PSymbolConst(symname);
sym->ValueType = VAL_Int;
sym->ValueType = TypeSInt32;
sym->Value = currvalue;
if (symt->AddSymbol (sym) == NULL)
{