mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Sol -> Yul] Implement if statements
This commit is contained in:
@@ -152,6 +152,25 @@ bool IRGeneratorForStatements::visit(TupleExpression const& _tuple)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IRGeneratorForStatements::visit(IfStatement const& _ifStatement)
|
||||
{
|
||||
_ifStatement.condition().accept(*this);
|
||||
string condition = expressionAsType(_ifStatement.condition(), *TypeProvider::boolean());
|
||||
|
||||
if (_ifStatement.falseStatement())
|
||||
{
|
||||
m_code << "switch " << condition << "\n" "case 0 {\n";
|
||||
_ifStatement.falseStatement()->accept(*this);
|
||||
m_code << "}\n" "default {\n";
|
||||
}
|
||||
else
|
||||
m_code << "if " << condition << " {\n";
|
||||
_ifStatement.trueStatement().accept(*this);
|
||||
m_code << "}\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IRGeneratorForStatements::visit(ForStatement const& _forStatement)
|
||||
{
|
||||
generateLoop(
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
void endVisit(VariableDeclarationStatement const& _variableDeclaration) override;
|
||||
bool visit(Assignment const& _assignment) override;
|
||||
bool visit(TupleExpression const& _tuple) override;
|
||||
bool visit(IfStatement const& _ifStatement) override;
|
||||
bool visit(ForStatement const& _forStatement) override;
|
||||
bool visit(WhileStatement const& _whileStatement) override;
|
||||
bool visit(Continue const& _continueStatement) override;
|
||||
|
||||
Reference in New Issue
Block a user