mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[cond-expr] generate assembly for _ ? _ : _
This commit is contained in:
parent
047172eb9a
commit
ff4f1666ab
@ -176,6 +176,21 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
|
||||
m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction);
|
||||
}
|
||||
|
||||
bool ExpressionCompiler::visit(Conditional const& _condition)
|
||||
{
|
||||
CompilerContext::LocationSetter locationSetter(m_context, _condition);
|
||||
_condition.condition().accept(*this);
|
||||
m_context << eth::Instruction::ISZERO;
|
||||
eth::AssemblyItem falseTag = m_context.appendConditionalJump();
|
||||
_condition.trueExpression().accept(*this);
|
||||
eth::AssemblyItem endTag = m_context.appendJumpToNew();
|
||||
m_context << falseTag;
|
||||
m_context.adjustStackOffset(-1);
|
||||
_condition.falseExpression().accept(*this);
|
||||
m_context << endTag;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExpressionCompiler::visit(Assignment const& _assignment)
|
||||
{
|
||||
CompilerContext::LocationSetter locationSetter(m_context, _assignment);
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
void appendConstStateVariableAccessor(const VariableDeclaration& _varDecl);
|
||||
|
||||
private:
|
||||
virtual bool visit(Conditional const& _condition) override;
|
||||
virtual bool visit(Assignment const& _assignment) override;
|
||||
virtual bool visit(TupleExpression const& _tuple) override;
|
||||
virtual bool visit(UnaryOperation const& _unaryOperation) override;
|
||||
|
Loading…
Reference in New Issue
Block a user