Add a PSymbolConstString class

- Constants can be strings, but the existing PSymbolConst couldn't handle
  them. The old PSymbolConst is now PSymbolConstNumeric, and the new
  PSymbolConst is a now a baseclass for it and PSymbolConstString.
This commit is contained in:
Randy Heit 2013-09-10 22:01:00 -05:00
commit 2ab3974752
4 changed files with 47 additions and 23 deletions

View file

@ -202,15 +202,15 @@ static void ParseConstant (FScanner &sc, PSymbolTable *symt, PClassActor *cls)
{
ExpVal val = static_cast<FxConstant *>(expr)->GetValue();
delete expr;
PSymbolConst *sym = new PSymbolConst(symname);
PSymbolConstNumeric *sym;
if (type == TK_Int)
{
sym->ValueType = TypeSInt32;
sym = new PSymbolConstNumeric(symname, TypeSInt32);
sym->Value = val.GetInt();
}
else
{
sym->ValueType = TypeFloat64;
sym = new PSymbolConstNumeric(symname, TypeFloat64);
sym->Float = val.GetFloat();
}
if (symt->AddSymbol (sym) == NULL)
@ -260,8 +260,7 @@ static void ParseEnum (FScanner &sc, PSymbolTable *symt, PClassActor *cls)
}
delete expr;
}
PSymbolConst *sym = new PSymbolConst(symname);
sym->ValueType = TypeSInt32;
PSymbolConstNumeric *sym = new PSymbolConstNumeric(symname, TypeSInt32);
sym->Value = currvalue;
if (symt->AddSymbol (sym) == NULL)
{