source: src/AST/Copy.hpp @ 3249dd8b

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 3249dd8b was 3249dd8b, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Some clean-up. DeepCopyCore? lost its already tenous reason to be in the header so I moved it.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// Copy.hpp -- Provides functions to copy the AST.
8//
9// Author           : Andrew Beach
10// Created On       : Wed Jul 10 16:13:00 2019
11// Last Modified By : Andrew Beach
12// Last Modified On : Thr Nov 11  9:22:00 2021
13// Update Count     : 2
14//
15
16#pragma once
17
18#include "Node.hpp"
19#include <cassert>
20
21namespace ast {
22
23template<typename node_t>
24node_t * shallowCopy( const node_t * node );
25/* Create a shallow copy of the node given.
26 *
27 * The new node has all the same primitive field values and points to the
28 * same children nodes as the parent.
29 */
30
31template<typename node_t>
32node_t * deepCopy( const node_t * localRoot );
33/* Create a deep copy of the tree rooted at localRoot.
34 *
35 * This creates a copy of every node in the sub-tree (reachable by strong
36 * reference from local_root) and updates any readonly pointers on those nodes
37 * that point to another node in the sub-tree to the new version of that node.
38 */
39
40// Implementations:
41template<typename node_t>
42node_t * shallowCopy( const node_t * localRoot ) {
43        return localRoot->clone();
44}
45
46Node * deepCopyNode( const Node * node );
47
48template<typename node_t>
49node_t * deepCopy( const node_t * localRoot ) {
50        return strict_dynamic_cast<node_t *>( deepCopyNode( localRoot ) );
51}
52
53}
54
55// Local Variables: //
56// tab-width: 4 //
57// mode: c++ //
58// compile-command: "make install" //
59// End: //
Note: See TracBrowser for help on using the repository browser.