mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
JSSpecCompiler: Introduce ControlFlowOperator nodes
This commit is contained in:
parent
81519975c5
commit
67e07fa4e2
3 changed files with 75 additions and 0 deletions
|
@ -80,6 +80,7 @@ protected:
|
|||
// ```.
|
||||
class Statement : public Node { };
|
||||
class Expression : public Node { };
|
||||
class ControlFlowOperator : public Statement { };
|
||||
|
||||
class ErrorNode : public Expression {
|
||||
public:
|
||||
|
@ -96,6 +97,52 @@ protected:
|
|||
|
||||
inline Tree const error_tree = make_ref_counted<ErrorNode>();
|
||||
|
||||
class ControlFlowFunctionReturn : public ControlFlowOperator {
|
||||
public:
|
||||
ControlFlowFunctionReturn(VariableRef return_value)
|
||||
: m_return_value(move(return_value))
|
||||
{
|
||||
}
|
||||
|
||||
VariableRef m_return_value;
|
||||
|
||||
protected:
|
||||
void dump_tree(StringBuilder& builder) override;
|
||||
};
|
||||
|
||||
class ControlFlowJump : public ControlFlowOperator {
|
||||
public:
|
||||
ControlFlowJump(BasicBlockRef block)
|
||||
: m_block(block)
|
||||
{
|
||||
}
|
||||
|
||||
BasicBlockRef m_block;
|
||||
|
||||
protected:
|
||||
void dump_tree(StringBuilder& builder) override;
|
||||
};
|
||||
|
||||
// This should be invalid enough to crash program on use.
|
||||
inline NonnullRefPtr<ControlFlowOperator> const invalid_continuation = make_ref_counted<ControlFlowJump>(nullptr);
|
||||
|
||||
class ControlFlowBranch : public ControlFlowOperator {
|
||||
public:
|
||||
ControlFlowBranch(Tree condition, BasicBlockRef then, BasicBlockRef else_)
|
||||
: m_condition(move(condition))
|
||||
, m_then(then)
|
||||
, m_else(else_)
|
||||
{
|
||||
}
|
||||
|
||||
Tree m_condition;
|
||||
BasicBlockRef m_then;
|
||||
BasicBlockRef m_else;
|
||||
|
||||
protected:
|
||||
void dump_tree(StringBuilder& builder) override;
|
||||
};
|
||||
|
||||
class MathematicalConstant : public Expression {
|
||||
public:
|
||||
MathematicalConstant(i64 number)
|
||||
|
@ -249,6 +296,8 @@ protected:
|
|||
void dump_tree(StringBuilder& builder) override;
|
||||
};
|
||||
|
||||
// Although assert might seems a good candidate for ControlFlowOperator, we are not interested in
|
||||
// tracking control flow after a failed assertion.
|
||||
class AssertExpression : public Expression {
|
||||
public:
|
||||
AssertExpression(Tree condition)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue