mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Yul] leave statement.
This commit is contained in:
@@ -490,6 +490,9 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
||||
m_assembly.appendConstant(u256(0));
|
||||
}
|
||||
|
||||
m_context->functionExitPoints.push(
|
||||
CodeTransformContext::JumpInfo{m_assembly.newLabelId(), m_assembly.stackHeight()}
|
||||
);
|
||||
try
|
||||
{
|
||||
CodeTransform(
|
||||
@@ -518,6 +521,9 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
||||
stackError(std::move(error), height);
|
||||
}
|
||||
|
||||
m_assembly.appendLabel(m_context->functionExitPoints.top().label);
|
||||
m_context->functionExitPoints.pop();
|
||||
|
||||
{
|
||||
// The stack layout here is:
|
||||
// <return label>? <arguments...> <return values...>
|
||||
@@ -643,6 +649,17 @@ void CodeTransform::operator()(Continue const& _continue)
|
||||
checkStackHeight(&_continue);
|
||||
}
|
||||
|
||||
void CodeTransform::operator()(Leave const& _leave)
|
||||
{
|
||||
yulAssert(!m_context->functionExitPoints.empty(), "Invalid leave-statement. Requires surrounding function in code generation.");
|
||||
m_assembly.setSourceLocation(_leave.location);
|
||||
|
||||
Context::JumpInfo const& jump = m_context->functionExitPoints.top();
|
||||
m_assembly.appendJumpTo(jump.label, appendPopUntil(jump.targetStackHeight));
|
||||
|
||||
checkStackHeight(&_leave);
|
||||
}
|
||||
|
||||
void CodeTransform::operator()(Block const& _block)
|
||||
{
|
||||
Scope* originalScope = m_scope;
|
||||
|
||||
@@ -73,6 +73,7 @@ struct CodeTransformContext
|
||||
};
|
||||
|
||||
std::stack<ForLoopLabels> forLoopStack;
|
||||
std::stack<JumpInfo> functionExitPoints;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -185,6 +186,7 @@ public:
|
||||
void operator()(ForLoop const&);
|
||||
void operator()(Break const&);
|
||||
void operator()(Continue const&);
|
||||
void operator()(Leave const&);
|
||||
void operator()(Block const& _block);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user