diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-01 09:55:04 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-05-01 09:55:04 +0200 |
| commit | 731ea17dd4bc18ceccef14924a9db2eb57058b2d (patch) | |
| tree | 38088edd87a4e4123d65adcdd1f119580c304525 /modules/gdscript/gdscript_compiler.cpp | |
| parent | f89de7ab435c8fdc5c5666d9678e5566e952ed6d (diff) | |
| parent | 7ca038effa28c1767e43e4f66d2bd9f34852d5b7 (diff) | |
| download | redot-engine-731ea17dd4bc18ceccef14924a9db2eb57058b2d.tar.gz | |
Merge pull request #91192 from vnen/gdscript-validated-native-static-calls
GDScript: Perform validated calls with static methods
Diffstat (limited to 'modules/gdscript/gdscript_compiler.cpp')
| -rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 734e37bc09..a8a7f3d9f7 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -673,7 +673,15 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code } else if (!call->is_super && subscript->base->type == GDScriptParser::Node::IDENTIFIER && call->function_name != SNAME("new") && ClassDB::class_exists(static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name) && !Engine::get_singleton()->has_singleton(static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name)) { // It's a static native method call. - gen->write_call_native_static(result, static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name, subscript->attribute->name, arguments); + StringName class_name = static_cast<GDScriptParser::IdentifierNode *>(subscript->base)->name; + MethodBind *method = ClassDB::get_method(class_name, subscript->attribute->name); + if (_can_use_validate_call(method, arguments)) { + // Exact arguments, use validated call. + gen->write_call_native_static_validated(result, method, arguments); + } else { + // Not exact arguments, use regular static call + gen->write_call_native_static(result, class_name, subscript->attribute->name, arguments); + } } else { GDScriptCodeGenerator::Address base = _parse_expression(codegen, r_error, subscript->base); if (r_error) { |
