mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Yul] Adds break/continue statements and some general tests for for-loop syntax.
This commit is contained in:
committed by
Christian Parpart
parent
4704ef843d
commit
05e2d362c8
+23
-2
@@ -25,6 +25,7 @@
|
||||
#include <libyul/AsmScope.h>
|
||||
#include <libyul/AsmAnalysisInfo.h>
|
||||
#include <libyul/Utilities.h>
|
||||
#include <libyul/Exceptions.h>
|
||||
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
|
||||
@@ -33,6 +34,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
@@ -472,7 +474,7 @@ bool AsmAnalyzer::operator()(ForLoop const& _for)
|
||||
{
|
||||
solAssert(_for.condition, "");
|
||||
|
||||
Scope* originalScope = m_currentScope;
|
||||
Scope* outerScope = m_currentScope;
|
||||
|
||||
bool success = true;
|
||||
if (!(*this)(_for.pre))
|
||||
@@ -485,18 +487,37 @@ bool AsmAnalyzer::operator()(ForLoop const& _for)
|
||||
if (!expectExpression(*_for.condition))
|
||||
success = false;
|
||||
m_stackHeight--;
|
||||
|
||||
// backup outer for-loop & create new state
|
||||
auto outerForLoop = m_currentForLoop;
|
||||
m_currentForLoop = &_for;
|
||||
|
||||
if (!(*this)(_for.body))
|
||||
success = false;
|
||||
|
||||
if (!(*this)(_for.post))
|
||||
success = false;
|
||||
|
||||
m_stackHeight -= scope(&_for.pre).numberOfVariables();
|
||||
m_info.stackHeightInfo[&_for] = m_stackHeight;
|
||||
m_currentScope = originalScope;
|
||||
m_currentScope = outerScope;
|
||||
m_currentForLoop = outerForLoop;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool AsmAnalyzer::operator()(Break const& _break)
|
||||
{
|
||||
m_info.stackHeightInfo[&_break] = m_stackHeight;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AsmAnalyzer::operator()(Continue const& _continue)
|
||||
{
|
||||
m_info.stackHeightInfo[&_continue] = m_stackHeight;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AsmAnalyzer::operator()(Block const& _block)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
Reference in New Issue
Block a user