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 "rwgen2.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_QUARK_USED
9 ///////////////////////////////////////////////////////////////////////////////
11 ///////////////////////////////////////////////////////////////////////////////
12 static const Quark
_r_w_g_e_n_2co_c_c_Q2("() {}\n");
13 static const Quark
_r_w_g_e_n_2co_c_c_Q1("\npublic:\n inline ");
15 ///////////////////////////////////////////////////////////////////////////////
17 // This file implements the 'rewrite (x) { ... }' construct.
18 // We'll transform this construct into the equivalent 'rewrite class ...'
19 // and 'rewrite id { ... };' statements.
21 ///////////////////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////////////////
31 // Method for compiling a 'rewrite (x) { ... }' statement.
33 ///////////////////////////////////////////////////////////////////////////////
34 void RewritingCompiler::gen_rewriting
35 ( Protocols protocols
,
42 { MEM::use_global_pools();
43 Id rewriter_name
= Quark(options
.mangled_file_prefix
,vars
.new_label());
47 (qualifiers
& ~QUALapplicative
) |
48 (dest
== NOexp
? QUALnone
: QUALapplicative
);
50 // Get the return and argument types
60 exp_ty
= ret_ty
= protocols
->_1
->ty
;
65 error("%Lempty type list in rewrite (...) ...");
71 exp_ty
= protocols
->_1
->ty
; ret_ty
= void_ty
;
80 // If it is destructive, use call by reference
81 if (! (qual
& QUALapplicative
)) exp_ty
= mkrefty(exp_ty
);
83 // Print the interface to the auxiliary function
84 pr("%+%^extern %t %s_rewrite(%t);", ret_ty
, "", rewriter_name
, exp_ty
, "");
86 // Generate the rewriting call
93 pr("%^%e = %s_rewrite(%e);", dest
, rewriter_name
, exp
);
97 pr("%^%s_rewrite(%e);", rewriter_name
, exp
);
101 #line 53 "rwgen2.pcc"
102 #line 53 "rwgen2.pcc"
107 // Add to the list of outstanding rewriting classes
108 Decl body
= OPAQUEdecl(
110 #line 59 "rwgen2.pcc"
111 #line 59 "rwgen2.pcc"
112 _r_w_g_e_n_2co_c_c_Q1
113 #line 59 "rwgen2.pcc"
114 #line 59 "rwgen2.pcc"
116 #line 59 "rwgen2.pcc"
117 #line 59 "rwgen2.pcc"
118 _r_w_g_e_n_2co_c_c_Q2
119 #line 59 "rwgen2.pcc"
120 #line 59 "rwgen2.pcc"
123 CLASSDEFdecl(new RewriteClass(rewriter_name
,protocols
,
124 #line 61 "rwgen2.pcc"
125 #line 61 "rwgen2.pcc"
127 #line 61 "rwgen2.pcc"
128 #line 61 "rwgen2.pcc"
130 #line 61 "rwgen2.pcc"
131 #line 61 "rwgen2.pcc"
133 #line 61 "rwgen2.pcc"
134 #line 61 "rwgen2.pcc"
137 #line 62 "rwgen2.pcc"
138 #line 62 "rwgen2.pcc"
139 list_1_(new_def
,list_1_(REWRITEdecl(rewriter_name
,Is
,rules
),rewriters
))
140 #line 62 "rwgen2.pcc"
141 #line 62 "rwgen2.pcc"
143 MEM::use_local_pools();
146 ///////////////////////////////////////////////////////////////////////////////
148 // Method for compiling rewrite classes for the 'rewrite (...) { ... }'
151 ///////////////////////////////////////////////////////////////////////////////
152 void RewritingCompiler::gen_rewriters()
154 debug_msg("[Generating the rewriters in this file]\n");
155 for_each (Decl
, d
, rewriters
)
158 #line 77 "rwgen2.pcc"
159 #line 111 "rwgen2.pcc"
163 case a_Decl::tag_CLASSDEFdecl
: {
165 #line 78 "rwgen2.pcc"
166 ((((Decl_CLASSDEFdecl
*)d
)->CLASSDEFdecl
->class_type
== ClassDefinition::REWRITE_CLASS
) && ((Decl_CLASSDEFdecl
*)d
)->CLASSDEFdecl
->protocols
)
167 #line 80 "rwgen2.pcc"
170 #line 81 "rwgen2.pcc"
171 Id id
= ((Decl_CLASSDEFdecl
*)d
)->CLASSDEFdecl
->class_name
;
172 Ty ty
= ((Decl_CLASSDEFdecl
*)d
)->CLASSDEFdecl
->protocols
->_1
->ty
;
173 TyQual qual
= ((Decl_CLASSDEFdecl
*)d
)->CLASSDEFdecl
->qualifiers
;
174 // If it is destructive, use call by reference
175 Bool is_applicative
= qual
& QUALapplicative
;
176 Bool do_traversal
= qual
& QUALtreeparser
;
177 Ty exp_ty
= is_applicative
? ty
: mkrefty(ty
);
178 Ty ret_ty
= is_applicative
? ty
: void_ty
;
181 pr ("%^%t %s_rewrite(%t _x_) ", ret_ty
, "", id
, exp_ty
, "");
182 // declare the rewriter
183 pr ("%^{ %s _r_;", id
);
186 { if (is_applicative
)
187 { pr ("%^ return _r_.reduce(_r_(_x_));"); }
189 { pr ("%^ _r_(_x_); %s_r_.reduce(_x_);",
190 ret_ty
== void_ty
? "" : "return ");
193 { if (is_applicative
)
194 { pr ("%^ return _r_(_x_);"); }
196 { pr ("%^ _r_(_x_);"); }
200 #line 109 "rwgen2.pcc"
205 default: { goto L4
; } break;
209 #line 111 "rwgen2.pcc"
210 #line 111 "rwgen2.pcc"
213 debug_msg("[Finished generating the rewriters in this file]\n");
215 #line 115 "rwgen2.pcc"
217 ------------------------------- Statistics -------------------------------
218 Merge matching rules = yes
219 Number of DFA nodes merged = 287
220 Number of ifs generated = 6
221 Number of switches generated = 1
224 Adaptive matching = enabled
225 Fast string matching = disabled
226 Inline downcasts = enabled
227 --------------------------------------------------------------------------