diff options
author | George Marques <george@gmarqu.es> | 2021-05-16 11:48:53 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2021-05-16 11:54:33 -0300 |
commit | ec783dd885a67467691ef3e55ca0d05151205c4c (patch) | |
tree | 11af7a6fa2f744d4e56cd737b458c910ccdf1c5c /modules/gdscript/gdscript_analyzer.cpp | |
parent | 6e621441ca0e562fb010c86d88e1d3a8a9ed0fd8 (diff) | |
download | redot-engine-ec783dd885a67467691ef3e55ca0d05151205c4c.tar.gz |
GDScript: Add support for builtin static method calls
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 17ae52f3ab..7b04959227 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2078,9 +2078,23 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa mark_node_unsafe(p_call); return; } - reduce_expression(subscript->base); + if (subscript->attribute == nullptr) { + // Invalid call. Error already sent in parser. + p_call->set_datatype(call_type); + mark_node_unsafe(p_call); + return; + } - base_type = subscript->base->get_datatype(); + GDScriptParser::IdentifierNode *base_id = nullptr; + if (subscript->base->type == GDScriptParser::Node::IDENTIFIER) { + base_id = static_cast<GDScriptParser::IdentifierNode *>(subscript->base); + } + if (base_id && GDScriptParser::get_builtin_type(base_id->name) < Variant::VARIANT_MAX) { + base_type = make_builtin_meta_type(GDScriptParser::get_builtin_type(base_id->name)); + } else { + reduce_expression(subscript->base); + base_type = subscript->base->get_datatype(); + } } else { // Invalid call. Error already sent in parser. // TODO: Could check if Callable here too. |