gcc config
[prop.git] / prop-src / setl-ast.cc
blob2bb6c8e6e0cb3535abdcc65cf8cdcf70bbb68612
1 ///////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.3.6),
3 // last updated on Nov 2, 1999.
4 // The original source file is "setl-ast.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #line 1 "setl-ast.pcc"
8 ///////////////////////////////////////////////////////////////////////////////
9 //
10 // This file implements the basic routines on definitions and statements
11 // ASTs.
13 ///////////////////////////////////////////////////////////////////////////////
15 #include <iostream>
16 #include "ir.h"
17 #include "ast.h"
18 #include "setl-ast.h"
20 ///////////////////////////////////////////////////////////////////////////////
22 // Instantiate the AST datatypes.
24 ///////////////////////////////////////////////////////////////////////////////
25 #line 18 "setl-ast.pcc"
26 #line 18 "setl-ast.pcc"
27 ///////////////////////////////////////////////////////////////////////////////
29 // Interface specification of datatype Def
31 ///////////////////////////////////////////////////////////////////////////////
32 #line 18 "setl-ast.pcc"
35 ///////////////////////////////////////////////////////////////////////////////
37 // Interface specification of datatype Sig
39 ///////////////////////////////////////////////////////////////////////////////
40 #line 18 "setl-ast.pcc"
43 ///////////////////////////////////////////////////////////////////////////////
45 // Interface specification of datatype Stmt
47 ///////////////////////////////////////////////////////////////////////////////
48 #line 18 "setl-ast.pcc"
51 ///////////////////////////////////////////////////////////////////////////////
53 // Interface specification of datatype List<Def>
55 ///////////////////////////////////////////////////////////////////////////////
56 #line 18 "setl-ast.pcc"
59 ///////////////////////////////////////////////////////////////////////////////
61 // Interface specification of datatype List<Sig>
63 ///////////////////////////////////////////////////////////////////////////////
64 #line 18 "setl-ast.pcc"
67 ///////////////////////////////////////////////////////////////////////////////
69 // Interface specification of datatype List<LabSig>
71 ///////////////////////////////////////////////////////////////////////////////
72 #line 18 "setl-ast.pcc"
75 ///////////////////////////////////////////////////////////////////////////////
77 // Interface specification of datatype List<Stmt>
79 ///////////////////////////////////////////////////////////////////////////////
80 #line 18 "setl-ast.pcc"
83 ///////////////////////////////////////////////////////////////////////////////
85 // Instantiation of datatype Def
87 ///////////////////////////////////////////////////////////////////////////////
88 #line 18 "setl-ast.pcc"
89 Def_VARdef::Def_VARdef (Id x_id, Ty x_ty, Exp x_init_exp)
90 : a_Def(tag_VARdef), id(x_id), ty(x_ty), init_exp(x_init_exp)
93 a_Def * VARdef (Id x_id, Ty x_ty, Exp x_init_exp)
95 return new Def_VARdef (x_id, x_ty, x_init_exp);
97 Def_FUNCTIONdef::Def_FUNCTIONdef (Id x_id, LabTys x_args, Ty x_return_ty, Defs x_local_defs, Stmts x_body)
98 : a_Def(tag_FUNCTIONdef), id(x_id), args(x_args), return_ty(x_return_ty), local_defs(x_local_defs), body(x_body)
101 a_Def * FUNCTIONdef (Id x_id, LabTys x_args, Ty x_return_ty, Defs x_local_defs, Stmts x_body)
103 return new Def_FUNCTIONdef (x_id, x_args, x_return_ty, x_local_defs, x_body);
105 Def_MODULEdef::Def_MODULEdef (Id x_id, LabSigs x_args, Sig x_sig, Defs x_body)
106 : a_Def(tag_MODULEdef), id(x_id), args(x_args), sig(x_sig), body(x_body)
109 a_Def * MODULEdef (Id x_id, LabSigs x_args, Sig x_sig, Defs x_body)
111 return new Def_MODULEdef (x_id, x_args, x_sig, x_body);
113 Def_SIGNATUREdef::Def_SIGNATUREdef (Id x_id, LabSigs x_args, Sig x_sig)
114 : a_Def(tag_SIGNATUREdef), id(x_id), args(x_args), sig(x_sig)
117 a_Def * SIGNATUREdef (Id x_id, LabSigs x_args, Sig x_sig)
119 return new Def_SIGNATUREdef (x_id, x_args, x_sig);
121 Def_TYPEdef::Def_TYPEdef (Decl x_TYPEdef)
122 : a_Def(tag_TYPEdef), TYPEdef(x_TYPEdef)
125 a_Def * TYPEdef (Decl x_TYPEdef)
127 return new Def_TYPEdef (x_TYPEdef);
129 Def_LAMBDAdef::Def_LAMBDAdef (LabTys x_1, Defs x_2)
130 : a_Def(tag_LAMBDAdef), _1(x_1), _2(x_2)
133 a_Def * LAMBDAdef (LabTys x_1, Defs x_2)
135 return new Def_LAMBDAdef (x_1, x_2);
139 ///////////////////////////////////////////////////////////////////////////////
141 // Instantiation of datatype Sig
143 ///////////////////////////////////////////////////////////////////////////////
144 #line 18 "setl-ast.pcc"
145 Sig_IDsig::Sig_IDsig (Id x_IDsig)
146 : a_Sig(tag_IDsig), IDsig(x_IDsig)
149 a_Sig * IDsig (Id x_IDsig)
151 return new Sig_IDsig (x_IDsig);
153 Sig_DOTsig::Sig_DOTsig (Sig x_1, Id x_2)
154 : a_Sig(tag_DOTsig), _1(x_1), _2(x_2)
157 a_Sig * DOTsig (Sig x_1, Id x_2)
159 return new Sig_DOTsig (x_1, x_2);
161 Sig_APPsig::Sig_APPsig (Sig x_1, Sigs x_2)
162 : a_Sig(tag_APPsig), _1(x_1), _2(x_2)
165 a_Sig * APPsig (Sig x_1, Sigs x_2)
167 return new Sig_APPsig (x_1, x_2);
169 Sig_DEFsig::Sig_DEFsig (Defs x_DEFsig)
170 : a_Sig(tag_DEFsig), DEFsig(x_DEFsig)
173 a_Sig * DEFsig (Defs x_DEFsig)
175 return new Sig_DEFsig (x_DEFsig);
177 Sig_LAMBDAsig::Sig_LAMBDAsig (LabSigs x_1, Sig x_2)
178 : a_Sig(tag_LAMBDAsig), _1(x_1), _2(x_2)
181 a_Sig * LAMBDAsig (LabSigs x_1, Sig x_2)
183 return new Sig_LAMBDAsig (x_1, x_2);
187 ///////////////////////////////////////////////////////////////////////////////
189 // Instantiation of datatype Stmt
191 ///////////////////////////////////////////////////////////////////////////////
192 #line 18 "setl-ast.pcc"
193 Stmt_ASSIGNstmt::Stmt_ASSIGNstmt (Exp x_1, Exp x_2)
194 : a_Stmt(tag_ASSIGNstmt), _1(x_1), _2(x_2)
197 a_Stmt * ASSIGNstmt (Exp x_1, Exp x_2)
199 return new Stmt_ASSIGNstmt (x_1, x_2);
201 Stmt_BLOCKstmt::Stmt_BLOCKstmt (Defs x_1, Stmts x_2)
202 : a_Stmt(tag_BLOCKstmt), _1(x_1), _2(x_2)
205 a_Stmt * BLOCKstmt (Defs x_1, Stmts x_2)
207 return new Stmt_BLOCKstmt (x_1, x_2);
209 Stmt_WHILEstmt::Stmt_WHILEstmt (Exp x_1, Stmt x_2)
210 : a_Stmt(tag_WHILEstmt), _1(x_1), _2(x_2)
213 a_Stmt * WHILEstmt (Exp x_1, Stmt x_2)
215 return new Stmt_WHILEstmt (x_1, x_2);
217 Stmt_IFstmt::Stmt_IFstmt (Exp x_1, Stmt x_2, Stmt x_3)
218 : a_Stmt(tag_IFstmt), _1(x_1), _2(x_2), _3(x_3)
221 a_Stmt * IFstmt (Exp x_1, Stmt x_2, Stmt x_3)
223 return new Stmt_IFstmt (x_1, x_2, x_3);
225 Stmt_MATCHstmt::Stmt_MATCHstmt (Decl x_MATCHstmt)
226 : a_Stmt(tag_MATCHstmt), MATCHstmt(x_MATCHstmt)
229 a_Stmt * MATCHstmt (Decl x_MATCHstmt)
231 return new Stmt_MATCHstmt (x_MATCHstmt);
233 Stmt_REWRITEstmt::Stmt_REWRITEstmt (Decl x_REWRITEstmt)
234 : a_Stmt(tag_REWRITEstmt), REWRITEstmt(x_REWRITEstmt)
237 a_Stmt * REWRITEstmt (Decl x_REWRITEstmt)
239 return new Stmt_REWRITEstmt (x_REWRITEstmt);
241 Stmt_REPLACEMENTstmt::Stmt_REPLACEMENTstmt (Decl x_REPLACEMENTstmt)
242 : a_Stmt(tag_REPLACEMENTstmt), REPLACEMENTstmt(x_REPLACEMENTstmt)
245 a_Stmt * REPLACEMENTstmt (Decl x_REPLACEMENTstmt)
247 return new Stmt_REPLACEMENTstmt (x_REPLACEMENTstmt);
249 Stmt_FORALLstmt::Stmt_FORALLstmt (Generators x_1, Stmt x_2)
250 : a_Stmt(tag_FORALLstmt), _1(x_1), _2(x_2)
253 a_Stmt * FORALLstmt (Generators x_1, Stmt x_2)
255 return new Stmt_FORALLstmt (x_1, x_2);
257 Stmt_RETURNstmt::Stmt_RETURNstmt (Exp x_RETURNstmt)
258 : a_Stmt(tag_RETURNstmt), RETURNstmt(x_RETURNstmt)
261 a_Stmt * RETURNstmt (Exp x_RETURNstmt)
263 return new Stmt_RETURNstmt (x_RETURNstmt);
267 ///////////////////////////////////////////////////////////////////////////////
269 // Instantiation of datatype List<Def>
271 ///////////////////////////////////////////////////////////////////////////////
272 #line 18 "setl-ast.pcc"
273 #ifdef PROP_EXPLICIT_TEMPLATE_INSTANTIATION
274 template class a_List<Def>;
275 template a_List<Def> * list_1_(Stmt x_1, a_List<Stmt> * x_2);
276 template a_List<Def> * list_1_(Stmt x_list_1_);
277 template int boxed(const a_List<Def> *);
278 template int untag(const a_List<Def> *);
279 #endif /* PROP_EXPLICIT_TEMPLATE_INSTANTIATION */
281 ///////////////////////////////////////////////////////////////////////////////
283 // Instantiation of datatype List<Sig>
285 ///////////////////////////////////////////////////////////////////////////////
286 #line 18 "setl-ast.pcc"
287 #ifdef PROP_EXPLICIT_TEMPLATE_INSTANTIATION
288 template class a_List<Sig>;
289 template a_List<Sig> * list_1_(Def x_1, a_List<Def> * x_2);
290 template a_List<Sig> * list_1_(Def x_list_1_);
291 template int boxed(const a_List<Sig> *);
292 template int untag(const a_List<Sig> *);
293 #endif /* PROP_EXPLICIT_TEMPLATE_INSTANTIATION */
295 ///////////////////////////////////////////////////////////////////////////////
297 // Instantiation of datatype List<LabSig>
299 ///////////////////////////////////////////////////////////////////////////////
300 #line 18 "setl-ast.pcc"
301 #ifdef PROP_EXPLICIT_TEMPLATE_INSTANTIATION
302 template class a_List<LabSig>;
303 template a_List<LabSig> * list_1_(Sig x_1, a_List<Sig> * x_2);
304 template a_List<LabSig> * list_1_(Sig x_list_1_);
305 template int boxed(const a_List<LabSig> *);
306 template int untag(const a_List<LabSig> *);
307 #endif /* PROP_EXPLICIT_TEMPLATE_INSTANTIATION */
309 ///////////////////////////////////////////////////////////////////////////////
311 // Instantiation of datatype List<Stmt>
313 ///////////////////////////////////////////////////////////////////////////////
314 #line 18 "setl-ast.pcc"
315 #ifdef PROP_EXPLICIT_TEMPLATE_INSTANTIATION
316 template class a_List<Stmt>;
317 template a_List<Stmt> * list_1_(LabSig x_1, a_List<LabSig> * x_2);
318 template a_List<Stmt> * list_1_(LabSig x_list_1_);
319 template int boxed(const a_List<Stmt> *);
320 template int untag(const a_List<Stmt> *);
321 #endif /* PROP_EXPLICIT_TEMPLATE_INSTANTIATION */
323 #line 20 "setl-ast.pcc"
324 #line 20 "setl-ast.pcc"
327 ///////////////////////////////////////////////////////////////////////////////
329 // The rest of pretty printing functions for definitions and statements
331 ///////////////////////////////////////////////////////////////////////////////
333 ///////////////////////////////////////////////////////////////////////////////
335 // Pretty print a signature
337 ///////////////////////////////////////////////////////////////////////////////
338 std::ostream& operator << (std::ostream& f, Sig s)
340 #line 34 "setl-ast.pcc"
341 #line 40 "setl-ast.pcc"
343 if (s) {
344 switch (s->tag__) {
345 case a_Sig::tag_IDsig: {
346 #line 36 "setl-ast.pcc"
347 f << ((Sig_IDsig *)s)->IDsig;
348 #line 36 "setl-ast.pcc"
349 } break;
350 case a_Sig::tag_DOTsig: {
351 #line 37 "setl-ast.pcc"
352 f << ((Sig_DOTsig *)s)->_1 << '.' << ((Sig_DOTsig *)s)->_2;
353 #line 37 "setl-ast.pcc"
354 } break;
355 case a_Sig::tag_APPsig: {
356 #line 38 "setl-ast.pcc"
357 f << ((Sig_APPsig *)s)->_1 << '(' << ((Sig_APPsig *)s)->_2 << ')';
358 #line 38 "setl-ast.pcc"
359 } break;
360 case a_Sig::tag_DEFsig: {
361 #line 39 "setl-ast.pcc"
362 f << "<def>";
363 #line 39 "setl-ast.pcc"
364 } break;
365 default: {
366 #line 40 "setl-ast.pcc"
367 f << "<lambda>";
368 #line 40 "setl-ast.pcc"
369 } break;
371 } else {
372 #line 35 "setl-ast.pcc"
373 f << "none";
374 #line 35 "setl-ast.pcc"
377 #line 41 "setl-ast.pcc"
378 #line 41 "setl-ast.pcc"
380 return f;
383 ///////////////////////////////////////////////////////////////////////////////
385 // Pretty print a signature list
387 ///////////////////////////////////////////////////////////////////////////////
388 std::ostream& operator << (std::ostream& f, Sigs ss)
390 #line 51 "setl-ast.pcc"
391 #line 53 "setl-ast.pcc"
393 for (;;) {
394 if (ss) {
395 if (ss->_2) {
396 #line 53 "setl-ast.pcc"
397 f << ss->_1 << ", "; ss = ss->_2;
398 #line 53 "setl-ast.pcc"
399 } else {
400 #line 52 "setl-ast.pcc"
401 f << ss->_1; ss =
402 #line 52 "setl-ast.pcc"
403 #line 52 "setl-ast.pcc"
404 nil_1_
405 #line 52 "setl-ast.pcc"
406 #line 52 "setl-ast.pcc"
408 #line 52 "setl-ast.pcc"
410 } else { goto L1; }
412 L1:;
414 #line 54 "setl-ast.pcc"
415 #line 54 "setl-ast.pcc"
417 return f;
420 ///////////////////////////////////////////////////////////////////////////////
422 // Pretty print a statement
424 ///////////////////////////////////////////////////////////////////////////////
425 std::ostream& operator << (std::ostream& f, Stmt s)
428 #line 65 "setl-ast.pcc"
429 #line 82 "setl-ast.pcc"
431 if (s) {
432 switch (s->tag__) {
433 case a_Stmt::tag_ASSIGNstmt: {
434 #line 67 "setl-ast.pcc"
435 f << ((Stmt_ASSIGNstmt *)s)->_1 << " := " << ((Stmt_ASSIGNstmt *)s)->_2 << ';';
436 #line 67 "setl-ast.pcc"
437 } break;
438 case a_Stmt::tag_BLOCKstmt: {
439 #line 68 "setl-ast.pcc"
440 f << ((Stmt_BLOCKstmt *)s)->_2;
441 #line 68 "setl-ast.pcc"
442 } break;
443 case a_Stmt::tag_WHILEstmt: {
444 #line 70 "setl-ast.pcc"
445 f << "while " << ((Stmt_WHILEstmt *)s)->_1 << " loop " << ((Stmt_WHILEstmt *)s)->_2 << " end loop";
446 #line 70 "setl-ast.pcc"
447 } break;
448 case a_Stmt::tag_IFstmt: {
449 #line 72 "setl-ast.pcc"
450 f << "if " << ((Stmt_IFstmt *)s)->_1 << " then " << ((Stmt_IFstmt *)s)->_2 << " else " << ((Stmt_IFstmt *)s)->_3 << "end if";
451 #line 72 "setl-ast.pcc"
452 } break;
453 case a_Stmt::tag_MATCHstmt: {
454 #line 78 "setl-ast.pcc"
455 f << "match ...";
456 #line 78 "setl-ast.pcc"
457 } break;
458 case a_Stmt::tag_REWRITEstmt: {
459 #line 80 "setl-ast.pcc"
460 f << "rewrite ...";
461 #line 80 "setl-ast.pcc"
462 } break;
463 case a_Stmt::tag_REPLACEMENTstmt: {
464 #line 82 "setl-ast.pcc"
465 f << "rewrite ...";
466 #line 82 "setl-ast.pcc"
467 } break;
468 case a_Stmt::tag_FORALLstmt: {
469 #line 74 "setl-ast.pcc"
470 f << "forall " << ((Stmt_FORALLstmt *)s)->_1 << " loop " << ((Stmt_FORALLstmt *)s)->_2 << "end loop";
471 #line 74 "setl-ast.pcc"
472 } break;
473 default: {
474 #line 76 "setl-ast.pcc"
475 f << "return " << ((Stmt_RETURNstmt *)s)->RETURNstmt << ';';
476 #line 76 "setl-ast.pcc"
477 } break;
479 } else {
480 #line 66 "setl-ast.pcc"
481 f << "skip;";
482 #line 66 "setl-ast.pcc"
485 #line 83 "setl-ast.pcc"
486 #line 83 "setl-ast.pcc"
488 return f;
491 ///////////////////////////////////////////////////////////////////////////////
493 // Pretty print a list of statements
495 ///////////////////////////////////////////////////////////////////////////////
496 std::ostream& operator << (std::ostream& f, Stmts s)
498 #line 93 "setl-ast.pcc"
499 #line 95 "setl-ast.pcc"
501 for (;;) {
502 if (s) {
503 if (s->_2) {
504 #line 95 "setl-ast.pcc"
505 f << s->_1 << " "; s = s->_2;
506 #line 95 "setl-ast.pcc"
507 } else {
508 #line 94 "setl-ast.pcc"
509 f << s->_1; s =
510 #line 94 "setl-ast.pcc"
511 #line 94 "setl-ast.pcc"
512 nil_1_
513 #line 94 "setl-ast.pcc"
514 #line 94 "setl-ast.pcc"
516 #line 94 "setl-ast.pcc"
518 } else { goto L2; }
520 L2:;
522 #line 96 "setl-ast.pcc"
523 #line 96 "setl-ast.pcc"
525 return f;
528 ///////////////////////////////////////////////////////////////////////////////
530 // Pretty print a generator expression
532 ///////////////////////////////////////////////////////////////////////////////
533 std::ostream& operator << (std::ostream& f, Generator b)
535 #line 106 "setl-ast.pcc"
536 #line 111 "setl-ast.pcc"
538 #line 108 "setl-ast.pcc"
539 f << b->pat;
540 if (b->guard != NOexp) f << " | " << b->guard;
541 f << " <- " << b->exp;
543 #line 111 "setl-ast.pcc"
545 #line 112 "setl-ast.pcc"
546 #line 112 "setl-ast.pcc"
548 return f;
551 ///////////////////////////////////////////////////////////////////////////////
553 // Pretty print a list of generator expressions
555 ///////////////////////////////////////////////////////////////////////////////
556 std::ostream& operator << (std::ostream& f, Generators b)
558 #line 122 "setl-ast.pcc"
559 #line 124 "setl-ast.pcc"
561 for (;;) {
562 if (b) {
563 if (b->_2) {
564 #line 124 "setl-ast.pcc"
565 f << b->_1 << ", "; b = b->_2;
566 #line 124 "setl-ast.pcc"
567 } else {
568 #line 123 "setl-ast.pcc"
569 f << b->_1; b =
570 #line 123 "setl-ast.pcc"
571 #line 123 "setl-ast.pcc"
572 nil_1_
573 #line 123 "setl-ast.pcc"
574 #line 123 "setl-ast.pcc"
576 #line 123 "setl-ast.pcc"
578 } else { goto L3; }
580 L3:;
582 #line 125 "setl-ast.pcc"
583 #line 125 "setl-ast.pcc"
585 return f;
587 #line 128 "setl-ast.pcc"
589 ------------------------------- Statistics -------------------------------
590 Merge matching rules = yes
591 Number of DFA nodes merged = 6
592 Number of ifs generated = 8
593 Number of switches generated = 2
594 Number of labels = 0
595 Number of gotos = 0
596 Adaptive matching = enabled
597 Fast string matching = disabled
598 Inline downcasts = enabled
599 --------------------------------------------------------------------------