Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra4/src/utilities/sid/rstack.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/*** rstack.c --- Renaming stack ADT.
32
 *
33
 ** Author: Steve Folkes <smf@hermes.mod.uk>
34
 *
35
 *** Commentary:
36
 *
37
 * This file implements the renaming stack routines.  They are mainly used by
38
 * the output routines to do scoping of inlined rules.
39
 *
40
 *** Change Log:
41
 * $Log: rstack.c,v $
42
 * Revision 1.1.1.1  1998/01/17  15:57:46  release
43
 * First version to be checked into rolling release.
44
 *
45
 * Revision 1.2  1994/12/15  09:58:31  smf
46
 * Brought into line with OSSG C Coding Standards Document, as per
47
 * "CR94_178.sid+tld-update".
48
 *
49
 * Revision 1.1.1.1  1994/07/25  16:04:37  smf
50
 * Initial import of SID 1.8 non shared files.
51
 *
52
**/
53
 
54
/****************************************************************************/
55
 
56
#include "rstack.h"
57
#include "action.h"
58
#include "basic.h"
59
#include "name.h"
60
#include "rule.h"
61
#include "type.h"
62
 
63
/*--------------------------------------------------------------------------*/
64
 
65
void
66
rstack_init PROTO_N ((rstack))
67
	    PROTO_T (RStackP rstack)
68
{
69
    rstack->head = NIL (TransStackEntryP);
70
}
71
 
72
void
73
rstack_push_frame PROTO_N ((rstack))
74
		  PROTO_T (RStackP rstack)
75
{
76
    TransStackEntryP frame = ALLOCATE (TransStackEntryT);
77
 
78
    frame->next = rstack->head;
79
    rtrans_init (&(frame->translator));
80
    rstack->head = frame;
81
}
82
 
83
void
84
rstack_compute_formal_renaming PROTO_N ((rstack, names))
85
			       PROTO_T (RStackP    rstack X
86
					TypeTupleP names)
87
{
88
    ASSERT (rstack->head);
89
    types_compute_formal_renaming (names, &(rstack->head->translator));
90
}
91
 
92
void
93
rstack_compute_formal_inlining PROTO_N ((rstack, names, renames))
94
			       PROTO_T (RStackP    rstack X
95
					TypeTupleP names X
96
					TypeTupleP renames)
97
{
98
    SaveRStackT state;
99
 
100
    ASSERT (rstack->head);
101
    state.head = rstack->head->next;
102
    types_compute_formal_inlining (names, renames, &(rstack->head->translator),
103
				   &state);
104
}
105
 
106
void
107
rstack_compute_local_renaming PROTO_N ((rstack, names, exclude, table))
108
			      PROTO_T (RStackP    rstack X
109
				       TypeTupleP names X
110
				       TypeTupleP exclude X
111
				       TableP     table)
112
{
113
    SaveRStackT state;
114
 
115
    ASSERT (rstack->head);
116
    state.head = rstack->head->next;
117
    types_compute_local_renaming (names, exclude, &(rstack->head->translator),
118
				  &state, table);
119
}
120
 
121
void
122
rstack_add_translation PROTO_N ((rstack, from, to, type, reference))
123
		       PROTO_T (RStackP rstack X
124
				EntryP  from X
125
				EntryP  to X
126
				EntryP  type X
127
				BoolT   reference)
128
{
129
    ASSERT (rstack->head);
130
    rtrans_add_translation (&(rstack->head->translator), from, to, type,
131
			    reference);
132
}
133
 
134
void
135
rstack_save_state PROTO_N ((rstack, state))
136
		  PROTO_T (RStackP     rstack X
137
			   SaveRStackP state)
138
{
139
    state->head = rstack->head;
140
}
141
 
142
EntryP
143
rstack_get_translation PROTO_N ((state, entry, type_ref, reference_ref))
144
		       PROTO_T (SaveRStackP state X
145
				EntryP      entry X
146
				EntryP     *type_ref X
147
				BoolT      *reference_ref)
148
{
149
    TransStackEntryP frame = state->head;
150
 
151
    while (frame) {
152
	EntryP translation;
153
 
154
	translation = rtrans_get_translation (&(frame->translator), entry,
155
					      type_ref, reference_ref);
156
	if (translation) {
157
	    return (translation);
158
	}
159
	frame = frame->next;
160
    }
161
    return (NIL (EntryP));
162
}
163
 
164
void
165
rstack_apply_for_non_locals PROTO_N ((non_local_stack, state, proc, closure))
166
			    PROTO_T (RStackP     non_local_stack X
167
				     SaveRStackP state X
168
				     void      (*proc) PROTO_S ((EntryP,
169
								 EntryP,
170
								 GenericP)) X
171
				     GenericP    closure)
172
{
173
    TransStackEntryP frame = non_local_stack->head;
174
 
175
    if ((frame != NIL (TransStackEntryP)) && (state->head)) {
176
	TransStackEntryP limit = state->head->next;
177
 
178
	for (; frame != limit; frame = frame->next) {
179
	    rtrans_apply_for_non_locals (&(frame->translator), proc, closure);
180
	}
181
    }
182
}
183
 
184
void
185
rstack_pop_frame PROTO_N ((rstack))
186
		 PROTO_T (RStackP rstack)
187
{
188
    TransStackEntryP frame = rstack->head;
189
 
190
    rstack->head = frame->next;
191
    rtrans_destroy (&(frame->translator));
192
    DEALLOCATE (frame);
193
}
194
 
195
void
196
rstack_destroy PROTO_N ((rstack))
197
	       PROTO_T (RStackP rstack)
198
{
199
    while (rstack->head) {
200
	rstack_pop_frame (rstack);
201
    }
202
}
203
 
204
/*
205
 * Local variables(smf):
206
 * eval: (include::add-path-entry "../os-interface" "../library")
207
 * eval: (include::add-path-entry "../generated")
208
 * end:
209
**/