From 6584819d01b2cfe23cfaaf1ac04ece53d7426bd8 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 7 Sep 2013 20:35:46 -0500 Subject: [PATCH] Use PType for typing things in PSymbolConst. --- src/dobjtype.h | 2 +- src/thingdef/thingdef_expression.cpp | 15 +++++++-------- src/thingdef/thingdef_parse.cpp | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/dobjtype.h b/src/dobjtype.h index dad47d44c1..56ae1b6de0 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -38,7 +38,7 @@ class PSymbolConst : public PSymbol { DECLARE_CLASS(PSymbolConst, PSymbol); public: - int ValueType; + class PType *ValueType; union { int Value; diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index d5fd9b0d24..1f5d48ab5d 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -297,17 +297,16 @@ FxExpression *FxConstant::MakeConstant(PSymbol *sym, const FScriptPosition &pos) PSymbolConst *csym = dyn_cast(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; } diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 55d43b5357..db8238d1c1 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -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) {