mirror of
https://github.com/godotengine/godot.git
synced 2024-12-09 10:09:20 +08:00
false positive "Identifier not found" error or signals fixed
This commit is contained in:
parent
e1e52b3736
commit
9869522e6a
@ -255,6 +255,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
}
|
||||
|
||||
// Try class constants.
|
||||
{
|
||||
GDScript *owner = codegen.script;
|
||||
while (owner) {
|
||||
GDScript *scr = owner;
|
||||
@ -280,8 +281,10 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
|
||||
owner = owner->_owner;
|
||||
}
|
||||
}
|
||||
|
||||
// Try signals and methods (can be made callables);
|
||||
// Try signals and methods (can be made callables).
|
||||
{
|
||||
if (codegen.class_node->members_indices.has(identifier)) {
|
||||
const GDScriptParser::ClassNode::Member &member = codegen.class_node->members[codegen.class_node->members_indices[identifier]];
|
||||
if (member.type == GDScriptParser::ClassNode::Member::FUNCTION || member.type == GDScriptParser::ClassNode::Member::SIGNAL) {
|
||||
@ -294,6 +297,26 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
}
|
||||
}
|
||||
|
||||
// Try in native base.
|
||||
GDScript *scr = codegen.script;
|
||||
GDScriptNativeClass *nc = nullptr;
|
||||
while (scr) {
|
||||
if (scr->native.is_valid()) {
|
||||
nc = scr->native.ptr();
|
||||
}
|
||||
scr = scr->_base;
|
||||
}
|
||||
|
||||
if (nc && (ClassDB::has_signal(nc->get_name(), identifier) || ClassDB::has_method(nc->get_name(), identifier))) {
|
||||
// Get like it was a property.
|
||||
GDScriptCodeGenerator::Address temp = codegen.add_temporary(); // TODO: Get type here.
|
||||
GDScriptCodeGenerator::Address self(GDScriptCodeGenerator::Address::SELF);
|
||||
|
||||
gen->write_get_named(temp, identifier, self);
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
|
||||
if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
|
||||
int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier];
|
||||
return GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::GLOBAL, idx); // TODO: Get type.
|
||||
|
Loading…
Reference in New Issue
Block a user