mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:07:35 +00:00
JSSpecCompiler: Restrict usage of NodeSubtreePointer
This class stores a non-owning raw pointer to a member of `Node`, so extra care is needed to ensure that referenced `Node`s will be alive by the time `NodeSubtreePointer` is used. Since we only need to use this class while traversing AST in `RecursiveASTVisitor`, access to class methods can be restricted using `Badge<RecursiveASTVisitor>`.
This commit is contained in:
parent
f789d26e37
commit
1c4cd34320
3 changed files with 8 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -27,9 +28,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
Tree& get() { return *m_tree_ptr; }
|
||||
Tree& get(Badge<RecursiveASTVisitor>) { return *m_tree_ptr; }
|
||||
|
||||
void replace_subtree(Tree tree) { *m_tree_ptr = move(tree); }
|
||||
void replace_subtree(Badge<RecursiveASTVisitor>, Tree tree) { *m_tree_ptr = move(tree); }
|
||||
|
||||
private:
|
||||
Tree* m_tree_ptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue