Modify parser and optimizer.

This commit is contained in:
chriseth
2019-05-20 17:32:56 +02:00
parent 46d9df7574
commit 1dc15d5864
20 changed files with 117 additions and 61 deletions
+8 -3
View File
@@ -70,6 +70,8 @@ class TerminationFinder
public:
enum class ControlFlow { FlowOut, Break, Continue, Terminate };
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
/// call to a terminating builtin function.
@@ -77,18 +79,21 @@ public:
/// returns `FlowOut` and ``size_t(-1)``.
/// The function might return ``FlowOut`` even though control
/// flow cannot actually continue.
static std::pair<ControlFlow, size_t> firstUnconditionalControlFlowChange(
std::pair<ControlFlow, size_t> firstUnconditionalControlFlowChange(
std::vector<Statement> const& _statements
);
/// @returns the control flow type of the given statement.
/// This function could return FlowOut even if control flow never continues.
static ControlFlow controlFlowKind(Statement const& _statement);
ControlFlow controlFlowKind(Statement const& _statement);
/// @returns true if the expression statement is a direct
/// call to a builtin terminating function like
/// ``stop``, ``revert`` or ``return``.
static bool isTerminatingBuiltin(ExpressionStatement const& _exprStmnt);
bool isTerminatingBuiltin(ExpressionStatement const& _exprStmnt);
private:
Dialect const& m_dialect;
};
}