From 241622300e99ad7d02ad5c01308ea9636857d828 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 28 Jul 2013 19:40:48 -0500 Subject: [PATCH] Removed some EvalExpression implementations - Removed EvalExpression() implementations from some subclasses of FxExpression that don't make any sense in the context of evaluating a constant value. --- src/thingdef/thingdef_exp.h | 5 -- src/thingdef/thingdef_expression.cpp | 97 +--------------------------- 2 files changed, 1 insertion(+), 101 deletions(-) diff --git a/src/thingdef/thingdef_exp.h b/src/thingdef/thingdef_exp.h index c88260ac0..3b4c78864 100644 --- a/src/thingdef/thingdef_exp.h +++ b/src/thingdef/thingdef_exp.h @@ -667,7 +667,6 @@ public: ~FxRandom(); FxExpression *Resolve(FCompileContext&); - ExpVal EvalExpression(); ExpEmit Emit(VMFunctionBuilder *build); }; @@ -681,7 +680,6 @@ class FxFRandom : public FxRandom { public: FxFRandom(FRandom *, FxExpression *mi, FxExpression *ma, const FScriptPosition &pos); - ExpVal EvalExpression(); ExpEmit Emit(VMFunctionBuilder *build); }; @@ -702,7 +700,6 @@ public: ~FxRandom2(); FxExpression *Resolve(FCompileContext&); - ExpVal EvalExpression(); ExpEmit Emit(VMFunctionBuilder *build); }; @@ -757,7 +754,6 @@ class FxSelf : public FxExpression public: FxSelf(const FScriptPosition&); FxExpression *Resolve(FCompileContext&); - ExpVal EvalExpression(); ExpEmit Emit(VMFunctionBuilder *build); }; @@ -822,7 +818,6 @@ public: FxActionSpecialCall(FxExpression *self, int special, FArgumentList *args, const FScriptPosition &pos); ~FxActionSpecialCall(); FxExpression *Resolve(FCompileContext&); - ExpVal EvalExpression(); ExpEmit Emit(VMFunctionBuilder *build); }; diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 7946cfc07..d68ba59e7 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -2365,30 +2365,6 @@ FxExpression *FxRandom::Resolve(FCompileContext &ctx) // //========================================================================== -ExpVal FxRandom::EvalExpression() -{ - ExpVal val; - val.Type = VAL_Int; - - if (min != NULL && max != NULL) - { - int minval = min->EvalExpression().GetInt(); - int maxval = max->EvalExpression().GetInt(); - - if (maxval < minval) - { - swapvalues (maxval, minval); - } - - val.Int = (*rng)(maxval - minval + 1) + minval; - } - else - { - val.Int = (*rng)(); - } - return val; -} - int DecoRandom(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret) { assert(numparam >= 1 && numparam <= 3); @@ -2462,32 +2438,6 @@ FxFRandom::FxFRandom(FRandom *r, FxExpression *mi, FxExpression *ma, const FScri // //========================================================================== -ExpVal FxFRandom::EvalExpression() -{ - ExpVal val; - val.Type = VAL_Float; - int random = (*rng)(0x40000000); - double frandom = random / double(0x40000000); - - if (min != NULL && max != NULL) - { - double minval = min->EvalExpression().GetFloat(); - double maxval = max->EvalExpression().GetFloat(); - - if (maxval < minval) - { - swapvalues (maxval, minval); - } - - val.Float = frandom * (maxval - minval) + minval; - } - else - { - val.Float = frandom; - } - return val; -} - int DecoFRandom(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret) { assert(numparam == 1 || numparam == 3); @@ -2584,16 +2534,6 @@ FxExpression *FxRandom2::Resolve(FCompileContext &ctx) // //========================================================================== -ExpVal FxRandom2::EvalExpression() -{ - ExpVal maskval = mask->EvalExpression(); - int imaskval = maskval.GetInt(); - - maskval.Type = VAL_Int; - maskval.Int = rng->Random2(imaskval); - return maskval; -} - ExpEmit FxRandom2::Emit(VMFunctionBuilder *build) { // Call the DecoRandom function to generate the random number. @@ -2749,18 +2689,9 @@ FxExpression *FxSelf::Resolve(FCompileContext& ctx) // //========================================================================== -ExpVal FxSelf::EvalExpression() -{ - ExpVal ret; - - ret.Type = VAL_Object; - ret.pointer = NULL; - return ret; -} - ExpEmit FxSelf::Emit(VMFunctionBuilder *build) { - // self is always the first pointer passed to the function; + // self is always the first pointer passed to the function ExpEmit me(0, REGT_POINTER); me.Fixed = true; return me; @@ -3363,32 +3294,6 @@ FxExpression *FxActionSpecialCall::Resolve(FCompileContext& ctx) // //========================================================================== -ExpVal FxActionSpecialCall::EvalExpression() -{ - int v[5] = {0,0,0,0,0}; - int special = Special; - - if (ArgList != NULL) - { - for(unsigned i = 0; i < ArgList->Size(); i++) - { - if (special < 0) - { - special = -special; - v[i] = -(*ArgList)[i]->EvalExpression().GetName(); - } - else - { - v[i] = (*ArgList)[i]->EvalExpression().GetInt(); - } - } - } - ExpVal ret; - ret.Type = VAL_Int; - ret.Int = P_ExecuteSpecial(special, NULL, NULL, false, v[0], v[1], v[2], v[3], v[4]); - return ret; -} - int DecoCallLineSpecial(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret) { assert(numparam > 2 && numparam < 7);