mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[Yul] leave statement.
This commit is contained in:
@@ -113,6 +113,31 @@ private:
|
||||
bool m_msizeFound = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Class that can be used to find out if the given function contains the ``leave`` statement.
|
||||
*
|
||||
* Returns true even in the case where the function definition contains another function definition
|
||||
* that contains the leave statement.
|
||||
*/
|
||||
class LeaveFinder: public ASTWalker
|
||||
{
|
||||
public:
|
||||
static bool containsLeave(FunctionDefinition const& _fun)
|
||||
{
|
||||
LeaveFinder f;
|
||||
f(_fun);
|
||||
return f.m_leaveFound;
|
||||
}
|
||||
|
||||
using ASTWalker::operator();
|
||||
void operator()(Leave const&) { m_leaveFound = true; }
|
||||
|
||||
private:
|
||||
LeaveFinder() = default;
|
||||
|
||||
bool m_leaveFound = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Specific AST walker that determines whether an expression is movable
|
||||
* and collects the referenced variables.
|
||||
@@ -148,12 +173,13 @@ private:
|
||||
class TerminationFinder
|
||||
{
|
||||
public:
|
||||
enum class ControlFlow { FlowOut, Break, Continue, Terminate };
|
||||
// TODO check all uses of TerminationFinder!
|
||||
enum class ControlFlow { FlowOut, Break, Continue, Terminate, Leave };
|
||||
|
||||
TerminationFinder(Dialect const& _dialect): m_dialect(_dialect) {}
|
||||
|
||||
/// @returns the index of the first statement in the provided sequence
|
||||
/// that is an unconditional ``break``, ``continue`` or a
|
||||
/// that is an unconditional ``break``, ``continue``, ``leave`` or a
|
||||
/// call to a terminating builtin function.
|
||||
/// If control flow can continue at the end of the list,
|
||||
/// returns `FlowOut` and ``size_t(-1)``.
|
||||
|
||||
Reference in New Issue
Block a user