GDScript: Make sure calls don't use return when not needed
This commit is contained in:
parent
342c1bf1e2
commit
d36213bab8
@ -488,6 +488,9 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_expression);
|
||||
GDScriptDataType type = _gdtype_from_datatype(call->get_datatype());
|
||||
GDScriptCodeGenerator::Address result = codegen.add_temporary(type);
|
||||
GDScriptCodeGenerator::Address nil = GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::NIL);
|
||||
|
||||
GDScriptCodeGenerator::Address return_addr = p_root ? nil : result;
|
||||
|
||||
Vector<GDScriptCodeGenerator::Address> arguments;
|
||||
for (int i = 0; i < call->arguments.size(); i++) {
|
||||
@ -538,13 +541,13 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
if (within_await) {
|
||||
gen->write_call_async(result, self, call->function_name, arguments);
|
||||
} else {
|
||||
gen->write_call(result, self, call->function_name, arguments);
|
||||
gen->write_call(return_addr, self, call->function_name, arguments);
|
||||
}
|
||||
} else {
|
||||
if (within_await) {
|
||||
gen->write_call_self_async(result, call->function_name, arguments);
|
||||
} else {
|
||||
gen->write_call_self(result, call->function_name, arguments);
|
||||
gen->write_call_self(return_addr, call->function_name, arguments);
|
||||
}
|
||||
}
|
||||
} else if (callee->type == GDScriptParser::Node::SUBSCRIPT) {
|
||||
@ -579,12 +582,12 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||
gen->write_call_method_bind(result, base, method, arguments);
|
||||
}
|
||||
} else {
|
||||
gen->write_call(result, base, call->function_name, arguments);
|
||||
gen->write_call(return_addr, base, call->function_name, arguments);
|
||||
}
|
||||
} else if (base.type.has_type && base.type.kind == GDScriptDataType::BUILTIN) {
|
||||
gen->write_call_builtin_type(result, base, base.type.builtin_type, call->function_name, arguments);
|
||||
} else {
|
||||
gen->write_call(result, base, call->function_name, arguments);
|
||||
gen->write_call(return_addr, base, call->function_name, arguments);
|
||||
}
|
||||
if (base.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
|
||||
gen->pop_temporary();
|
||||
|
Loading…
Reference in New Issue
Block a user