gcc config
[prop.git] / prop-src / timespace.cc
bloba87c9f1c413c3fd2c73d2566299a6310307c7818
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
9 #include <propdefs.h>
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 ///////////////////////////////////////////////////////////////////////////////
18 #include <math.h>
19 #include <iostream>
20 #include "basics.h"
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)
149 : TIME(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)
165 : SPACE(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 std::ostream& operator << (std::ostream& f, Complexity c)
185 #line 26 "timespace.pcc"
186 #line 36 "timespace.pcc"
188 switch (c->tag__) {
189 case a_Complexity::tag_Var: {
190 #line 27 "timespace.pcc"
191 f << ((Complexity_Var *)c)->Var;
192 #line 27 "timespace.pcc"
193 } break;
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"
198 } break;
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"
203 } break;
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"
208 } break;
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"
213 } break;
214 case a_Complexity::tag_Log: {
215 #line 32 "timespace.pcc"
216 f << "log " << ((Complexity_Log *)c)->Log;
217 #line 32 "timespace.pcc"
218 } break;
219 case a_Complexity::tag_Const: {
220 #line 33 "timespace.pcc"
221 f << ((Complexity_Const *)c)->Const;
222 #line 33 "timespace.pcc"
223 } break;
224 case a_Complexity::tag_BigOh: {
225 #line 34 "timespace.pcc"
226 f << "O(" << ((Complexity_BigOh *)c)->BigOh << ')';
227 #line 34 "timespace.pcc"
228 } break;
229 case a_Complexity::tag_Omega: {
230 #line 35 "timespace.pcc"
231 f << "Omega(" << ((Complexity_Omega *)c)->Omega << ')';
232 #line 35 "timespace.pcc"
233 } break;
234 default: {
235 #line 36 "timespace.pcc"
236 f << "o(" << ((Complexity_LittleOh *)c)->LittleOh << ')';
237 #line 36 "timespace.pcc"
238 } break;
241 #line 37 "timespace.pcc"
242 #line 37 "timespace.pcc"
244 return f;
247 ///////////////////////////////////////////////////////////////////////////////
249 // Pretty print the time complexity
251 ///////////////////////////////////////////////////////////////////////////////
252 std::ostream& operator << (std::ostream& f, Time t)
253 { return f << "Time(" << t << ")"; }
255 ///////////////////////////////////////////////////////////////////////////////
257 // Pretty print the space complexity
259 ///////////////////////////////////////////////////////////////////////////////
260 std::ostream& operator << (std::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"
277 return c;
279 #line 72 "timespace.pcc"
280 class _t_i_m_e_s_p_a_c_eco_X1 : public BURS {
281 private:
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
284 public:
285 struct _t_i_m_e_s_p_a_c_eco_X1_StateRec * stack__, * stack_top__;
286 public:
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); }
291 private:
292 public:
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_;
297 _r_(_x_);
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
307 #else
308 static const char * _t_i_m_e_s_p_a_c_eco_X1_file_name = "timespace.pcc";
309 #endif
311 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_1[2][2] = {
312 { 0, 0 },
313 { 0, 2 }
317 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_2[2][2] = {
318 { 0, 0 },
319 { 0, 3 }
323 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_3[2][2] = {
324 { 0, 0 },
325 { 0, 4 }
329 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_4[2][2] = {
330 { 0, 0 },
331 { 0, 5 }
335 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_theta_5[2] = {
336 0, 6
340 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_1_0[7] = {
341 0, 1, 0, 0, 0, 0, 0
345 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_1_1[7] = {
346 0, 1, 0, 0, 0, 0, 0
350 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_2_0[7] = {
351 0, 1, 0, 0, 0, 0, 0
355 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_2_1[7] = {
356 0, 1, 0, 0, 0, 0, 0
360 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_3_0[7] = {
361 0, 1, 0, 0, 0, 0, 0
365 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_3_1[7] = {
366 0, 1, 0, 0, 0, 0, 0
370 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_4_0[7] = {
371 0, 1, 0, 0, 0, 0, 0
375 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_4_1[7] = {
376 0, 1, 0, 0, 0, 0, 0
380 static const TreeTables::ShortState _t_i_m_e_s_p_a_c_eco_X1_mu_5_0[7] = {
381 0, 1, 0, 0, 0, 0, 0
385 inline void _t_i_m_e_s_p_a_c_eco_X1::labeler(char const * redex,int& s__,int)
388 s__ = 0;
392 inline void _t_i_m_e_s_p_a_c_eco_X1::labeler(Quark redex,int& s__,int)
395 s__ = 0;
399 void _t_i_m_e_s_p_a_c_eco_X1::labeler (Complexity & redex, int& s__, int r__)
401 replacement__:
402 switch(redex->tag__) {
403 case a_Complexity::tag_Var: {
404 int s0__;
405 labeler(((Complexity_Var *)redex)->Var, s0__, r__);
406 s__ = 0;} break;
407 case a_Complexity::tag_Add: {
408 int s0__;
409 int s1__;
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: {
414 int s0__;
415 int s1__;
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: {
420 int s0__;
421 int s1__;
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: {
426 int s0__;
427 int s1__;
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: {
432 int s0__;
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: {
436 int s0__;
437 s0__ = 0; // double
438 s__ = 1;} break;
439 case a_Complexity::tag_BigOh: {
440 int s0__;
441 labeler(((Complexity_BigOh *)redex)->BigOh, s0__, r__);
442 s__ = 0;} break;
443 case a_Complexity::tag_Omega: {
444 int s0__;
445 labeler(((Complexity_Omega *)redex)->Omega, s0__, r__);
446 s__ = 0;} break;
447 default: {
448 int s0__;
449 labeler(((Complexity_LittleOh *)redex)->LittleOh, s0__, r__);
450 s__ = 0;} break;
452 switch (s__) {
453 case 6: {
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"
458 } break;
459 case 5: {
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"
464 } break;
465 case 4: {
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"
470 } break;
471 case 3: {
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"
476 } break;
477 case 2: {
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"
482 } break;
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
493 Number of labels = 0
494 Number of gotos = 0
495 Adaptive matching = enabled
496 Fast string matching = disabled
497 Inline downcasts = enabled
498 --------------------------------------------------------------------------