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 "timespace.pcc".
5 ///////////////////////////////////////////////////////////////////////////////
7 #define PROP_REWRITING_USED
8 #define PROP_QUARK_USED
10 #line 1 "timespace.pcc"
11 ///////////////////////////////////////////////////////////////////////////////
13 // This file implements the time and space complexity
14 // datatypes. These datatypes are used to represent time and space
15 // complexity in the SETL-like extension language.
17 ///////////////////////////////////////////////////////////////////////////////
21 #include "timespace.h"
23 ///////////////////////////////////////////////////////////////////////////////
25 // Instantiate the time and space datatypes
27 ///////////////////////////////////////////////////////////////////////////////
28 #line 18 "timespace.pcc"
29 #line 18 "timespace.pcc"
30 ///////////////////////////////////////////////////////////////////////////////
32 // Interface specification of datatype Complexity
34 ///////////////////////////////////////////////////////////////////////////////
35 #line 18 "timespace.pcc"
38 ///////////////////////////////////////////////////////////////////////////////
40 // Interface specification of datatype Time
42 ///////////////////////////////////////////////////////////////////////////////
43 #line 18 "timespace.pcc"
46 ///////////////////////////////////////////////////////////////////////////////
48 // Interface specification of datatype Space
50 ///////////////////////////////////////////////////////////////////////////////
51 #line 18 "timespace.pcc"
54 ///////////////////////////////////////////////////////////////////////////////
56 // Instantiation of datatype Complexity
58 ///////////////////////////////////////////////////////////////////////////////
59 #line 18 "timespace.pcc"
60 Complexity_Var::Complexity_Var (Id x_Var
)
61 : a_Complexity(tag_Var
), Var(x_Var
)
64 a_Complexity
* Var (Id x_Var
)
66 return new Complexity_Var (x_Var
);
68 Complexity_Add::Complexity_Add (Complexity x_1
, Complexity x_2
)
69 : a_Complexity(tag_Add
), _1(x_1
), _2(x_2
)
72 a_Complexity
* Add (Complexity x_1
, Complexity x_2
)
74 return new Complexity_Add (x_1
, x_2
);
76 Complexity_Mul::Complexity_Mul (Complexity x_1
, Complexity x_2
)
77 : a_Complexity(tag_Mul
), _1(x_1
), _2(x_2
)
80 a_Complexity
* Mul (Complexity x_1
, Complexity x_2
)
82 return new Complexity_Mul (x_1
, x_2
);
84 Complexity_Div::Complexity_Div (Complexity x_1
, Complexity x_2
)
85 : a_Complexity(tag_Div
), _1(x_1
), _2(x_2
)
88 a_Complexity
* Div (Complexity x_1
, Complexity x_2
)
90 return new Complexity_Div (x_1
, x_2
);
92 Complexity_Power::Complexity_Power (Complexity x_1
, Complexity x_2
)
93 : a_Complexity(tag_Power
), _1(x_1
), _2(x_2
)
96 a_Complexity
* Power (Complexity x_1
, Complexity x_2
)
98 return new Complexity_Power (x_1
, x_2
);
100 Complexity_Log::Complexity_Log (Complexity x_Log
)
101 : a_Complexity(tag_Log
), Log(x_Log
)
104 a_Complexity
* Log (Complexity x_Log
)
106 return new Complexity_Log (x_Log
);
108 Complexity_Const::Complexity_Const (double x_Const
)
109 : a_Complexity(tag_Const
), Const(x_Const
)
112 a_Complexity
* Const (double x_Const
)
114 return new Complexity_Const (x_Const
);
116 Complexity_BigOh::Complexity_BigOh (Complexity x_BigOh
)
117 : a_Complexity(tag_BigOh
), BigOh(x_BigOh
)
120 a_Complexity
* BigOh (Complexity x_BigOh
)
122 return new Complexity_BigOh (x_BigOh
);
124 Complexity_Omega::Complexity_Omega (Complexity x_Omega
)
125 : a_Complexity(tag_Omega
), Omega(x_Omega
)
128 a_Complexity
* Omega (Complexity x_Omega
)
130 return new Complexity_Omega (x_Omega
);
132 Complexity_LittleOh::Complexity_LittleOh (Complexity x_LittleOh
)
133 : a_Complexity(tag_LittleOh
), LittleOh(x_LittleOh
)
136 a_Complexity
* LittleOh (Complexity x_LittleOh
)
138 return new Complexity_LittleOh (x_LittleOh
);
142 ///////////////////////////////////////////////////////////////////////////////
144 // Instantiation of datatype Time
146 ///////////////////////////////////////////////////////////////////////////////
147 #line 18 "timespace.pcc"
148 a_Time::a_Time (Complexity x_TIME
)
152 a_Time
* TIME (Complexity x_TIME
)
154 return new a_Time (x_TIME
);
158 ///////////////////////////////////////////////////////////////////////////////
160 // Instantiation of datatype Space
162 ///////////////////////////////////////////////////////////////////////////////
163 #line 18 "timespace.pcc"
164 a_Space::a_Space (Complexity x_SPACE
)
168 a_Space
* SPACE (Complexity x_SPACE
)
170 return new a_Space (x_SPACE
);
174 #line 18 "timespace.pcc"
175 #line 18 "timespace.pcc"
178 ///////////////////////////////////////////////////////////////////////////////
180 // Pretty print the complexity
182 ///////////////////////////////////////////////////////////////////////////////
183 ostream
& operator << (ostream
& f
, Complexity c
)
185 #line 26 "timespace.pcc"
186 #line 36 "timespace.pcc"
189 case a_Complexity::tag_Var
: {
190 #line 27 "timespace.pcc"
191 f
<< ((Complexity_Var
*)c
)->Var
;
192 #line 27 "timespace.pcc"
194 case a_Complexity::tag_Add
: {
195 #line 28 "timespace.pcc"
196 f
<< '(' << ((Complexity_Add
*)c
)->_1
<< " + " << ((Complexity_Add
*)c
)->_2
<< ')';
197 #line 28 "timespace.pcc"
199 case a_Complexity::tag_Mul
: {
200 #line 29 "timespace.pcc"
201 f
<< '(' << ((Complexity_Mul
*)c
)->_1
<< " * " << ((Complexity_Mul
*)c
)->_2
<< ')';
202 #line 29 "timespace.pcc"
204 case a_Complexity::tag_Div
: {
205 #line 30 "timespace.pcc"
206 f
<< '(' << ((Complexity_Div
*)c
)->_1
<< " / " << ((Complexity_Div
*)c
)->_2
<< ')';
207 #line 30 "timespace.pcc"
209 case a_Complexity::tag_Power
: {
210 #line 31 "timespace.pcc"
211 f
<< '(' << ((Complexity_Power
*)c
)->_1
<< " ^ " << ((Complexity_Power
*)c
)->_2
<< ')';
212 #line 31 "timespace.pcc"
214 case a_Complexity::tag_Log
: {
215 #line 32 "timespace.pcc"
216 f
<< "log " << ((Complexity_Log
*)c
)->Log
;
217 #line 32 "timespace.pcc"
219 case a_Complexity::tag_Const
: {
220 #line 33 "timespace.pcc"
221 f
<< ((Complexity_Const
*)c
)->Const
;
222 #line 33 "timespace.pcc"
224 case a_Complexity::tag_BigOh
: {
225 #line 34 "timespace.pcc"
226 f
<< "O(" << ((Complexity_BigOh
*)c
)->BigOh
<< ')';
227 #line 34 "timespace.pcc"
229 case a_Complexity::tag_Omega
: {
230 #line 35 "timespace.pcc"
231 f
<< "Omega(" << ((Complexity_Omega
*)c
)->Omega
<< ')';
232 #line 35 "timespace.pcc"
235 #line 36 "timespace.pcc"
236 f
<< "o(" << ((Complexity_LittleOh
*)c
)->LittleOh
<< ')';
237 #line 36 "timespace.pcc"
241 #line 37 "timespace.pcc"
242 #line 37 "timespace.pcc"
247 ///////////////////////////////////////////////////////////////////////////////
249 // Pretty print the time complexity
251 ///////////////////////////////////////////////////////////////////////////////
252 ostream
& operator << (ostream
& f
, Time t
)
253 { return f
<< "Time(" << t
<< ")"; }
255 ///////////////////////////////////////////////////////////////////////////////
257 // Pretty print the space complexity
259 ///////////////////////////////////////////////////////////////////////////////
260 ostream
& operator << (ostream
& f
, Space s
)
261 { return f
<< "Space(" << s
<< ")"; }
263 ///////////////////////////////////////////////////////////////////////////////
265 // Function to simplify a complexity expression
267 ///////////////////////////////////////////////////////////////////////////////
268 Complexity
simplify (Complexity c
)
270 #line 63 "timespace.pcc"
271 #line 69 "timespace.pcc"
272 extern void _t_i_m_e_s_p_a_c_eco_X1_rewrite(Complexity
& );
273 _t_i_m_e_s_p_a_c_eco_X1_rewrite(c
);
274 #line 69 "timespace.pcc"
275 #line 69 "timespace.pcc"
279 #line 72 "timespace.pcc"
280 class _t_i_m_e_s_p_a_c_eco_X1
: public BURS
{
282 _t_i_m_e_s_p_a_c_eco_X1(const _t_i_m_e_s_p_a_c_eco_X1
&); // no copy constructor
283 void operator = (const _t_i_m_e_s_p_a_c_eco_X1
&); // no assignment
285 struct _t_i_m_e_s_p_a_c_eco_X1_StateRec
* stack__
, * stack_top__
;
287 void labeler(const char *, int&, int);
288 void labeler(Quark
, int&, int);
289 void labeler(Complexity
& redex
, int&, int);
290 inline virtual void operator () (Complexity
& redex
) { int s
; labeler(redex
,s
,0); }
293 inline _t_i_m_e_s_p_a_c_eco_X1() {}
295 void _t_i_m_e_s_p_a_c_eco_X1_rewrite(Complexity
& _x_
)
296 { _t_i_m_e_s_p_a_c_eco_X1 _r_
;
300 ///////////////////////////////////////////////////////////////////////////////
302 // This macro can be redefined by the user for debugging
304 ///////////////////////////////////////////////////////////////////////////////
305 #ifndef DEBUG__t_i_m_e_s_p_a_c_eco_X1
306 #define DEBUG__t_i_m_e_s_p_a_c_eco_X1(repl,redex,file,line,rule) repl
308 static const char * _t_i_m_e_s_p_a_c_eco_X1_file_name
= "timespace.pcc";
311 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_1
[2][2] = {
317 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_2
[2][2] = {
323 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_3
[2][2] = {
329 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_4
[2][2] = {
335 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_5
[2] = {
340 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_1_0
[7] = {
345 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_1_1
[7] = {
350 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_2_0
[7] = {
355 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_2_1
[7] = {
360 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_3_0
[7] = {
365 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_3_1
[7] = {
370 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_4_0
[7] = {
375 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_4_1
[7] = {
380 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_5_0
[7] = {
385 inline void _t_i_m_e_s_p_a_c_eco_X1::labeler(char const * redex
,int& s__
,int)
392 inline void _t_i_m_e_s_p_a_c_eco_X1::labeler(Quark redex
,int& s__
,int)
399 void _t_i_m_e_s_p_a_c_eco_X1::labeler (Complexity
& redex
, int& s__
, int r__
)
402 switch(redex
->tag__
) {
403 case a_Complexity::tag_Var
: {
405 labeler(((Complexity_Var
*)redex
)->Var
, s0__
, r__
);
407 case a_Complexity::tag_Add
: {
410 labeler(((Complexity_Add
*)redex
)->_1
, s0__
, r__
);
411 labeler(((Complexity_Add
*)redex
)->_2
, s1__
, r__
);
412 s__
= _t_i_m_e_s_p_a_c_eco_X1_theta_1
[_t_i_m_e_s_p_a_c_eco_X1_mu_1_0
[s0__
]][_t_i_m_e_s_p_a_c_eco_X1_mu_1_1
[s1__
]]; } break;
413 case a_Complexity::tag_Mul
: {
416 labeler(((Complexity_Mul
*)redex
)->_1
, s0__
, r__
);
417 labeler(((Complexity_Mul
*)redex
)->_2
, s1__
, r__
);
418 s__
= _t_i_m_e_s_p_a_c_eco_X1_theta_2
[_t_i_m_e_s_p_a_c_eco_X1_mu_2_0
[s0__
]][_t_i_m_e_s_p_a_c_eco_X1_mu_2_1
[s1__
]]; } break;
419 case a_Complexity::tag_Div
: {
422 labeler(((Complexity_Div
*)redex
)->_1
, s0__
, r__
);
423 labeler(((Complexity_Div
*)redex
)->_2
, s1__
, r__
);
424 s__
= _t_i_m_e_s_p_a_c_eco_X1_theta_3
[_t_i_m_e_s_p_a_c_eco_X1_mu_3_0
[s0__
]][_t_i_m_e_s_p_a_c_eco_X1_mu_3_1
[s1__
]]; } break;
425 case a_Complexity::tag_Power
: {
428 labeler(((Complexity_Power
*)redex
)->_1
, s0__
, r__
);
429 labeler(((Complexity_Power
*)redex
)->_2
, s1__
, r__
);
430 s__
= _t_i_m_e_s_p_a_c_eco_X1_theta_4
[_t_i_m_e_s_p_a_c_eco_X1_mu_4_0
[s0__
]][_t_i_m_e_s_p_a_c_eco_X1_mu_4_1
[s1__
]]; } break;
431 case a_Complexity::tag_Log
: {
433 labeler(((Complexity_Log
*)redex
)->Log
, s0__
, r__
);
434 s__
= _t_i_m_e_s_p_a_c_eco_X1_theta_5
[_t_i_m_e_s_p_a_c_eco_X1_mu_5_0
[s0__
]]; } break;
435 case a_Complexity::tag_Const
: {
439 case a_Complexity::tag_BigOh
: {
441 labeler(((Complexity_BigOh
*)redex
)->BigOh
, s0__
, r__
);
443 case a_Complexity::tag_Omega
: {
445 labeler(((Complexity_Omega
*)redex
)->Omega
, s0__
, r__
);
449 labeler(((Complexity_LittleOh
*)redex
)->LittleOh
, s0__
, r__
);
454 #line 68 "timespace.pcc"
455 { redex
= DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const(log(((Complexity_Const
*)((Complexity_Log
*)redex
)->Log
)->Const
)),redex
,_t_i_m_e_s_p_a_c_eco_X1_file_name
,68,"Log Const i: ...");
456 r__
= 1; goto replacement__
; }
457 #line 69 "timespace.pcc"
460 #line 67 "timespace.pcc"
461 { redex
= DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const(exp((log(((Complexity_Const
*)((Complexity_Power
*)redex
)->_1
)->Const
) * ((Complexity_Const
*)((Complexity_Power
*)redex
)->_2
)->Const
))),redex
,_t_i_m_e_s_p_a_c_eco_X1_file_name
,67,"Power (Const i, Const j): ...");
462 r__
= 1; goto replacement__
; }
463 #line 68 "timespace.pcc"
466 #line 66 "timespace.pcc"
467 { redex
= DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const((((Complexity_Const
*)((Complexity_Div
*)redex
)->_1
)->Const
/ ((Complexity_Const
*)((Complexity_Div
*)redex
)->_2
)->Const
)),redex
,_t_i_m_e_s_p_a_c_eco_X1_file_name
,66,"Div (Const i, Const j): ...");
468 r__
= 1; goto replacement__
; }
469 #line 67 "timespace.pcc"
472 #line 65 "timespace.pcc"
473 { redex
= DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const((((Complexity_Const
*)((Complexity_Mul
*)redex
)->_1
)->Const
* ((Complexity_Const
*)((Complexity_Mul
*)redex
)->_2
)->Const
)),redex
,_t_i_m_e_s_p_a_c_eco_X1_file_name
,65,"Mul (Const i, Const j): ...");
474 r__
= 1; goto replacement__
; }
475 #line 66 "timespace.pcc"
478 #line 64 "timespace.pcc"
479 { redex
= DEBUG__t_i_m_e_s_p_a_c_eco_X1(Const((((Complexity_Const
*)((Complexity_Add
*)redex
)->_1
)->Const
+ ((Complexity_Const
*)((Complexity_Add
*)redex
)->_2
)->Const
)),redex
,_t_i_m_e_s_p_a_c_eco_X1_file_name
,64,"Add (Const i, Const j): ...");
480 r__
= 1; goto replacement__
; }
481 #line 65 "timespace.pcc"
488 ------------------------------- Statistics -------------------------------
489 Merge matching rules = yes
490 Number of DFA nodes merged = 0
491 Number of ifs generated = 0
492 Number of switches generated = 1
495 Adaptive matching = enabled
496 Fast string matching = disabled
497 Inline downcasts = enabled
498 --------------------------------------------------------------------------