diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index f10a07ad11..252b22fd3b 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -2287,6 +2287,8 @@ CCMD(typetable) IMPLEMENT_ABSTRACT_CLASS(PSymbol); IMPLEMENT_CLASS(PSymbolConst); +IMPLEMENT_CLASS(PSymbolConstNumeric); +IMPLEMENT_CLASS(PSymbolConstString); IMPLEMENT_POINTY_CLASS(PSymbolVMFunction) DECLARE_POINTER(Function) END_POINTERS diff --git a/src/dobjtype.h b/src/dobjtype.h index 56ae1b6de0..bfc3b966ef 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -32,23 +32,6 @@ protected: PSymbol(FName name) { SymbolName = name; } }; -// A constant value --------------------------------------------------------- - -class PSymbolConst : public PSymbol -{ - DECLARE_CLASS(PSymbolConst, PSymbol); -public: - class PType *ValueType; - union - { - int Value; - double Float; - }; - - PSymbolConst(FName name) : PSymbol(name) {} - PSymbolConst() : PSymbol(NAME_None) {} -}; - // An action function ------------------------------------------------------- struct FState; @@ -654,4 +637,44 @@ extern PStatePointer *TypeState; extern PFixed *TypeFixed; extern PAngle *TypeAngle; +// A constant value --------------------------------------------------------- + +class PSymbolConst : public PSymbol +{ + DECLARE_CLASS(PSymbolConst, PSymbol); +public: + PType *ValueType; + + PSymbolConst(FName name, PType *type=NULL) : PSymbol(name), ValueType(type) {} + PSymbolConst() : PSymbol(NAME_None), ValueType(NULL) {} +}; + +// A constant numeric value ------------------------------------------------- + +class PSymbolConstNumeric : public PSymbolConst +{ + DECLARE_CLASS(PSymbolConstNumeric, PSymbolConst); +public: + union + { + int Value; + double Float; + }; + + PSymbolConstNumeric(FName name, PType *type=NULL) : PSymbolConst(name, type) {} + PSymbolConstNumeric() {} +}; + +// A constant string value -------------------------------------------------- + +class PSymbolConstString : public PSymbolConst +{ + DECLARE_CLASS(PSymbolConstString, PSymbolConst); +public: + FString Str; + + PSymbolConstString(FName name, FString &str) : PSymbolConst(name, TypeString), Str(str) {} + PSymbolConstString() {} +}; + #endif diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 1f5d48ab5d..f7e5988151 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -294,7 +294,7 @@ ExpEmit FxParameter::Emit(VMFunctionBuilder *build) FxExpression *FxConstant::MakeConstant(PSymbol *sym, const FScriptPosition &pos) { FxExpression *x; - PSymbolConst *csym = dyn_cast(sym); + PSymbolConstNumeric *csym = dyn_cast(sym); if (csym != NULL) { if (csym->ValueType->IsA(RUNTIME_CLASS(PInt))) diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index db8238d1c1..2632efcc11 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -202,15 +202,15 @@ static void ParseConstant (FScanner &sc, PSymbolTable *symt, PClassActor *cls) { ExpVal val = static_cast(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) {