minor
[prop.git] / tools / misc / ty_setl.cc
blob2bebabc61279c91370005af3b295c00a3eb64fca
1 //////////////////////////////////////////////////////////////////////////////
2 // This file is generated automatically using Prop (version 2.0 (pre-beta)),
3 // last updated on Jan 4th, 1995. Please be sure not to alter this file
4 // directly. Instead, refer to the original source file "ty_setl.pcc".
5 //////////////////////////////////////////////////////////////////////////////
6 #line 1 "ty_setl.pcc"
7 //////////////////////////////////////////////////////////////////////////////
8 // NOTICE:
9 //
10 // ADLib, Prop and their related set of tools and documentation are in the
11 // public domain. The author(s) of this software reserve no copyrights on
12 // the source code and any code generated using the tools. You are encouraged
13 // to use ADLib and Prop to develop software, in both academic and commercial
14 // settings, and are welcomed to incorporate any part of ADLib and Prop into
15 // your programs.
17 // Although you are under no obligation to do so, we strongly recommend that
18 // you give away all software developed using our tools.
20 // We also ask that credit be given to us when ADLib and/or Prop are used in
21 // your programs, and that this notice be preserved intact in all the source
22 // code.
24 // This software is still under development and we welcome(read crave for)
25 // any suggestions and help from the users.
27 // Allen Leung
28 // 1994
29 //////////////////////////////////////////////////////////////////////////////
31 //////////////////////////////////////////////////////////////////////////////
32 // This file implements the type analysis methods for the SETL sublanguage.
33 // Type analysis is used to:
34 // (a) Check for valid typing of the soruce program.
35 // (b) Select implementations of the set-theoretic data structures.
37 // For details, see Paige, Schwartz, Cai, et al.
38 //////////////////////////////////////////////////////////////////////////////
40 #include "irdef.h" // intermediate representations
41 #include "setl.h" // SETL abstract syntax
43 //////////////////////////////////////////////////////////////////////////////
44 // Method to infer the type a SETL expression when given an expression
45 // and an type binding environment.
46 //////////////////////////////////////////////////////////////////////////////
47 TY InferSETL::infer(EXPR e, Map<ID,TY>& env)
49 #line 42 "ty_setl.pcc"
50 { if (e) {
51 switch (e->untag()) {
52 case a_EXPR::tag_typed_exp: {
53 #line 44 "ty_setl.pcc"
55 } break;
56 case a_EXPR::tag_ident_exp: {
57 #line 45 "ty_setl.pcc"
58 return env[(_ident_exp(e)->ident_exp)];
59 } break;
60 case a_EXPR::tag_int_exp: {
61 #line 46 "ty_setl.pcc"
62 return Infer::integer_ty;
63 } break;
64 case a_EXPR::tag_real_exp: {
65 #line 47 "ty_setl.pcc"
66 return Infer::real_ty;
67 } break;
68 case a_EXPR::tag_string_exp: {
69 #line 48 "ty_setl.pcc"
70 return Infer::string_ty;
71 } break;
72 case a_EXPR::tag_char_exp: {
73 #line 49 "ty_setl.pcc"
74 return Infer::character_ty;
75 } break;
76 case a_EXPR::tag_app_exp: {
77 #line 50 "ty_setl.pcc"
79 } break;
80 case a_EXPR::tag_set_exp: {
81 #line 51 "ty_setl.pcc"
82 return set_ty(infer((_set_exp(e)->set_exp),env));
83 } break;
84 case a_EXPR::tag_multiset_exp: {
85 #line 52 "ty_setl.pcc"
86 return multiset_ty(infer((_multiset_exp(e)->multiset_exp),env));
87 } break;
88 case a_EXPR::tag_cons_exp: break;
89 case a_EXPR::tag_tuple_exp: {
90 #line 53 "ty_setl.pcc"
91 return tuple_ty(infer((_tuple_exp(e)->tuple_exp),env));
92 } break;
93 case a_EXPR::tag_map_exp: {
94 #line 54 "ty_setl.pcc"
95 return map_ty(infer((_map_exp(e)->map_exp),env));
96 } break;
97 case a_EXPR::tag_multimap_exp: {
98 #line 55 "ty_setl.pcc"
99 return multimap_ty(infer((_multimap_exp(e)->multimap_exp),env));
100 } break;
101 case a_EXPR::tag_record_exp: {
102 #line 56 "ty_setl.pcc"
103 return record_ty(infer((_record_exp(e)->record_exp),env));
104 } break;
105 case a_EXPR::tag_c_exp: {
106 #line 57 "ty_setl.pcc"
107 return var_ty(no_ty);
108 } break;
109 default:
110 } } else {
112 #line 42 "ty_setl.pcc"
113 return var_ty(no_ty);
117 #line 58 "ty_setl.pcc"
121 ----------------------------- Statistics -------------------------------
122 Number of decision nodes merged = 0
123 Number of switches generated = 1
124 Number of ifs generated = 1
125 Number of labels generated = 0
126 Number of gotos generated = 0
127 Number of temporary variables = 0
128 ------------------------------------------------------------------------