mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Simplify single-run for loops to if statements.
This commit is contained in:
@@ -38,7 +38,7 @@ namespace yul
|
||||
* The ControlFlowSimplifier does record the presence or absence of ``break``
|
||||
* and ``continue`` statements during its traversal.
|
||||
*
|
||||
* Prerequisite: Disambiguator, ForLoopInitRewriter.
|
||||
* Prerequisite: Disambiguator, FunctionHoister, ForLoopInitRewriter.
|
||||
*
|
||||
* Important: Introduces EVM opcodes and thus can only be used on EVM code for now.
|
||||
*/
|
||||
@@ -46,9 +46,17 @@ class ControlFlowSimplifier: public ASTModifier
|
||||
{
|
||||
public:
|
||||
using ASTModifier::operator();
|
||||
void operator()(Break&) override { ++m_numBreakStatements; }
|
||||
void operator()(Continue&) override { ++m_numContinueStatements; }
|
||||
void operator()(Block& _block) override;
|
||||
|
||||
void visit(Statement& _st) override;
|
||||
|
||||
private:
|
||||
void simplify(std::vector<Statement>& _statements);
|
||||
|
||||
size_t m_numBreakStatements = 0;
|
||||
size_t m_numContinueStatements = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user