mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add support for do/while loops
This commit adds support for a standard do <statement> while <expr>; form of statement. While loops were already being supported; supporting a do/while loop mostly involves reusing code from while loops but putting the conditional checking last.
This commit is contained in:
@@ -1005,18 +1005,22 @@ public:
|
||||
SourceLocation const& _location,
|
||||
ASTPointer<ASTString> const& _docString,
|
||||
ASTPointer<Expression> const& _condition,
|
||||
ASTPointer<Statement> const& _body
|
||||
ASTPointer<Statement> const& _body,
|
||||
bool _isDoWhile
|
||||
):
|
||||
BreakableStatement(_location, _docString), m_condition(_condition), m_body(_body) {}
|
||||
BreakableStatement(_location, _docString), m_condition(_condition), m_body(_body),
|
||||
m_isDoWhile(_isDoWhile) {}
|
||||
virtual void accept(ASTVisitor& _visitor) override;
|
||||
virtual void accept(ASTConstVisitor& _visitor) const override;
|
||||
|
||||
Expression const& condition() const { return *m_condition; }
|
||||
Statement const& body() const { return *m_body; }
|
||||
bool isDoWhile() const { return m_isDoWhile; }
|
||||
|
||||
private:
|
||||
ASTPointer<Expression> m_condition;
|
||||
ASTPointer<Statement> m_body;
|
||||
bool m_isDoWhile;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user