mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +00:00
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.
This commit is contained in:
parent
2c24e7f9c6
commit
241622300e
2 changed files with 1 additions and 101 deletions
|
@ -667,7 +667,6 @@ public:
|
||||||
~FxRandom();
|
~FxRandom();
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
|
|
||||||
ExpVal EvalExpression();
|
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -681,7 +680,6 @@ class FxFRandom : public FxRandom
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FxFRandom(FRandom *, FxExpression *mi, FxExpression *ma, const FScriptPosition &pos);
|
FxFRandom(FRandom *, FxExpression *mi, FxExpression *ma, const FScriptPosition &pos);
|
||||||
ExpVal EvalExpression();
|
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -702,7 +700,6 @@ public:
|
||||||
~FxRandom2();
|
~FxRandom2();
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
|
|
||||||
ExpVal EvalExpression();
|
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -757,7 +754,6 @@ class FxSelf : public FxExpression
|
||||||
public:
|
public:
|
||||||
FxSelf(const FScriptPosition&);
|
FxSelf(const FScriptPosition&);
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
ExpVal EvalExpression();
|
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -822,7 +818,6 @@ public:
|
||||||
FxActionSpecialCall(FxExpression *self, int special, FArgumentList *args, const FScriptPosition &pos);
|
FxActionSpecialCall(FxExpression *self, int special, FArgumentList *args, const FScriptPosition &pos);
|
||||||
~FxActionSpecialCall();
|
~FxActionSpecialCall();
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
ExpVal EvalExpression();
|
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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)
|
int DecoRandom(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret)
|
||||||
{
|
{
|
||||||
assert(numparam >= 1 && numparam <= 3);
|
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)
|
int DecoFRandom(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret)
|
||||||
{
|
{
|
||||||
assert(numparam == 1 || numparam == 3);
|
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)
|
ExpEmit FxRandom2::Emit(VMFunctionBuilder *build)
|
||||||
{
|
{
|
||||||
// Call the DecoRandom function to generate the random number.
|
// 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)
|
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);
|
ExpEmit me(0, REGT_POINTER);
|
||||||
me.Fixed = true;
|
me.Fixed = true;
|
||||||
return me;
|
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)
|
int DecoCallLineSpecial(VMFrameStack *stack, VMValue *param, int numparam, VMReturn *ret, int numret)
|
||||||
{
|
{
|
||||||
assert(numparam > 2 && numparam < 7);
|
assert(numparam > 2 && numparam < 7);
|
||||||
|
|
Loading…
Reference in a new issue