From a862f728b6720f36c01885149e14109cffd47e83 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 25 Feb 2016 09:39:35 -0600 Subject: [PATCH] Add remaining VM-supported floating point operations to DECORATE - These are: * exp * log * log10 * ceil * floor * acos * asin * atan * tan * cosh * sinh * tanh --- src/namedef.h | 10 ++++++++++ src/thingdef/thingdef_expression.cpp | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/namedef.h b/src/namedef.h index 83f4aca9b..5478349e6 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -284,8 +284,18 @@ xx(FRandom) xx(Random2) xx(RandomPick) xx(FRandomPick) +xx(Exp) +xx(Log10) +xx(Ceil) +xx(ACos) +xx(ASin) +xx(ATan) xx(Cos) xx(Sin) +xx(Tan) +xx(CosH) +xx(SinH) +xx(TanH) xx(Alpha) xx(Angle) xx(Args) diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 7d18bce59..2ac41f7a8 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -65,9 +65,23 @@ struct FLOP // degrees to radians for those that work with angles. static const FLOP FxFlops[] = { + { NAME_Exp, FLOP_EXP, [](double v) { return exp(v); } }, + { NAME_Log, FLOP_LOG, [](double v) { return log(v); } }, + { NAME_Log10, FLOP_LOG10, [](double v) { return log10(v); } }, { NAME_Sqrt, FLOP_SQRT, [](double v) { return sqrt(v); } }, + { NAME_Ceil, FLOP_CEIL, [](double v) { return ceil(v); } }, + { NAME_Floor, FLOP_FLOOR, [](double v) { return floor(v); } }, + + { NAME_ACos, FLOP_ACOS_DEG, [](double v) { return acos(v) * (180.0 / M_PI); } }, + { NAME_ASin, FLOP_ASIN_DEG, [](double v) { return asin(v) * (180.0 / M_PI); } }, + { NAME_ATan, FLOP_ATAN_DEG, [](double v) { return atan(v) * (180.0 / M_PI); } }, { NAME_Cos, FLOP_COS_DEG, [](double v) { return cos(v * (M_PI / 180.0)); } }, { NAME_Sin, FLOP_SIN_DEG, [](double v) { return sin(v * (M_PI / 180.0)); } }, + { NAME_Tan, FLOP_TAN_DEG, [](double v) { return tan(v * (M_PI / 180.0)); } }, + + { NAME_CosH, FLOP_COSH, [](double v) { return cosh(v); } }, + { NAME_SinH, FLOP_SINH, [](double v) { return sinh(v); } }, + { NAME_TanH, FLOP_TANH, [](double v) { return tanh(v); } }, }; ExpEmit::ExpEmit(VMFunctionBuilder *build, int type) @@ -3162,8 +3176,6 @@ FxFunctionCall::~FxFunctionCall() FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx) { - // There's currently only 3 global functions. - // If this changes later, it won't be here! for (int i = 0; i < countof(FxFlops); ++i) { if (MethodName == FxFlops[i].Name)