diff options
Diffstat (limited to 'modules/gdscript/gdscript_function.h')
-rw-r--r-- | modules/gdscript/gdscript_function.h | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h index 34019e563d..583eab744a 100644 --- a/modules/gdscript/gdscript_function.h +++ b/modules/gdscript/gdscript_function.h @@ -43,20 +43,25 @@ class GDScriptInstance; class GDScript; struct GDScriptDataType { - bool has_type; - enum { + enum Kind { UNINITIALIZED, BUILTIN, NATIVE, SCRIPT, GDSCRIPT, - } kind; - Variant::Type builtin_type; + }; + + Kind kind = UNINITIALIZED; + + bool has_type = false; + Variant::Type builtin_type = Variant::NIL; StringName native_type; Ref<Script> script_type; bool is_type(const Variant &p_variant, bool p_allow_implicit_conversion = false) const { - if (!has_type) return true; // Can't type check + if (!has_type) { + return true; // Can't type check + } switch (kind) { case UNINITIALIZED: @@ -105,7 +110,7 @@ struct GDScriptDataType { return false; } - Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : NULL; + Ref<Script> base = obj && obj->get_script_instance() ? obj->get_script_instance()->get_script() : nullptr; bool valid = false; while (base.is_valid()) { if (base == script_type) { @@ -146,10 +151,7 @@ struct GDScriptDataType { return info; } - GDScriptDataType() : - has_type(false), - kind(UNINITIALIZED), - builtin_type(Variant::NIL) {} + GDScriptDataType() {} }; class GDScriptFunction { @@ -214,7 +216,6 @@ public: }; struct StackDebug { - int line; int pos; bool added; @@ -292,14 +293,16 @@ private: public: struct CallState { - - ObjectID instance_id; + GDScript *script; GDScriptInstance *instance; +#ifdef DEBUG_ENABLED + StringName function_name; + String script_path; +#endif Vector<uint8_t> stack; int stack_size; Variant self; uint32_t alloca_size; - Ref<GDScript> script; int ip; int line; int defarg; @@ -321,7 +324,7 @@ public: GDScript *get_script() const { return _script; } StringName get_source() const { return source; } - void debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const; + void debug_get_stack_member_state(int p_line, List<Pair<StringName, int>> *r_stackvars) const; _FORCE_INLINE_ bool is_empty() const { return _code_size == 0; } @@ -339,7 +342,7 @@ public: return default_arguments[p_idx]; } - Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state = NULL); + Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Callable::CallError &r_err, CallState *p_state = nullptr); _FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const { return rpc_mode; } GDScriptFunction(); @@ -347,7 +350,6 @@ public: }; class GDScriptFunctionState : public Reference { - GDCLASS(GDScriptFunctionState, Reference); friend class GDScriptFunction; GDScriptFunction *function; @@ -355,12 +357,18 @@ class GDScriptFunctionState : public Reference { Variant _signal_callback(const Variant **p_args, int p_argcount, Callable::CallError &r_error); Ref<GDScriptFunctionState> first_state; + SelfList<GDScriptFunctionState> scripts_list; + SelfList<GDScriptFunctionState> instances_list; + protected: static void _bind_methods(); public: bool is_valid(bool p_extended_check = false) const; Variant resume(const Variant &p_arg = Variant()); + + void _clear_stack(); + GDScriptFunctionState(); ~GDScriptFunctionState(); }; |