GDScript: Make sure calls don't use return when not needed
This commit is contained in:
parent
342c1bf1e2
commit
d36213bab8
1 changed files with 7 additions and 4 deletions
|
@ -488,6 +488,9 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||||
const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_expression);
|
const GDScriptParser::CallNode *call = static_cast<const GDScriptParser::CallNode *>(p_expression);
|
||||||
GDScriptDataType type = _gdtype_from_datatype(call->get_datatype());
|
GDScriptDataType type = _gdtype_from_datatype(call->get_datatype());
|
||||||
GDScriptCodeGenerator::Address result = codegen.add_temporary(type);
|
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;
|
Vector<GDScriptCodeGenerator::Address> arguments;
|
||||||
for (int i = 0; i < call->arguments.size(); i++) {
|
for (int i = 0; i < call->arguments.size(); i++) {
|
||||||
|
@ -538,13 +541,13 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
||||||
if (within_await) {
|
if (within_await) {
|
||||||
gen->write_call_async(result, self, call->function_name, arguments);
|
gen->write_call_async(result, self, call->function_name, arguments);
|
||||||
} else {
|
} else {
|
||||||
gen->write_call(result, self, call->function_name, arguments);
|
gen->write_call(return_addr, self, call->function_name, arguments);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (within_await) {
|
if (within_await) {
|
||||||
gen->write_call_self_async(result, call->function_name, arguments);
|
gen->write_call_self_async(result, call->function_name, arguments);
|
||||||
} else {
|
} 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) {
|
} 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);
|
gen->write_call_method_bind(result, base, method, arguments);
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
} 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);
|
gen->write_call_builtin_type(result, base, base.type.builtin_type, call->function_name, arguments);
|
||||||
} else {
|
} 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) {
|
if (base.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
|
||||||
gen->pop_temporary();
|
gen->pop_temporary();
|
||||||
|
|
Loading…
Add table
Reference in a new issue