diff options
author | George Marques <george@gmarqu.es> | 2021-09-01 16:01:39 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2021-09-01 16:06:30 -0300 |
commit | 3d135880572ae863b4de250bc2da8edac701c020 (patch) | |
tree | 60a34c4a383c460547126d260a410625365f5419 /modules/gdscript/gdscript_vm.cpp | |
parent | a160a95ea67455c80c55da8385220d5c75a0aa60 (diff) | |
download | redot-engine-3d135880572ae863b4de250bc2da8edac701c020.tar.gz |
GDScript: Fix loading of interdependent autoloads
Move the autoload resolution to runtime by loading it into the stack
with an extra instruction. This allows an autoload to use another
autoload singleton independent of load order.
Diffstat (limited to 'modules/gdscript/gdscript_vm.cpp')
-rw-r--r-- | modules/gdscript/gdscript_vm.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index 882256b7e3..64fd7eca8a 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -322,6 +322,7 @@ void (*type_init_function_table[])(Variant *) = { &&OPCODE_ITERATE_PACKED_VECTOR3_ARRAY, \ &&OPCODE_ITERATE_PACKED_COLOR_ARRAY, \ &&OPCODE_ITERATE_OBJECT, \ + &&OPCODE_STORE_GLOBAL, \ &&OPCODE_STORE_NAMED_GLOBAL, \ &&OPCODE_TYPE_ADJUST_BOOL, \ &&OPCODE_TYPE_ADJUST_INT, \ @@ -3116,6 +3117,18 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } DISPATCH_OPCODE; + OPCODE(OPCODE_STORE_GLOBAL) { + CHECK_SPACE(3); + int global_idx = _code_ptr[ip + 2]; + GD_ERR_BREAK(global_idx < 0 || global_idx >= GDScriptLanguage::get_singleton()->get_global_array_size()); + + GET_INSTRUCTION_ARG(dst, 0); + *dst = GDScriptLanguage::get_singleton()->get_global_array()[global_idx]; + + ip += 3; + } + DISPATCH_OPCODE; + OPCODE(OPCODE_STORE_NAMED_GLOBAL) { CHECK_SPACE(3); int globalname_idx = _code_ptr[ip + 2]; |