[Yul] leave statement.

This commit is contained in:
chriseth
2019-10-29 14:32:16 +01:00
parent edf1e83fda
commit ceb8ee9124
41 changed files with 214 additions and 27 deletions
+28 -2
View File
@@ -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)``.