|
|
1.1 root 1: /* ident "@(#)ctrans:src/tree_walk.h 1.2" */
2: /* -*- Mode: C -*- Begin include file tree_walk.H */
3: /*
4: $Source: /usr3/lang/benson/work/stripped_cfront/RCS/tree_walk.H,v $ $RCSfile: tree_walk.H,v $
5: $Revision: 1.1 $ $Date: 89/11/20 08:51:05 $
6: $Author: benson $ $Locker: $
7: $State: Exp $
8: */
9:
10: #ifndef _TREE_WALK
11: #define _TREE_WALK
12:
13: #include "cfront.h"
14: #include "node_classes.h"
15: #include <iostream.h>
16: #include "ios_printf.h"
17: #include "hash.h"
18:
19: enum tree_node_action {
20: tna_continue = 0, /* plain vanilla */
21: tna_stop = 1, /* don't proceed */
22: tna_error = 2, /* stop entire walk now. */
23: };
24:
25: /* procedural interface to indirect via a pointer. */
26: typedef int (*tree_fetch_proc) (void * info,
27: void * pointer,
28: unsigned long length,
29: int zero_stop, /* for character strings.*/
30: void * target);
31:
32:
33: const tree_fetch_proc null_tfp = (tree_fetch_proc) 0;
34:
35: class tree_walk_tree {
36: public:
37: tree_walk_tree * parent;
38: char storage[1]; /* variable amt, specified by caller. */
39: };
40:
41: /* The trailing int here controls whether to remember the
42: node in the hash table to short-circuit meeting it again */
43:
44: typedef void (*tree_pre_action)
45: (Pnode&, node_class, void *, tree_node_action&, int, Pnode,
46: tree_walk_tree&, int&);
47:
48:
49: typedef void (*tree_post_action)
50: (Pnode&, node_class, void *, tree_node_action&, int, Pnode,
51: tree_walk_tree&);
52:
53: typedef void (*errorp) (char, const char *);
54:
55: class tree_walk_control {
56: public:
57: int version;
58: void * callback_info;
59: tree_fetch_proc fetcher;
60: tree_pre_action action_proc;
61: tree_post_action post_action_proc;
62: int (*i_error) (int, const char *); /* usually part of cfront */
63: int call_i_error; /* if 0, just use the following */
64: ostream * error_stream;
65: Hash * nodes_seen_hash; /* allows this to be global over
66: more than one call to the walker. */
67: int resolve_by_name;
68: int alloc_stack_bytes;
69: /* if on, n_list and s_list are ignored for the very top node.
70: this is for the benefit of the printer. */
71: int dont_chase_lists_top;
72: tree_walk_control () {
73: version = 1;
74: callback_info = 0;
75: fetcher = null_tfp;
76: call_i_error = 0;
77: error_stream = &cerr;
78: nodes_seen_hash = 0;
79: resolve_by_name = 1; /* the dumper turns this off */
80: alloc_stack_bytes = 0;
81: post_action_proc = 0;
82: dont_chase_lists_top = 0;
83: }
84: };
85:
86: tree_node_action walk_tree (tree_walk_control& c, Pnode& n);
87:
88: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.