mirror of
https://github.com/godotengine/godot.git
synced 2025-10-25 10:44:26 +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
|
|
@ -1084,7 +1084,11 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
|||
gen->write_call(GDScriptCodeGenerator::Address(), GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::SELF), setter_function, args);
|
||||
} else {
|
||||
// Just assign.
|
||||
gen->write_assign(target, op_result);
|
||||
if (assignment->use_conversion_assign) {
|
||||
gen->write_assign_with_conversion(target, op_result);
|
||||
} else {
|
||||
gen->write_assign(target, op_result);
|
||||
}
|
||||
}
|
||||
|
||||
if (op_result.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
|
||||
|
|
@ -1792,7 +1796,11 @@ Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::Sui
|
|||
if (error) {
|
||||
return error;
|
||||
}
|
||||
gen->write_assign(local, src_address);
|
||||
if (lv->use_conversion_assign) {
|
||||
gen->write_assign_with_conversion(local, src_address);
|
||||
} else {
|
||||
gen->write_assign(local, src_address);
|
||||
}
|
||||
if (src_address.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
|
||||
codegen.generator->pop_temporary();
|
||||
}
|
||||
|
|
@ -1930,7 +1938,11 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
codegen.generator->write_assign(dst_address, src_address);
|
||||
if (field->use_conversion_assign) {
|
||||
codegen.generator->write_assign_with_conversion(dst_address, src_address);
|
||||
} else {
|
||||
codegen.generator->write_assign(dst_address, src_address);
|
||||
}
|
||||
if (src_address.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
|
||||
codegen.generator->pop_temporary();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue