1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.5),
3 // last updated on Jun 18, 1997.
4 // The original source file is "rename.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_REWRITING_USED
8 #define PROP_STRCMP_USED
9 #define PROP_QUARK_USED
10 #define PROP_TUPLE2_USED
13 #include <AD/pretty/postream.h>
16 ///////////////////////////////////////////////////////////////////////////////
18 // Constructor and destructor for the renaming phase
20 ///////////////////////////////////////////////////////////////////////////////
21 RemoveDuplicateNames::RemoveDuplicateNames() {}
22 RemoveDuplicateNames::~RemoveDuplicateNames() {}
24 ///////////////////////////////////////////////////////////////////////////////
26 // Method to create a new variable binding. We'll only create a
27 // new name if the current binding overshadows some previous name.
29 ///////////////////////////////////////////////////////////////////////////////
30 void RemoveDuplicateNames::new_binding(Id
& x
)
31 { if (env
.contains(x
))
50 void RemoveDuplicateNames::new_binding(Ids ids
)
58 new_binding(ids
->_1
); ids
= ids
->_2
;
69 ///////////////////////////////////////////////////////////////////////////////
71 // Method to remove a variable binding.
73 ///////////////////////////////////////////////////////////////////////////////
74 void RemoveDuplicateNames::old_binding(Id
& x
)
83 env
.insert(x
,names
->_2
); x
= names
->_1
;
87 env
.remove(x
); x
= names
->_1
;
97 void RemoveDuplicateNames::old_binding(Ids ids
)
100 #line 48 "rename.pcc"
104 #line 48 "rename.pcc"
105 old_binding(ids
->_1
); ids
= ids
->_2
;
106 #line 48 "rename.pcc"
111 #line 49 "rename.pcc"
112 #line 49 "rename.pcc"
116 ///////////////////////////////////////////////////////////////////////////////
118 // Method to rename a variable
120 ///////////////////////////////////////////////////////////////////////////////
121 void RemoveDuplicateNames::rename(Id
& x
)
122 { if (env
.contains(x
))
123 { Ids names
= env
[x
];
125 #line 60 "rename.pcc"
126 #line 63 "rename.pcc"
129 #line 61 "rename.pcc"
131 #line 61 "rename.pcc"
134 #line 63 "rename.pcc"
135 #line 63 "rename.pcc"
140 ///////////////////////////////////////////////////////////////////////////////
142 // Method to invoke the renaming phase.
144 ///////////////////////////////////////////////////////////////////////////////
145 Exp
RemoveDuplicateNames::remove_duplicate_names(Exp e
)
146 { message("Renaming phase", e
); env
.clear(); (*this)(e
); return e
; }
148 ///////////////////////////////////////////////////////////////////////////////
150 // Transformation rules
152 ///////////////////////////////////////////////////////////////////////////////
153 #line 80 "rename.pcc"
154 #line 100 "rename.pcc"
155 ///////////////////////////////////////////////////////////////////////////////
157 // This macro can be redefined by the user for debugging
159 ///////////////////////////////////////////////////////////////////////////////
160 #ifndef DEBUG_RemoveDuplicateNames
161 #define DEBUG_RemoveDuplicateNames(repl,redex,file,line,rule) repl
163 static const char * RemoveDuplicateNames_file_name
= "rename.pcc";
166 inline void RemoveDuplicateNames::labeler(char const * redex
,int& s__
,int)
173 inline void RemoveDuplicateNames::labeler(Quark redex
,int& s__
,int)
180 void RemoveDuplicateNames::labeler (Exp
& redex
, int& s__
, int r__
)
184 switch (redex
->tag__
) {
185 case a_Exp::tag_ID
: {
186 #line 94 "rename.pcc"
187 rename(_ID(redex
)->ID
);
188 #line 94 "rename.pcc"
190 case a_Exp::tag_FORALL
: {
191 #line 89 "rename.pcc"
192 new_binding(_FORALL(redex
)->_1
);
193 #line 89 "rename.pcc"
195 case a_Exp::tag_EXISTS
: {
196 #line 88 "rename.pcc"
197 new_binding(_EXISTS(redex
)->_1
);
198 #line 88 "rename.pcc"
200 case a_Exp::tag_GENERATOR
: {
201 #line 90 "rename.pcc"
202 new_binding(_GENERATOR(redex
)->_1
);
203 #line 90 "rename.pcc"
205 case a_Exp::tag_LET
: {
206 #line 91 "rename.pcc"
207 new_binding(_LET(redex
)->_1
);
208 #line 91 "rename.pcc"
213 switch(redex
->tag__
) {
214 case a_Exp::tag_OP
: {
217 labeler(_OP(redex
)->_1
, s0__
, r__
);
218 labeler(_OP(redex
)->_2
, s1__
, r__
);
220 case a_Exp::tag_APP
: {
223 labeler(_APP(redex
)->_1
, s0__
, r__
);
224 labeler(_APP(redex
)->_2
, s1__
, r__
);
226 case a_Exp::tag_LIT
: {
228 labeler(_LIT(redex
)->LIT
, s0__
, r__
);
230 case a_Exp::tag_ID
: {
232 labeler(_ID(redex
)->ID
, s0__
, r__
);
234 case a_Exp::tag_TUPLE
: {
236 labeler(_TUPLE(redex
)->TUPLE
, s0__
, r__
);
238 case a_Exp::tag_FORALL
: {
242 labeler(_FORALL(redex
)->_1
, s0__
, r__
);
243 labeler(_FORALL(redex
)->_2
, s1__
, r__
);
244 labeler(_FORALL(redex
)->_3
, s2__
, r__
);
246 case a_Exp::tag_EXISTS
: {
250 labeler(_EXISTS(redex
)->_1
, s0__
, r__
);
251 labeler(_EXISTS(redex
)->_2
, s1__
, r__
);
252 labeler(_EXISTS(redex
)->_3
, s2__
, r__
);
254 case a_Exp::tag_GUARD
: {
257 labeler(_GUARD(redex
)->_1
, s0__
, r__
);
258 labeler(_GUARD(redex
)->_2
, s1__
, r__
);
260 case a_Exp::tag_GENERATOR
: {
265 labeler(_GENERATOR(redex
)->_2
, s1__
, r__
);
266 labeler(_GENERATOR(redex
)->_3
, s2__
, r__
);
272 labeler(_LET(redex
)->_1
, s0__
, r__
);
273 labeler(_LET(redex
)->_2
, s1__
, r__
);
274 labeler(_LET(redex
)->_3
, s2__
, r__
);
278 switch (redex
->tag__
) {
279 case a_Exp::tag_FORALL
: {
280 #line 98 "rename.pcc"
281 old_binding(_FORALL(redex
)->_1
); define_range(_FORALL(redex
)->_1
,_FORALL(redex
)->_2
);
282 #line 98 "rename.pcc"
284 case a_Exp::tag_EXISTS
: {
285 #line 97 "rename.pcc"
286 old_binding(_EXISTS(redex
)->_1
); define_range(_EXISTS(redex
)->_1
,_EXISTS(redex
)->_2
);
287 #line 97 "rename.pcc"
289 case a_Exp::tag_GENERATOR
: {
290 #line 99 "rename.pcc"
291 old_binding(_GENERATOR(redex
)->_1
); define_range(_GENERATOR(redex
)->_1
,_GENERATOR(redex
)->_2
);
292 #line 99 "rename.pcc"
294 case a_Exp::tag_LET
: {
295 #line 100 "rename.pcc"
296 old_binding(_LET(redex
)->_1
);
297 #line 100 "rename.pcc"
305 void RemoveDuplicateNames::labeler (Literal
& redex
, int& s__
, int r__
)
308 switch(redex
->tag__
) {
309 case a_Literal::tag_INT
: {
313 case a_Literal::tag_STRING
: {
315 labeler(_STRING(redex
)->STRING
, s0__
, r__
);
325 void RemoveDuplicateNames::labeler (a_List
<Exp
> * & redex
, int& s__
, int r__
)
331 labeler(redex
->_1
, s0__
, r__
);
332 labeler(redex
->_2
, s1__
, r__
);
339 #line 101 "rename.pcc"
340 #line 101 "rename.pcc"
342 #line 102 "rename.pcc"
344 ------------------------------- Statistics -------------------------------
345 Merge matching rules = yes
346 Number of DFA nodes merged = 16
347 Number of ifs generated = 5
348 Number of switches generated = 2
351 Adaptive matching = disabled
352 Fast string matching = disabled
353 Inline downcasts = disabled
354 --------------------------------------------------------------------------