mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
GDScript: Use analyzer data to decide assignment conversion
Since there might be tricky cases in the analyzer (in the case of unsafe lines) which would need to be properly checked again. Instead, this splits the code generator in two functions and use information set by the analyzer to tell which function to use, without a need to re-check.
This commit is contained in:
parent
313e1f62bb
commit
c7459e3855
6 changed files with 74 additions and 51 deletions
|
|
@ -543,6 +543,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
|
|||
} else {
|
||||
// TODO: Add warning.
|
||||
mark_node_unsafe(member.variable->initializer);
|
||||
member.variable->use_conversion_assign = true;
|
||||
}
|
||||
} else if (datatype.builtin_type == Variant::INT && member.variable->initializer->get_datatype().builtin_type == Variant::FLOAT) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
|
@ -552,6 +553,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
|
|||
if (member.variable->initializer->get_datatype().is_variant()) {
|
||||
// TODO: Warn unsafe assign.
|
||||
mark_node_unsafe(member.variable->initializer);
|
||||
member.variable->use_conversion_assign = true;
|
||||
}
|
||||
}
|
||||
} else if (member.variable->infer_datatype) {
|
||||
|
|
@ -1145,6 +1147,7 @@ void GDScriptAnalyzer::resolve_variable(GDScriptParser::VariableNode *p_variable
|
|||
} else {
|
||||
// TODO: Add warning.
|
||||
mark_node_unsafe(p_variable->initializer);
|
||||
p_variable->use_conversion_assign = true;
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
} else if (type.builtin_type == Variant::INT && p_variable->initializer->get_datatype().builtin_type == Variant::FLOAT) {
|
||||
|
|
@ -1154,6 +1157,7 @@ void GDScriptAnalyzer::resolve_variable(GDScriptParser::VariableNode *p_variable
|
|||
if (p_variable->initializer->get_datatype().is_variant()) {
|
||||
// TODO: Warn unsafe assign.
|
||||
mark_node_unsafe(p_variable->initializer);
|
||||
p_variable->use_conversion_assign = true;
|
||||
}
|
||||
}
|
||||
} else if (p_variable->infer_datatype) {
|
||||
|
|
@ -1608,10 +1612,12 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
|
|||
} else {
|
||||
// TODO: Add warning.
|
||||
mark_node_unsafe(p_assignment);
|
||||
p_assignment->use_conversion_assign = true;
|
||||
}
|
||||
} else {
|
||||
// TODO: Warning in this case.
|
||||
mark_node_unsafe(p_assignment);
|
||||
p_assignment->use_conversion_assign = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1621,6 +1627,9 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
|
|||
|
||||
if (assignee_type.has_no_type() || assigned_value_type.is_variant()) {
|
||||
mark_node_unsafe(p_assignment);
|
||||
if (assignee_type.is_hard_type()) {
|
||||
p_assignment->use_conversion_assign = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_assignment->assignee->type == GDScriptParser::Node::IDENTIFIER) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue