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

Method resolve_class_interface

modules/gdscript/gdscript_analyzer.cpp:1274–1349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1272}
1273
1274void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_class, const GDScriptParser::Node *p_source) {
1275 if (p_source == nullptr && parser->has_class(p_class)) {
1276 p_source = p_class;
1277 }
1278
1279 Ref<GDScriptParserRef> parser_ref = ensure_cached_external_parser_for_class(p_class, nullptr, "Trying to resolve class interface", p_source);
1280
1281 if (!p_class->resolved_interface) {
1282#ifdef DEBUG_ENABLED
1283 bool has_static_data = p_class->has_static_data;
1284#endif // DEBUG_ENABLED
1285
1286 if (!parser->has_class(p_class)) {
1287 if (parser_ref.is_null()) {
1288 // Error already pushed.
1289 return;
1290 }
1291
1292 Error err = parser_ref->raise_status(GDScriptParserRef::PARSED);
1293 if (err) {
1294 push_error(vformat(R"(Could not parse script "%s": %s.)", p_class->get_datatype().script_path, error_names[err]), p_source);
1295 return;
1296 }
1297
1298 GDScriptAnalyzer *other_analyzer = parser_ref->get_analyzer();
1299 GDScriptParser *other_parser = parser_ref->get_parser();
1300
1301 int error_count = other_parser->errors.size();
1302 other_analyzer->resolve_class_interface(p_class);
1303 if (other_parser->errors.size() > error_count) {
1304 push_error(vformat(R"(Could not resolve class "%s".)", p_class->fqcn), p_source);
1305 return;
1306 }
1307
1308 return;
1309 }
1310
1311 p_class->resolved_interface = true;
1312
1313 if (resolve_class_inheritance(p_class) != OK) {
1314 return;
1315 }
1316
1317 GDScriptParser::DataType base_type = p_class->base_type;
1318 if (base_type.kind == GDScriptParser::DataType::CLASS) {
1319 GDScriptParser::ClassNode *base_class = base_type.class_type;
1320 resolve_class_interface(base_class, p_class);
1321 }
1322
1323 for (int i = 0; i < p_class->members.size(); i++) {
1324 resolve_class_member(p_class, i);
1325
1326#ifdef DEBUG_ENABLED
1327 if (!has_static_data) {
1328 GDScriptParser::ClassNode::Member member = p_class->members[i];
1329 if (member.type == GDScriptParser::ClassNode::Member::CLASS) {
1330 has_static_data = member.m_class->has_static_data;
1331 }

Callers

nothing calls this directly

Calls 9

vformatFunction · 0.85
raise_statusMethod · 0.80
get_analyzerMethod · 0.80
sizeMethod · 0.65
has_classMethod · 0.45
is_nullMethod · 0.45
get_datatypeMethod · 0.45
get_parserMethod · 0.45
push_warningMethod · 0.45

Tested by

no test coverage detected