forked from farisawan-2000/cfront-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tree_walk.h
117 lines (97 loc) · 3.74 KB
/
tree_walk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*ident "@(#)cls4:src/tree_walk.h 1.5" */
/*******************************************************************************
C++ source for the C++ Language System, Release 3.0. This product
is a new release of the original cfront developed in the computer
science research center of AT&T Bell Laboratories.
Copyright (c) 1993 UNIX System Laboratories, Inc.
Copyright (c) 1991, 1992 AT&T and UNIX System Laboratories, Inc.
Copyright (c) 1984, 1989, 1990 AT&T. All Rights Reserved.
THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE of AT&T and UNIX System
Laboratories, Inc. The copyright notice above does not evidence
any actual or intended publication of such source code.
*******************************************************************************/
/******************************************************************************
* Copyright (c) 1989 by Object Design, Inc., Burlington, Mass.
* All rights reserved.
*******************************************************************************/
#ifndef _TREE_WALK
#define _TREE_WALK
#include "cfront.h"
#include "node_classes.h"
#include "hash.h"
enum tree_node_action {
tna_continue = 0, /* plain vanilla */
tna_stop = 1, /* don't proceed */
tna_error = 2, /* stop entire walk now. */
};
/* procedural interface to indirect via a pointer. */
typedef int (*tree_fetch_proc)(void *info, void *pointer, unsigned long length,
int zero_stop, /* for character strings.*/
void *target);
const tree_fetch_proc null_tfp = (tree_fetch_proc) 0;
class tree_walk_tree {
public:
tree_walk_tree *parent;
char storage[1]; /* variable amt, specified by caller. */
};
/* The trailing int here controls whether to remember the
node in the hash table to short-circuit meeting it again */
typedef void (*tree_pre_action)(Pnode &, node_class, void *, tree_node_action &, int, Pnode,
tree_walk_tree &, int &);
typedef void (*tree_post_action)(Pnode &, node_class, void *, tree_node_action &, int, Pnode,
tree_walk_tree &);
typedef void (*errorp)(char, const char *);
class tree_walk_control {
public:
int version;
void *callback_info;
tree_fetch_proc fetcher;
tree_pre_action action_proc;
tree_post_action post_action_proc;
int (*i_error)(int, const char *); /* usually part of cfront */
int call_i_error; /* if 0, just use the following */
Hash *nodes_seen_hash; /* allows this to be global over
more than one call to the walker. */
int resolve_by_name;
int alloc_stack_bytes;
/* if on, n_list and s_list are ignored for the very top node.
this is for the benefit of the printer. */
int dont_chase_lists_top;
tree_walk_control() {
version = 1;
callback_info = 0;
fetcher = null_tfp;
call_i_error = 0;
nodes_seen_hash = 0;
resolve_by_name = 1; /* the dumper turns this off */
alloc_stack_bytes = 0;
post_action_proc = 0;
dont_chase_lists_top = 0;
}
};
typedef class patch_tree *Ppatch_tree;
class patch_tree {
public:
static void init(Hash *_ht) {
head = 0;
ht = _ht;
}
static void add(Pnode);
static void patch();
private:
static void patch_a_ktable(Pktab);
static void patch_a_table(Ptable);
static void patch_a_name(Pname);
static Pnode probe(Pnode);
static Ppatch_tree head;
static Hash *ht;
Pnode node;
Ppatch_tree next;
patch_tree(Pnode _node, Ppatch_tree _next) : node(_node), next(_next) {
}
patch_tree(const patch_tree &);
~patch_tree() {
}
};
tree_node_action walk_tree(tree_walk_control &c, Pnode &n);
#endif