You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Avoid GDScript bookkeeping from referencing objects longer than necessary
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user