Refactor: Only return output.

This commit is contained in:
chriseth 2021-11-02 17:48:59 +01:00
parent 735550b734
commit 99aa18c4f3
2 changed files with 12 additions and 12 deletions

View File

@ -176,9 +176,9 @@ StackSlot ControlFlowGraphBuilder::operator()(Expression const& _expression)
StackSlot ControlFlowGraphBuilder::operator()(FunctionCall const& _call) StackSlot ControlFlowGraphBuilder::operator()(FunctionCall const& _call)
{ {
CFG::Operation const& operation = visitFunctionCall(_call); Stack const& output = visitFunctionCall(_call);
yulAssert(operation.output.size() == 1, ""); yulAssert(output.size() == 1, "");
return operation.output.front(); return output.front();
} }
void ControlFlowGraphBuilder::operator()(VariableDeclaration const& _varDecl) void ControlFlowGraphBuilder::operator()(VariableDeclaration const& _varDecl)
@ -219,8 +219,8 @@ void ControlFlowGraphBuilder::operator()(ExpressionStatement const& _exprStmt)
yulAssert(m_currentBlock, ""); yulAssert(m_currentBlock, "");
std::visit(util::GenericVisitor{ std::visit(util::GenericVisitor{
[&](FunctionCall const& _call) { [&](FunctionCall const& _call) {
CFG::Operation const& operation = visitFunctionCall(_call); Stack const& output = visitFunctionCall(_call);
yulAssert(operation.output.empty(), ""); yulAssert(output.empty(), "");
}, },
[&](auto const&) { yulAssert(false, ""); } [&](auto const&) { yulAssert(false, ""); }
}, _exprStmt.expression); }, _exprStmt.expression);
@ -418,7 +418,7 @@ void ControlFlowGraphBuilder::operator()(FunctionDefinition const& _function)
} }
CFG::Operation const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _call) Stack const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _call)
{ {
yulAssert(m_scope, ""); yulAssert(m_scope, "");
yulAssert(m_currentBlock, ""); yulAssert(m_currentBlock, "");
@ -439,7 +439,7 @@ CFG::Operation const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall co
}) | ranges::to<Stack>, }) | ranges::to<Stack>,
// operation // operation
move(builtinCall) move(builtinCall)
}); }).output;
} }
else else
{ {
@ -456,7 +456,7 @@ CFG::Operation const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall co
}) | ranges::to<Stack>, }) | ranges::to<Stack>,
// operation // operation
CFG::FunctionCall{_call.debugData, function, _call} CFG::FunctionCall{_call.debugData, function, _call}
}); }).output;
} }
} }
@ -464,9 +464,9 @@ Stack ControlFlowGraphBuilder::visitAssignmentRightHandSide(Expression const& _e
{ {
return std::visit(util::GenericVisitor{ return std::visit(util::GenericVisitor{
[&](FunctionCall const& _call) -> Stack { [&](FunctionCall const& _call) -> Stack {
CFG::Operation const& operation = visitFunctionCall(_call); Stack const& output = visitFunctionCall(_call);
yulAssert(_expectedSlotCount == operation.output.size(), ""); yulAssert(_expectedSlotCount == output.size(), "");
return operation.output; return output;
}, },
[&](auto const& _identifierOrLiteral) -> Stack { [&](auto const& _identifierOrLiteral) -> Stack {
yulAssert(_expectedSlotCount == 1, ""); yulAssert(_expectedSlotCount == 1, "");

View File

@ -57,7 +57,7 @@ private:
AsmAnalysisInfo const& _analysisInfo, AsmAnalysisInfo const& _analysisInfo,
Dialect const& _dialect Dialect const& _dialect
); );
CFG::Operation const& visitFunctionCall(FunctionCall const&); Stack const& visitFunctionCall(FunctionCall const&);
Stack visitAssignmentRightHandSide(Expression const& _expression, size_t _expectedSlotCount); Stack visitAssignmentRightHandSide(Expression const& _expression, size_t _expectedSlotCount);
Scope::Function const& lookupFunction(YulString _name) const; Scope::Function const& lookupFunction(YulString _name) const;