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

Method resolve_assert

modules/gdscript/gdscript_analyzer.cpp:2390–2410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2388}
2389
2390void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) {
2391 reduce_expression(p_assert->condition);
2392 if (p_assert->message != nullptr) {
2393 reduce_expression(p_assert->message);
2394 if (!p_assert->message->get_datatype().has_no_type() && (p_assert->message->get_datatype().kind != GDScriptParser::DataType::BUILTIN || p_assert->message->get_datatype().builtin_type != Variant::STRING)) {
2395 push_error(R"(Expected string for assert error message.)", p_assert->message);
2396 }
2397 }
2398
2399 p_assert->set_datatype(p_assert->condition->get_datatype());
2400
2401#ifdef DEBUG_ENABLED
2402 if (p_assert->condition->is_constant) {
2403 if (p_assert->condition->reduced_value.booleanize()) {
2404 parser->push_warning(p_assert->condition, GDScriptWarning::ASSERT_ALWAYS_TRUE);
2405 } else if (!(p_assert->condition->type == GDScriptParser::Node::LITERAL && static_cast<GDScriptParser::LiteralNode *>(p_assert->condition)->value.get_type() == Variant::BOOL)) {
2406 parser->push_warning(p_assert->condition, GDScriptWarning::ASSERT_ALWAYS_FALSE);
2407 }
2408 }
2409#endif // DEBUG_ENABLED
2410}
2411
2412void GDScriptAnalyzer::resolve_match(GDScriptParser::MatchNode *p_match) {
2413 reduce_expression(p_match->test);

Callers

nothing calls this directly

Calls 6

has_no_typeMethod · 0.80
set_datatypeMethod · 0.80
booleanizeMethod · 0.80
get_datatypeMethod · 0.45
push_warningMethod · 0.45
get_typeMethod · 0.45

Tested by

no test coverage detected