|
|
1.1 root 1: /* -*- Mode: C -*- begin include file tree_copy.H
2: argument class for copying trees. */
3:
4: #include <hash.H>
5: #include "tree_walk.H"
6:
7: /* The copier procedure expects one of these as its
8: info pointer */
9:
10: class tree_copy_info {
11: public:
12: /* If non-zero, this procedure is called at each node.
13: it returns an action. It cannot currently return
14: a node of a different class and also return an
15: action other than tna_stop, since the walker won't
16: notice that the rug has been removed from beneath its feet.
17: The procedure must set the last argument to indicate whether
18: or not to register the node in the hash table and use the
19: replacement every future time it is encountered.
20: */
21:
22: void (* node_hook) (void * info, Pnode&, node_class, tree_node_action&,
23: int&);
24:
25: /* if this is nonzero it is used to allocate space for
26: the copies. We don't run constructors since we always
27: bit copy over the new copy. */
28: char * (* malloc_hook) (void * info, size_t);
29: void * hook_info;
30: tree_copy_info ()
31: {
32: hook_info = 0;
33: node_hook = 0;
34: malloc_hook = 0;
35: };
36: char * malloc (size_t s) {
37: return malloc_hook ? malloc_hook(hook_info, s) : ::malloc (s);
38: };
39: void check_node (Pnode& n,
40: node_class cl,
41: tree_node_action& action,
42: int& never_see_again) {
43: if(node_hook)
44: node_hook(hook_info, n, cl, action, never_see_again);
45: };
46: };
47:
48: void copy_tree (Pnode& n, tree_copy_info& tci, Hash * cht = 0);
49:
50: /* End tree_copy.H */
51:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.