summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_byte_codegen.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript_byte_codegen.h')
-rw-r--r--modules/gdscript/gdscript_byte_codegen.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_byte_codegen.h b/modules/gdscript/gdscript_byte_codegen.h
index 8aa02b86c4..1d1b22e196 100644
--- a/modules/gdscript/gdscript_byte_codegen.h
+++ b/modules/gdscript/gdscript_byte_codegen.h
@@ -48,6 +48,33 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator {
const static int RESERVED_STACK = 3; // For self, class, and nil.
+ struct CallTarget {
+ Address target;
+ bool is_new_temporary = false;
+ GDScriptByteCodeGenerator *codegen = nullptr;
+#ifdef DEV_ENABLED
+ bool cleaned = false;
+#endif
+
+ void cleanup() {
+ DEV_ASSERT(!cleaned);
+ if (is_new_temporary) {
+ codegen->pop_temporary();
+ }
+#ifdef DEV_ENABLED
+ cleaned = true;
+#endif
+ }
+
+ CallTarget(Address p_target, bool p_is_new_temporary, GDScriptByteCodeGenerator *p_codegen) :
+ target(p_target),
+ is_new_temporary(p_is_new_temporary),
+ codegen(p_codegen) {}
+ ~CallTarget() { DEV_ASSERT(cleaned); }
+ CallTarget(const CallTarget &) = delete;
+ CallTarget &operator=(CallTarget &) = delete;
+ };
+
bool ended = false;
GDScriptFunction *function = nullptr;
bool debug_stack = false;
@@ -326,7 +353,7 @@ class GDScriptByteCodeGenerator : public GDScriptCodeGenerator {
}
}
- Address get_call_target(const Address &p_target, Variant::Type p_type = Variant::NIL);
+ CallTarget get_call_target(const Address &p_target, Variant::Type p_type = Variant::NIL);
int address_of(const Address &p_address) {
switch (p_address.mode) {