diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gd_function.cpp | 25 | ||||
-rw-r--r-- | modules/gdscript/gd_function.h | 3 | ||||
-rw-r--r-- | modules/gdscript/gd_parser.cpp | 9 | ||||
-rw-r--r-- | modules/gdscript/gd_script.h | 2 |
4 files changed, 39 insertions, 0 deletions
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 6e52686de4..de86eb2ab9 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -846,6 +846,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a gdfs->state._class=_class; gdfs->state.ip=ip+ipofs; gdfs->state.line=line; + gdfs->state.instance_id=(p_instance && p_instance->get_owner())?p_instance->get_owner()->get_instance_ID():0; + gdfs->state.script_id=_class->get_instance_ID(); //gdfs->state.result_pos=ip+ipofs-1; gdfs->state.defarg=defarg; gdfs->state.instance=p_instance; @@ -1352,6 +1354,18 @@ GDFunction::~GDFunction() { Variant GDFunctionState::_signal_callback(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { +#ifdef DEBUG_ENABLED + if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) { + ERR_EXPLAIN("Resumed after yield, but class instance is gone"); + ERR_FAIL_V(Variant()); + } + + if (state.script_id && !ObjectDB::get_instance(state.script_id)) { + ERR_EXPLAIN("Resumed after yield, but script is gone"); + ERR_FAIL_V(Variant()); + } +#endif + Variant arg; r_error.error=Variant::CallError::CALL_OK; @@ -1398,6 +1412,17 @@ bool GDFunctionState::is_valid() const { Variant GDFunctionState::resume(const Variant& p_arg) { ERR_FAIL_COND_V(!function,Variant()); +#ifdef DEBUG_ENABLED + if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) { + ERR_EXPLAIN("Resumed after yield, but class instance is gone"); + ERR_FAIL_V(Variant()); + } + + if (state.script_id && !ObjectDB::get_instance(state.script_id)) { + ERR_EXPLAIN("Resumed after yield, but script is gone"); + ERR_FAIL_V(Variant()); + } +#endif state.result=p_arg; Variant::CallError err; diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h index 942db170c8..e09c6509dd 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gd_function.h @@ -136,6 +136,9 @@ public: struct CallState { + ObjectID instance_id; //by debug only + ObjectID script_id; + GDInstance *instance; Vector<uint8_t> stack; int stack_size; diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index e83bd3d21e..6c6560efa6 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -31,6 +31,7 @@ #include "io/resource_loader.h" #include "os/file_access.h" #include "script_language.h" +#include "gd_script.h" template<class T> T* GDParser::alloc_node() { @@ -494,6 +495,14 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ } } + if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) { + //check from constants + ConstantNode *constant = alloc_node<ConstantNode>(); + constant->value = GDScriptLanguage::get_singleton()->get_global_array()[ GDScriptLanguage::get_singleton()->get_global_map()[identifier] ]; + expr=constant; + bfn = true; + } + if ( !bfn ) { IdentifierNode *id = alloc_node<IdentifierNode>(); id->name = identifier; diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 166e29ad70..723761c3a9 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -202,6 +202,8 @@ friend class GDCompiler; public: + _FORCE_INLINE_ Object* get_owner() { return owner; } + virtual bool set(const StringName& p_name, const Variant& p_value); virtual bool get(const StringName& p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; |