diff options
Diffstat (limited to 'core/math/expression.h')
-rw-r--r-- | core/math/expression.h | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/core/math/expression.h b/core/math/expression.h index c5b9d79a16..f2cfe6b1a6 100644 --- a/core/math/expression.h +++ b/core/math/expression.h @@ -63,7 +63,6 @@ public: MATH_ISNAN, MATH_ISINF, MATH_EASE, - MATH_DECIMALS, MATH_STEP_DECIMALS, MATH_STEPIFY, MATH_LERP, @@ -112,30 +111,27 @@ public: static int get_func_argument_count(BuiltinFunc p_func); static String get_func_name(BuiltinFunc p_func); - static void exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Variant::CallError &r_error, String &r_error_str); + static void exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Callable::CallError &r_error, String &r_error_str); static BuiltinFunc find_function(const String &p_string); private: static const char *func_name[FUNC_MAX]; struct Input { - - Variant::Type type; + Variant::Type type = Variant::NIL; String name; - Input() : - type(Variant::NIL) { - } + Input() {} }; Vector<Input> inputs; - Variant::Type output_type; + Variant::Type output_type = Variant::NIL; String expression; - bool sequenced; - int str_ofs; - bool expression_dirty; + bool sequenced = false; + int str_ofs = 0; + bool expression_dirty = false; bool _compile_expression(); @@ -183,14 +179,14 @@ private: static const char *token_name[TK_MAX]; struct Token { - TokenType type; Variant value; }; void _set_error(const String &p_err) { - if (error_set) + if (error_set) { return; + } error_str = p_err; error_set = true; } @@ -198,10 +194,9 @@ private: Error _get_token(Token &r_token); String error_str; - bool error_set; + bool error_set = true; struct ENode { - enum Type { TYPE_INPUT, TYPE_CONSTANT, @@ -216,11 +211,11 @@ private: TYPE_CALL }; - ENode *next; + ENode *next = nullptr; Type type; - ENode() { next = NULL; } + ENode() {} virtual ~ENode() { if (next) { memdelete(next); @@ -229,7 +224,6 @@ private: }; struct ExpressionNode { - bool is_op; union { Variant::Operator op; @@ -240,7 +234,6 @@ private: ENode *_parse_expression(); struct InputNode : public ENode { - int index; InputNode() { type = TYPE_INPUT; @@ -248,7 +241,6 @@ private: }; struct ConstantNode : public ENode { - Variant value; ConstantNode() { type = TYPE_CONSTANT; @@ -256,7 +248,6 @@ private: }; struct OperatorNode : public ENode { - Variant::Operator op; ENode *nodes[2]; @@ -267,7 +258,6 @@ private: }; struct SelfNode : public ENode { - SelfNode() { type = TYPE_SELF; } @@ -340,12 +330,12 @@ private: return node; } - ENode *root; - ENode *nodes; + ENode *root = nullptr; + ENode *nodes = nullptr; Vector<String> input_names; - bool execution_error; + bool execution_error = false; bool _execute(const Array &p_inputs, Object *p_instance, Expression::ENode *p_node, Variant &r_ret, String &r_error_str); protected: @@ -353,11 +343,11 @@ protected: public: Error parse(const String &p_expression, const Vector<String> &p_input_names = Vector<String>()); - Variant execute(Array p_inputs, Object *p_base = NULL, bool p_show_error = true); + Variant execute(Array p_inputs = Array(), Object *p_base = nullptr, bool p_show_error = true); bool has_execute_failed() const; String get_error_text() const; - Expression(); + Expression() {} ~Expression(); }; |