Skip to content

Commit

Permalink
Add docs to clone and deepClone methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed Jan 20, 2024
1 parent 09af7e1 commit 40d4aca
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions include/slang/syntax/SyntaxNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,33 @@ class SLANG_EXPORT SyntaxNode {
TokenOrSyntax getChild(size_t index);
};

SLANG_EXPORT SyntaxNode* clone(const SyntaxNode&, BumpAllocator&);
SLANG_EXPORT SyntaxNode* deepClone(const SyntaxNode&, BumpAllocator&);

/// @brief Performs a shallow clone of the given syntax node.
///
/// All members will be simply copied to the new instance.
/// The instance will be allocated with the provided allocator.
SLANG_EXPORT SyntaxNode* clone(const SyntaxNode& node, BumpAllocator& alloc);

/// @brief Performs a deep clone of the given syntax node.
///
/// All members will be cloned recursively to create a complete new
/// copy of the syntax tree. All cloned instances will be allocated
/// with the provided allocator.
SLANG_EXPORT SyntaxNode* deepClone(const SyntaxNode& node, BumpAllocator& alloc);

/// @brief Performs a shallow clone of the given syntax node.
///
/// All members will be simply copied to the new instance.
/// The instance will be allocated with the provided allocator.
template<std::derived_from<SyntaxNode> T>
T* clone(const T& node, BumpAllocator& alloc) {
return static_cast<T*>(clone(static_cast<const SyntaxNode&>(node), alloc));
}

/// @brief Performs a deep clone of the given syntax node.
///
/// All members will be cloned recursively to create a complete new
/// copy of the syntax tree. All cloned instances will be allocated
/// with the provided allocator.
template<std::derived_from<SyntaxNode> T>
T* deepClone(const T& node, BumpAllocator& alloc) {
return static_cast<T*>(deepClone(static_cast<const SyntaxNode&>(node), alloc));
Expand Down

0 comments on commit 40d4aca

Please sign in to comment.