From 511a4b761c3b5bf565f6e580fc9774a99e72a53e Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 27 Jun 2022 12:09:51 -0300 Subject: GDScript: Fix setter being called in chains for shared types When a type is shared (i.e. passed by reference) it doesn't need to be called in a setter chain (e.g. `a.b.c = 0`) since it will be updated in place. This commit adds an instruction that jumps when the value is shared so it can be used to skip those cases and avoid redundant calls of setters. It also solves issues when assigning to sub-properties of read-only properties. --- modules/gdscript/gdscript_codegen.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/gdscript/gdscript_codegen.h') diff --git a/modules/gdscript/gdscript_codegen.h b/modules/gdscript/gdscript_codegen.h index 326b66a295..81fa265aca 100644 --- a/modules/gdscript/gdscript_codegen.h +++ b/modules/gdscript/gdscript_codegen.h @@ -140,6 +140,8 @@ public: virtual void write_if(const Address &p_condition) = 0; virtual void write_else() = 0; virtual void write_endif() = 0; + virtual void write_jump_if_shared(const Address &p_value) = 0; + virtual void write_end_jump_if_shared() = 0; virtual void start_for(const GDScriptDataType &p_iterator_type, const GDScriptDataType &p_list_type) = 0; virtual void write_for_assignment(const Address &p_variable, const Address &p_list) = 0; virtual void write_for() = 0; -- cgit v1.2.3