mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
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:
parent
33e835b58d
commit
2ab3974752
4 changed files with 47 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -294,7 +294,7 @@ ExpEmit FxParameter::Emit(VMFunctionBuilder *build)
|
|||
FxExpression *FxConstant::MakeConstant(PSymbol *sym, const FScriptPosition &pos)
|
||||
{
|
||||
FxExpression *x;
|
||||
PSymbolConst *csym = dyn_cast<PSymbolConst>(sym);
|
||||
PSymbolConstNumeric *csym = dyn_cast<PSymbolConstNumeric>(sym);
|
||||
if (csym != NULL)
|
||||
{
|
||||
if (csym->ValueType->IsA(RUNTIME_CLASS(PInt)))
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue