mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-12-02 16:32:12 +00:00
Merge commit '173dbd6bcee02a9e9c12a4a74d1fffe3e081d162' into scripting
This commit is contained in:
commit
e9cbb0b223
2 changed files with 95 additions and 0 deletions
|
@ -389,6 +389,25 @@ public:
|
|||
};
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
class FxFloatCast : public FxExpression
|
||||
{
|
||||
FxExpression *basex;
|
||||
|
||||
public:
|
||||
|
||||
FxFloatCast(FxExpression *x);
|
||||
~FxFloatCast();
|
||||
FxExpression *Resolve(FCompileContext&);
|
||||
|
||||
ExpVal EvalExpression (AActor *self);
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FxSign
|
||||
|
|
|
@ -488,6 +488,82 @@ ExpEmit FxFloatCast::Emit(VMFunctionBuilder *build)
|
|||
return to;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FxFloatCast::FxFloatCast(FxExpression *x)
|
||||
: FxExpression(x->ScriptPosition)
|
||||
{
|
||||
basex = x;
|
||||
ValueType = VAL_Float;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FxFloatCast::~FxFloatCast()
|
||||
{
|
||||
SAFE_DELETE(basex);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FxExpression *FxFloatCast::Resolve(FCompileContext &ctx)
|
||||
{
|
||||
CHECKRESOLVED();
|
||||
SAFE_RESOLVE(basex, ctx);
|
||||
|
||||
if (basex->ValueType == VAL_Float)
|
||||
{
|
||||
FxExpression *x = basex;
|
||||
basex = NULL;
|
||||
delete this;
|
||||
return x;
|
||||
}
|
||||
else if (basex->ValueType == VAL_Int)
|
||||
{
|
||||
if (basex->isConstant())
|
||||
{
|
||||
ExpVal constval = basex->EvalExpression(NULL);
|
||||
FxExpression *x = new FxConstant(constval.GetFloat(), ScriptPosition);
|
||||
delete this;
|
||||
return x;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "Numeric type expected");
|
||||
delete this;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
ExpVal FxFloatCast::EvalExpression (AActor *self)
|
||||
{
|
||||
ExpVal baseval = basex->EvalExpression(self);
|
||||
baseval.Float = baseval.GetFloat();
|
||||
baseval.Type = VAL_Float;
|
||||
return baseval;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue