mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
JSSpecCompiler: Allow storing NullableTree
s in nodes
And use this in ElseIfBranch node.
This commit is contained in:
parent
4eede5282c
commit
092ed1cc8a
7 changed files with 56 additions and 18 deletions
|
@ -10,13 +10,24 @@
|
|||
|
||||
namespace JSSpecCompiler {
|
||||
|
||||
void RecursiveASTVisitor::run_in_const_subtree(NullableTree nullable_tree)
|
||||
{
|
||||
if (nullable_tree) {
|
||||
auto tree = nullable_tree.release_nonnull();
|
||||
auto tree_copy = tree;
|
||||
NodeSubtreePointer pointer { &tree };
|
||||
recurse(tree, pointer);
|
||||
VERIFY(tree == tree_copy);
|
||||
}
|
||||
}
|
||||
|
||||
void RecursiveASTVisitor::run_in_subtree(Tree& tree)
|
||||
{
|
||||
NodeSubtreePointer pointer { &tree };
|
||||
recurse(tree, pointer);
|
||||
}
|
||||
|
||||
void RecursiveASTVisitor::replace_current_node_with(Tree tree)
|
||||
void RecursiveASTVisitor::replace_current_node_with(NullableTree tree)
|
||||
{
|
||||
m_current_subtree_pointer->replace_subtree({}, move(tree));
|
||||
}
|
||||
|
|
|
@ -17,13 +17,14 @@ class RecursiveASTVisitor {
|
|||
public:
|
||||
virtual ~RecursiveASTVisitor() = default;
|
||||
|
||||
void run_in_const_subtree(NullableTree tree);
|
||||
void run_in_subtree(Tree& tree);
|
||||
|
||||
protected:
|
||||
virtual RecursionDecision on_entry(Tree) { return RecursionDecision::Recurse; }
|
||||
virtual void on_leave(Tree) { }
|
||||
|
||||
void replace_current_node_with(Tree tree);
|
||||
void replace_current_node_with(NullableTree tree);
|
||||
|
||||
private:
|
||||
RecursionDecision recurse(Tree root, NodeSubtreePointer& pointer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue