- Added a global symbol table and changed DECORATE parser to put its global
symbols there instead of into AActor. - Changed the expression evaluator's floating point precision to double. - Started rewriting the DECORATE expression evaluator to allow more flexibility. All the operators use the new functionality but functions, variables and constants are yet to be redone. While doing this rewrite I noticed that random2 was always evaluated as const. This got fixed automatically. SVN r1264 (trunk)
This commit is contained in:
parent
bca1fc5068
commit
7312e6a621
11 changed files with 2231 additions and 956 deletions
|
|
@ -50,6 +50,7 @@
|
|||
#include "doomerrors.h"
|
||||
#include "autosegs.h"
|
||||
#include "i_system.h"
|
||||
#include "thingdef_exp.h"
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -68,10 +69,11 @@ void ParseConstant (FScanner &sc, PSymbolTable * symt, PClass *cls)
|
|||
sc.MustGetToken(TK_Identifier);
|
||||
FName symname = sc.String;
|
||||
sc.MustGetToken('=');
|
||||
int expr = ParseExpression (sc, false, cls);
|
||||
FxExpression *expr = ParseExpression (sc, cls);
|
||||
sc.MustGetToken(';');
|
||||
|
||||
int val = EvalExpressionI (expr, NULL, cls);
|
||||
int val = expr->EvalExpression(NULL, cls).GetInt();
|
||||
delete expr;
|
||||
PSymbolConst *sym = new PSymbolConst;
|
||||
sym->SymbolName = symname;
|
||||
sym->SymbolType = SYM_Const;
|
||||
|
|
@ -79,8 +81,8 @@ void ParseConstant (FScanner &sc, PSymbolTable * symt, PClass *cls)
|
|||
if (symt->AddSymbol (sym) == NULL)
|
||||
{
|
||||
delete sym;
|
||||
sc.ScriptError ("'%s' is already defined in class '%s'.",
|
||||
symname.GetChars(), cls->TypeName.GetChars());
|
||||
sc.ScriptError ("'%s' is already defined in '%s'.",
|
||||
symname.GetChars(), cls? cls->TypeName.GetChars() : "Global");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,8 +105,9 @@ void ParseEnum (FScanner &sc, PSymbolTable *symt, PClass *cls)
|
|||
FName symname = sc.String;
|
||||
if (sc.CheckToken('='))
|
||||
{
|
||||
int expr = ParseExpression(sc, false, cls);
|
||||
currvalue = EvalExpressionI(expr, NULL, cls);
|
||||
FxExpression *expr = ParseExpression (sc, cls);
|
||||
currvalue = expr->EvalExpression(NULL, cls).GetInt();
|
||||
delete expr;
|
||||
}
|
||||
PSymbolConst *sym = new PSymbolConst;
|
||||
sym->SymbolName = symname;
|
||||
|
|
@ -113,8 +116,8 @@ void ParseEnum (FScanner &sc, PSymbolTable *symt, PClass *cls)
|
|||
if (symt->AddSymbol (sym) == NULL)
|
||||
{
|
||||
delete sym;
|
||||
sc.ScriptError ("'%s' is already defined in class '%s'.",
|
||||
symname.GetChars(), cls->TypeName.GetChars());
|
||||
sc.ScriptError ("'%s' is already defined in '%s'.",
|
||||
symname.GetChars(), cls? cls->TypeName.GetChars() : "Global");
|
||||
}
|
||||
// This allows a comma after the last value but doesn't enforce it.
|
||||
if (sc.CheckToken('}')) break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue