diff options
author | George Marques <george@gmarqu.es> | 2020-11-18 11:37:08 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2020-11-21 13:30:17 -0300 |
commit | 5518e2a68e36fe8a9dcf1531228a7b3cc4411263 (patch) | |
tree | d0790c288e54056f5a480d43fe88819535c1fa39 /modules/gdscript/gdscript_vm.cpp | |
parent | e0dca3c6b6f0a4dc0126c45873ff4c8c30e2d8a0 (diff) | |
download | redot-engine-5518e2a68e36fe8a9dcf1531228a7b3cc4411263.tar.gz |
GDScript: Add faster instruction for validated constructor
Only for built-in types.
Diffstat (limited to 'modules/gdscript/gdscript_vm.cpp')
-rw-r--r-- | modules/gdscript/gdscript_vm.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp index 04cd41ed6b..7c8bfcd944 100644 --- a/modules/gdscript/gdscript_vm.cpp +++ b/modules/gdscript/gdscript_vm.cpp @@ -214,6 +214,7 @@ String GDScriptFunction::_get_call_error(const Callable::CallError &p_err, const &&OPCODE_CAST_TO_NATIVE, \ &&OPCODE_CAST_TO_SCRIPT, \ &&OPCODE_CONSTRUCT, \ + &&OPCODE_CONSTRUCT_VALIDATED, \ &&OPCODE_CONSTRUCT_ARRAY, \ &&OPCODE_CONSTRUCT_DICTIONARY, \ &&OPCODE_CALL, \ @@ -1276,6 +1277,27 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } DISPATCH_OPCODE; + OPCODE(OPCODE_CONSTRUCT_VALIDATED) { + CHECK_SPACE(2 + instr_arg_count); + + ip += instr_arg_count; + + int argc = _code_ptr[ip + 1]; + + int constructor_idx = _code_ptr[ip + 2]; + GD_ERR_BREAK(constructor_idx < 0 || constructor_idx >= _constructors_count); + Variant::ValidatedConstructor constructor = _constructors_ptr[constructor_idx]; + + Variant **argptrs = instruction_args; + + GET_INSTRUCTION_ARG(dst, argc); + + constructor(*dst, (const Variant **)argptrs); + + ip += 3; + } + DISPATCH_OPCODE; + OPCODE(OPCODE_CONSTRUCT_ARRAY) { CHECK_SPACE(1 + instr_arg_count); ip += instr_arg_count; |