MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / can_reference

Method can_reference

modules/gdscript/gdscript_parser.cpp:5464–5506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5462}
5463
5464bool GDScriptParser::DataType::can_reference(const GDScriptParser::DataType &p_other) const {
5465 if (p_other.is_meta_type) {
5466 return false;
5467 } else if (builtin_type != p_other.builtin_type) {
5468 return false;
5469 } else if (builtin_type != Variant::OBJECT) {
5470 return true;
5471 }
5472
5473 if (native_type == StringName()) {
5474 return true;
5475 } else if (p_other.native_type == StringName()) {
5476 return false;
5477 } else if (native_type != p_other.native_type && !ClassDB::is_parent_class(p_other.native_type, native_type)) {
5478 return false;
5479 }
5480
5481 Ref<Script> script = script_type;
5482 if (kind == GDScriptParser::DataType::CLASS && script.is_null()) {
5483 Error err = OK;
5484 Ref<GDScript> scr = GDScriptCache::get_shallow_script(script_path, err);
5485 ERR_FAIL_COND_V_MSG(err, false, vformat(R"(Error while getting cache for script "%s".)", script_path));
5486 script.reference_ptr(scr->find_class(class_type->fqcn));
5487 }
5488
5489 Ref<Script> script_other = p_other.script_type;
5490 if (p_other.kind == GDScriptParser::DataType::CLASS && script_other.is_null()) {
5491 Error err = OK;
5492 Ref<GDScript> scr = GDScriptCache::get_shallow_script(p_other.script_path, err);
5493 ERR_FAIL_COND_V_MSG(err, false, vformat(R"(Error while getting cache for script "%s".)", p_other.script_path));
5494 script_other.reference_ptr(scr->find_class(p_other.class_type->fqcn));
5495 }
5496
5497 if (script.is_null()) {
5498 return true;
5499 } else if (script_other.is_null()) {
5500 return false;
5501 } else if (script != script_other && !script_other->inherits_script(script)) {
5502 return false;
5503 }
5504
5505 return true;
5506}
5507
5508void GDScriptParser::complete_extents(Node *p_node) {
5509 while (!nodes_in_progress.is_empty() && nodes_in_progress.back()->get() != p_node) {

Callers 1

reduce_subscriptMethod · 0.45

Calls 6

vformatFunction · 0.85
reference_ptrMethod · 0.80
StringNameClass · 0.50
is_nullMethod · 0.45
find_classMethod · 0.45
inherits_scriptMethod · 0.45

Tested by

no test coverage detected