Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10982
Merged at revision: 11116
Proposed branch: lp:~zorba-coders/zorba/markos-scratch
Merge into: lp:zorba
Diff against target: 445 lines (+104/-121)
1 file modified
src/compiler/expression/expr_put.cpp (+104/-121)
To merge this branch: bzr merge lp:~zorba-coders/zorba/markos-scratch
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+132036@code.launchpad.net

Commit message

cosmetic changes in printout of expr graph

Description of the change

cosmetic changes in printout of expr graph

To post a comment you must log in.
Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job markos-scratch-2012-10-30T10-39-49.825Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/compiler/expression/expr_put.cpp'
2--- src/compiler/expression/expr_put.cpp 2012-10-26 07:13:42 +0000
3+++ src/compiler/expression/expr_put.cpp 2012-10-30 10:06:25 +0000
4@@ -54,42 +54,38 @@
5 namespace zorba
6 {
7
8-#define BEGIN_PUT_NO_LOCATION(LABEL) \
9- os << indent << #LABEL << expr_addr(this) << " [\n" << inc_indent
10-
11-#define BEGIN_PUT(LABEL) \
12- os << indent << #LABEL << expr_addr(this) \
13- << expr_loc(dynamic_cast<const expr*>(this)) << " [\n" << inc_indent
14-
15-#define BEGIN_PUT2(STRING) \
16- os << indent << STRING << expr_addr(this) \
17- << expr_loc(dynamic_cast<const expr*>(this)) << " [\n" << inc_indent
18-
19-#define BEGIN_PUT_NO_EOL(LABEL) \
20- os << indent << #LABEL << expr_addr(this) \
21- << expr_loc(dynamic_cast<const expr*>(this)) << " [ "
22-
23-#define BEGIN_PUT1(LABEL,S1) \
24- os << indent << #LABEL << ' ' << (S1) << expr_addr(this) \
25- << expr_loc(dynamic_cast<const expr*>(this)) << " [\n" << inc_indent
26+#define BEGIN_PUT(LABEL) \
27+ os << indent << #LABEL << expr_addr(this) \
28+ << " [\n" << inc_indent
29+
30+#define BEGIN_PUT_NL(LABEL) \
31+ os << indent << #LABEL << expr_addr(this) \
32+ << std::endl << indent << "[\n" << inc_indent
33+
34+#define BEGIN_PUT_MSG(MSG) \
35+ os << indent << MSG << expr_addr(this) \
36+ << " [\n" << inc_indent
37+
38+#define BEGIN_PUT_NO_EOL(LABEL) \
39+ os << indent << #LABEL << expr_addr(this) \
40+ << " [ "
41
42 #define END_PUT() \
43 os << dec_indent << indent << "]\n"; return os;
44
45-#define PUT_SUB( LABEL, EXPR ) \
46- if ( !(EXPR) ) ; else { os << indent << (LABEL) << "\n" << inc_indent; (EXPR)->put(os); os << dec_indent; }
47-
48-
49-static inline zstring qname_to_string(store::Item_t qname)
50-{
51- zstring result;
52- zstring pfx = qname->getPrefix();
53- zstring ns = qname->getNamespace();
54- if (! ns.empty())
55- result += pfx.str() + "[=" + ns.str() + "]:";
56- result += qname->getLocalName().str();
57- return result;
58-}
59+#define END_PUT_NO_RET() \
60+ os << dec_indent << indent << "]\n";
61+
62+
63+#define PUT_SUB( LABEL, EXPR ) \
64+ if ( !(EXPR) ) \
65+ ; \
66+ else \
67+ { \
68+ os << indent << (LABEL) << "\n" << inc_indent; \
69+ (EXPR)->put(os); \
70+ os << dec_indent; \
71+ }
72
73
74 static inline ostream& put_qname(store::Item_t qname, ostream& os)
75@@ -105,7 +101,7 @@
76
77 static inline string expr_addr(const void* e)
78 {
79- if (Properties::instance()->noTreeIds ())
80+ if (Properties::instance()->noTreeIds())
81 {
82 return "";
83 }
84@@ -150,15 +146,11 @@
85 std::ostream&
86 wrapper_expr::put(std::ostream& os) const
87 {
88-#ifdef VERBOSE
89- get_expr()->put(os);
90- return os;
91-#else
92 if (get_input()->get_expr_kind() == var_expr_kind)
93 {
94 const var_expr* varExpr = static_cast<const var_expr*>(get_input());
95
96- BEGIN_PUT_NO_EOL(var_ref) ;
97+ BEGIN_PUT_NO_EOL(vref) ;
98 put_qname(varExpr->get_name(), os);
99 os << expr_addr(varExpr) << " ]" << endl;
100 return os;
101@@ -169,21 +161,24 @@
102 get_input()->put(os);
103 END_PUT();
104 }
105-#endif
106 }
107
108 ostream& block_expr::put( ostream& os) const
109 {
110- BEGIN_PUT( block_expr );
111- for (checked_vector<expr*>::const_iterator i = this->theArgs.begin ();
112- i != theArgs.end (); i++)
113- (*i)->put (os);
114+ BEGIN_PUT_NL(block_expr);
115+
116+ checked_vector<expr*>::const_iterator i = this->theArgs.begin();
117+
118+ for (; i != theArgs.end(); i++)
119+ (*i)->put(os);
120+
121 END_PUT();
122 }
123
124+
125 ostream& var_expr::put(ostream& os) const
126 {
127- os << indent << "var kind=" << decode_var_kind(get_kind()) << expr_addr(this);
128+ os << indent << "var " << decode_var_kind(get_kind()) << expr_addr(this);
129 if (theName != NULL)
130 {
131 os << " name=";
132@@ -193,7 +188,7 @@
133 #if VERBOSE
134 if (theDeclaredType != NULL)
135 {
136- os << " type=" << theDeclaredType->toString();
137+ os << " type=" << theDeclaredType->toSchemaString();
138 }
139 #endif
140
141@@ -202,7 +197,7 @@
142 }
143
144
145-ostream& for_clause::put(ostream& os) const
146+ostream& forlet_clause::put(ostream& os) const
147 {
148 if (theKind == flwor_clause::for_clause)
149 {
150@@ -238,7 +233,7 @@
151
152 ostream& window_clause::put(ostream& os) const
153 {
154- BEGIN_PUT(WINDOW);
155+ BEGIN_PUT_NL(WINDOW);
156 theVarExpr->put(os);
157 PUT_SUB("IN", theDomainExpr);
158 PUT_SUB("START", theWinStartCond);
159@@ -249,7 +244,7 @@
160
161 ostream& flwor_wincond::vars::put(ostream& os) const
162 {
163- BEGIN_PUT_NO_LOCATION( flwor_wincond::vars );
164+ BEGIN_PUT(flwor_wincond::vars);
165 PUT_SUB( "AT", posvar );
166 PUT_SUB( "CURR", curr );
167 PUT_SUB( "NEXT", next );
168@@ -259,7 +254,7 @@
169
170 ostream& flwor_wincond::put(ostream& os) const
171 {
172- BEGIN_PUT_NO_LOCATION(flwor_wincond);
173+ BEGIN_PUT(flwor_wincond);
174 PUT_SUB("IN-VARS", &get_in_vars());
175 PUT_SUB("OUT-VARS", &get_out_vars());
176 PUT_SUB("WHEN", theCondExpr);
177@@ -269,9 +264,7 @@
178
179 ostream& group_clause::put(ostream& os) const
180 {
181- os << indent << "GROUP-BY" << expr_addr(this) << " ";
182-
183- os << endl << indent << "[\n" << inc_indent;
184+ BEGIN_PUT_NL(GROUPBY);
185
186 os << indent << "GROUPING SPECS";
187
188@@ -304,9 +297,7 @@
189
190 ostream& orderby_clause::put(ostream& os) const
191 {
192- BEGIN_PUT(orderby_clause);
193-
194- //os << indent << "ORDER BY ";
195+ BEGIN_PUT_NL(ORDERBY);
196
197 csize numColumns = num_columns();
198
199@@ -314,34 +305,21 @@
200 {
201 theOrderingExprs[i]->put(os);
202 }
203-#if 0
204- os << endl;
205
206- os << indent << "VAR REBINDS ";
207- for (unsigned i = 0; i < theRebindList.size (); i++)
208- {
209- os << "$";
210- put_qname(theRebindList[i].first->get_varname(), os);
211- os << " (" << theRebindList[i].first << " -> "
212- << theRebindList[i].second << ") ";
213- }
214- os << endl;
215-#endif
216 END_PUT();
217 }
218
219
220 ostream& materialize_clause::put(ostream& os) const
221 {
222- BEGIN_PUT(materialize_clause);
223-
224+ BEGIN_PUT_NL(MATERIALIZE);
225 END_PUT();
226 }
227
228
229 ostream& flwor_expr::put(ostream& os) const
230 {
231- BEGIN_PUT(flwor_expr);
232+ BEGIN_PUT_NL(flwor_expr);
233
234 for (csize i = 0; i < num_clauses(); i++)
235 {
236@@ -351,7 +329,9 @@
237 {
238 case flwor_clause::where_clause:
239 {
240- PUT_SUB( "WHERE", static_cast<const where_clause *>(&c)->get_expr() );
241+ BEGIN_PUT_NL(WHERE);
242+ static_cast<const where_clause *>(&c)->get_expr()->put(os);
243+ END_PUT_NO_RET();
244 break;
245 }
246 case flwor_clause::count_clause:
247@@ -362,13 +342,9 @@
248 break;
249 }
250 case flwor_clause::for_clause:
251- {
252- static_cast<const for_clause *>(&c)->put(os);
253- break;
254- }
255 case flwor_clause::let_clause:
256 {
257- static_cast<const let_clause *>(&c)->put(os);
258+ static_cast<const forlet_clause *>(&c)->put(os);
259 break;
260 }
261 case flwor_clause::window_clause:
262@@ -398,7 +374,7 @@
263 }
264 }
265
266- os << indent << "RETURN\n" << inc_indent;
267+ BEGIN_PUT_NL(RETURN);
268 if (theReturnExpr == NULL)
269 {
270 os << indent << "NULL";
271@@ -407,7 +383,8 @@
272 {
273 theReturnExpr->put(os);
274 }
275- os << dec_indent;
276+ END_PUT_NO_RET();
277+
278 END_PUT();
279 }
280
281@@ -505,10 +482,16 @@
282
283 ostream& if_expr::put(ostream& os) const
284 {
285- BEGIN_PUT(if_expr);
286+ BEGIN_PUT_NL(if_expr);
287+
288 theCondExpr->put(os);
289- PUT_SUB("THEN", theThenExpr);
290- PUT_SUB("ELSE", theElseExpr);
291+
292+ os << indent << "THEN" << std::endl;
293+ theThenExpr->put(os);
294+
295+ os << indent << "ELSE" << std::endl;
296+ theElseExpr->put(os);
297+
298 END_PUT();
299 }
300
301@@ -516,12 +499,12 @@
302 ostream& fo_expr::put(ostream& os) const
303 {
304 const store::Item* qname = theFunction->getName();
305- BEGIN_PUT2( qname->getStringValue() << "/" << num_args() );
306- csize numArgs = theArgs.size();
307+ BEGIN_PUT_MSG( qname->getStringValue() << "/" << num_args() );
308+ csize numArgs = num_args();
309
310 for (csize i = 0; i < numArgs; ++i)
311 {
312- theArgs[i]->put(os);
313+ get_arg(i)->put(os);
314 }
315
316 END_PUT();
317@@ -565,7 +548,7 @@
318
319 theExpr->put(os);
320
321- for (ulong i = 0; i < theArgs.size(); ++i)
322+ for (csize i = 0; i < theArgs.size(); ++i)
323 theArgs[i]->put(os);
324
325 END_PUT();
326@@ -574,35 +557,35 @@
327
328 ostream& instanceof_expr::put( ostream& os) const
329 {
330- BEGIN_PUT1( instanceof_expr, theTargetType->toString() );
331- theInput->put(os);
332- END_PUT();
333-}
334-
335-ostream& treat_expr::put( ostream& os) const
336-{
337- BEGIN_PUT1( treat_expr, theTargetType->toString() );
338- theInput->put(os);
339- END_PUT();
340-}
341-
342-ostream& castable_expr::put( ostream& os) const
343-{
344- BEGIN_PUT1( castable_expr, theTargetType->toString() );
345- theInput->put(os);
346- END_PUT();
347-}
348-
349-ostream& cast_expr::put( ostream& os) const
350-{
351- BEGIN_PUT1( cast_expr, theTargetType->toString() );
352- theInput->put(os);
353- END_PUT();
354-}
355-
356-ostream& name_cast_expr::put( ostream& os) const
357-{
358- BEGIN_PUT( name_cast_expr );
359+ BEGIN_PUT_MSG("instanceof_expr " << theTargetType->toSchemaString());
360+ theInput->put(os);
361+ END_PUT();
362+}
363+
364+ostream& treat_expr::put(ostream& os) const
365+{
366+ BEGIN_PUT_MSG("treat_expr " << theTargetType->toSchemaString());
367+ theInput->put(os);
368+ END_PUT();
369+}
370+
371+ostream& castable_expr::put(ostream& os) const
372+{
373+ BEGIN_PUT_MSG("castable_expr " << theTargetType->toSchemaString());
374+ theInput->put(os);
375+ END_PUT();
376+}
377+
378+ostream& cast_expr::put(ostream& os) const
379+{
380+ BEGIN_PUT_MSG("cast_expr " << theTargetType->toSchemaString());
381+ theInput->put(os);
382+ END_PUT();
383+}
384+
385+ostream& name_cast_expr::put(ostream& os) const
386+{
387+ BEGIN_PUT(name_cast_expr);
388 theInputExpr->put(os);
389 END_PUT();
390 }
391@@ -610,7 +593,7 @@
392
393 ostream& validate_expr::put(ostream& os) const
394 {
395- BEGIN_PUT( validate_expr );
396+ BEGIN_PUT(validate_expr);
397
398 switch (theMode)
399 {
400@@ -755,15 +738,15 @@
401
402 ostream& const_expr::put(ostream& os) const
403 {
404- BEGIN_PUT_NO_EOL( const_expr );
405+ BEGIN_PUT_NO_EOL(const_expr);
406+
407 if (theValue->isFunction())
408 {
409 os << "functrion item [ " << theValue->show() << " ]";
410 }
411 else
412 {
413- os << get_val()->getType()->getStringValue()
414- << " [ " << theValue->show() << " ]";
415+ os << " " << theValue->show();
416 }
417 os << " ]\n";
418 return os;
419@@ -772,8 +755,7 @@
420
421 ostream& order_expr::put(ostream& os) const
422 {
423- os << indent << "order_expr" << expr_addr(this) << "\n" << inc_indent
424- << indent << "[ ";
425+ BEGIN_PUT(order_expr);
426
427 switch (theType)
428 {
429@@ -782,6 +764,7 @@
430 default: os << "??\n";
431 }
432 theInput->put(os) << endl;
433+
434 END_PUT();
435 }
436
437@@ -915,7 +898,7 @@
438
439 ostream& copy_clause::put(ostream& os) const
440 {
441- BEGIN_PUT_NO_LOCATION(copy);
442+ BEGIN_PUT(copy);
443 theVar->put(os);
444 theExpr->put(os);
445 END_PUT();

Subscribers

People subscribed via source and target branches