mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +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
				
			
		|  | @ -18,7 +18,7 @@ void RecursiveASTVisitor::run_in_subtree(Tree& tree) | |||
| 
 | ||||
| void RecursiveASTVisitor::replace_current_node_with(Tree tree) | ||||
| { | ||||
|     m_current_subtree_pointer->replace_subtree(move(tree)); | ||||
|     m_current_subtree_pointer->replace_subtree({}, move(tree)); | ||||
| } | ||||
| 
 | ||||
| RecursionDecision RecursiveASTVisitor::recurse(Tree root, NodeSubtreePointer& pointer) | ||||
|  | @ -30,7 +30,7 @@ RecursionDecision RecursiveASTVisitor::recurse(Tree root, NodeSubtreePointer& po | |||
| 
 | ||||
|     if (decision == RecursionDecision::Recurse) { | ||||
|         for (auto& child : root->subtrees()) { | ||||
|             if (recurse(child.get(), child) == RecursionDecision::Break) | ||||
|             if (recurse(child.get({}), child) == RecursionDecision::Break) | ||||
|                 return RecursionDecision::Break; | ||||
|         } | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Klishch
						Dan Klishch