Fix bug in call statement generator

This commit is contained in:
Bhargava Shastry 2021-05-05 18:54:44 +02:00
parent 954bcf95ea
commit a0197138d9

View File

@ -715,10 +715,6 @@ string FunctionCallGenerator::callStmt(shared_ptr<FunctionState> _callee)
string rhsExpr; string rhsExpr;
bool callValid = true; bool callValid = true;
// Create lhs expression only if function outputs non-zero return values.
if (!_callee->outputs.empty())
lhsExpr = lhs(_callee->outputs);
// Create arguments only if function contains non-zero input parameters. // Create arguments only if function contains non-zero input parameters.
if (!_callee->inputs.empty()) if (!_callee->inputs.empty())
{ {
@ -734,9 +730,15 @@ string FunctionCallGenerator::callStmt(shared_ptr<FunctionState> _callee)
rhsExpr = (_callee->type->functionScope() ? "" : "this.") + _callee->name + "();"; rhsExpr = (_callee->type->functionScope() ? "" : "this.") + _callee->name + "();";
if (callValid) if (callValid)
{
// Create lhs expression only if function outputs non-zero return values.
if (!_callee->outputs.empty())
lhsExpr = lhs(_callee->outputs);
callStmtStream << indentation() callStmtStream << indentation()
<< lhsExpr << lhsExpr
<< rhsExpr; << rhsExpr;
}
callStmtStream << "\n"; callStmtStream << "\n";
return callStmtStream.str(); return callStmtStream.str();
} }