From 27cb75112ed3a6b98a1edfefe3c419fbe20d6337 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 16 May 2015 16:32:46 -0300 Subject: -bit slower execution in debug, but proper error reporting for get index and operators, fixes #1911 --- modules/gdscript/gd_script.cpp | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index e260f70a91..48269f4490 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -335,17 +335,26 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a GET_VARIANT_PTR(b,3); GET_VARIANT_PTR(dst,4); +#ifdef DEBUG_ENABLED + Variant ret; + Variant::evaluate(op,*a,*b,ret,valid); +#else Variant::evaluate(op,*a,*b,*dst,valid); +#endif + if (!valid) { - if (dst->get_type()==Variant::STRING) { + if (ret.get_type()==Variant::STRING) { //return a string when invalid with the error - err_text=*dst; + err_text=ret; err_text += " in operator '"+Variant::get_operator_name(op)+"'."; } else { err_text="Invalid operands '"+Variant::get_type_name(a->get_type())+"' and '"+Variant::get_type_name(b->get_type())+"' in operator '"+Variant::get_operator_name(op)+"'."; } break; } +#ifdef DEBUG_ENABLED + *dst=ret; +#endif ip+=5; @@ -457,8 +466,13 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a GET_VARIANT_PTR(dst,3); bool valid; +#ifdef DEBUG_ENABLED +//allow better error message in cases where src and dst are the same stack position + Variant ret = src->get(*index,&valid); +#else *dst = src->get(*index,&valid); +#endif if (!valid) { String v = index->operator String(); if (v!="") { @@ -469,6 +483,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a err_text="Invalid get index "+v+" (on base: '"+_get_var_type(src)+"')."; break; } +#ifdef DEBUG_ENABLED + *dst=ret; +#endif ip+=4; } continue; case OPCODE_SET_NAMED: { @@ -508,7 +525,13 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a const StringName *index = &_global_names_ptr[indexname]; bool valid; +#ifdef DEBUG_ENABLED +//allow better error message in cases where src and dst are the same stack position + Variant ret = src->get_named(*index,&valid); + +#else *dst = src->get_named(*index,&valid); +#endif if (!valid) { if (src->has_method(*index)) { @@ -518,7 +541,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } break; } - +#ifdef DEBUG_ENABLED + *dst=ret; +#endif ip+=4; } continue; case OPCODE_ASSIGN: { -- cgit v1.2.3 From e72717e3738ea7fe1a2a6c9447ad0090bdf297ec Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 17 May 2015 13:11:55 -0300 Subject: properly save external resources, fixes #1924 added API to get scancode names to OS --- modules/gdscript/gd_script.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 48269f4490..c9b00f49ac 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -343,6 +343,8 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a #endif if (!valid) { +#ifdef DEBUG_ENABLED + if (ret.get_type()==Variant::STRING) { //return a string when invalid with the error err_text=ret; @@ -350,7 +352,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } else { err_text="Invalid operands '"+Variant::get_type_name(a->get_type())+"' and '"+Variant::get_type_name(b->get_type())+"' in operator '"+Variant::get_operator_name(op)+"'."; } +#endif break; + } #ifdef DEBUG_ENABLED *dst=ret; -- cgit v1.2.3 From e323cc050564fdb1b5cf81793d173cbd9483f55a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 18 May 2015 10:20:54 -0300 Subject: -Rename unexisting by nonexistant, closes #1940 -Added function to retrieve list of actions fron InputMap --- modules/gdscript/gd_script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gdscript/gd_script.cpp') diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index c9b00f49ac..ceca1ff2b9 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -140,7 +140,7 @@ String GDFunction::_get_call_error(const Variant::CallError& p_err, const String } else if (p_err.error==Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) { err_text="Invalid call to "+p_where+". Expected "+itos(p_err.argument)+" arguments."; } else if (p_err.error==Variant::CallError::CALL_ERROR_INVALID_METHOD) { - err_text="Invalid call. Unexisting "+p_where+"."; + err_text="Invalid call. Nonexistent "+p_where+"."; } else if (p_err.error==Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) { err_text="Attempt to call "+p_where+" on a null instance."; } else { -- cgit v1.2.3