1741
|
1 // tree-expr2.cc -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
|
28 #ifdef HAVE_CONFIG_H |
|
29 #include <config.h> |
|
30 #endif |
|
31 |
|
32 #include <iostream.h> |
|
33 #include <strstream.h> |
|
34 |
|
35 #include "defun.h" |
|
36 #include "error.h" |
|
37 #include "gripes.h" |
|
38 #include "help.h" |
|
39 #include "input.h" |
|
40 #include "oct-obj.h" |
|
41 #include "pager.h" |
|
42 #include "pt-const.h" |
|
43 #include "pt-exp.h" |
|
44 #include "pt-fvc.h" |
|
45 #include "pt-misc.h" |
|
46 #include "pt-mvr.h" |
|
47 #include "user-prefs.h" |
|
48 #include "utils.h" |
|
49 |
|
50 // Nonzero means we're returning from a function. |
|
51 extern int returning; |
|
52 |
|
53 // Nonzero means we're breaking out of a loop or function body. |
|
54 extern int breaking; |
|
55 |
|
56 // But first, some extra functions used by the tree classes. |
|
57 |
|
58 static void |
|
59 print_constant (tree_constant& tc, char *name, int print_padding = 1) |
|
60 { |
|
61 int pad_after = 0; |
|
62 if (user_pref.print_answer_id_name) |
|
63 { |
|
64 if (print_as_scalar (tc) || print_as_structure (tc)) |
|
65 { |
|
66 ostrstream output_buf; |
|
67 output_buf << name << " = " << ends; |
|
68 maybe_page_output (output_buf); |
|
69 } |
|
70 else |
|
71 { |
|
72 pad_after = 1; |
|
73 ostrstream output_buf; |
|
74 output_buf << name << " =\n\n" << ends; |
|
75 maybe_page_output (output_buf); |
|
76 } |
|
77 } |
|
78 |
|
79 tc.eval (1); |
|
80 |
|
81 if (print_padding && pad_after) |
|
82 { |
|
83 ostrstream output_buf; |
|
84 output_buf << "\n" << ends; |
|
85 maybe_page_output (output_buf); |
|
86 } |
|
87 } |
|
88 |
|
89 // Prefix expressions. |
|
90 |
|
91 tree_prefix_expression::~tree_prefix_expression (void) |
|
92 { |
|
93 delete id; |
|
94 } |
|
95 |
|
96 tree_constant |
|
97 tree_prefix_expression::eval (int print) |
|
98 { |
|
99 tree_constant retval; |
|
100 |
|
101 if (error_state) |
|
102 return retval; |
|
103 |
|
104 if (id) |
|
105 { |
|
106 id->bump_value (etype); |
|
107 if (error_state) |
|
108 eval_error (); |
|
109 else |
|
110 { |
|
111 retval = id->eval (print); |
|
112 if (error_state) |
|
113 { |
|
114 retval = tree_constant (); |
|
115 if (error_state) |
|
116 eval_error (); |
|
117 } |
|
118 } |
|
119 } |
|
120 return retval; |
|
121 } |
|
122 |
|
123 char * |
|
124 tree_prefix_expression::oper (void) const |
|
125 { |
|
126 static char *op; |
|
127 switch (etype) |
|
128 { |
|
129 case tree_expression::increment: |
|
130 op = "++"; |
|
131 break; |
|
132 |
|
133 case tree_expression::decrement: |
|
134 op = "--"; |
|
135 break; |
|
136 |
|
137 default: |
|
138 op = "<unknown>"; |
|
139 break; |
|
140 } |
|
141 return op; |
|
142 } |
|
143 |
|
144 void |
|
145 tree_prefix_expression::eval_error (void) |
|
146 { |
|
147 if (error_state > 0) |
|
148 { |
|
149 char *op = oper (); |
|
150 |
|
151 ::error ("evaluating prefix operator `%s' near line %d, column %d", |
|
152 op, line (), column ()); |
|
153 } |
|
154 } |
|
155 |
|
156 void |
|
157 tree_prefix_expression::print_code (ostream& os) |
|
158 { |
|
159 print_code_indent (os); |
|
160 |
|
161 if (in_parens) |
|
162 os << "("; |
|
163 |
|
164 os << oper (); |
|
165 |
|
166 if (id) |
|
167 id->print_code (os); |
|
168 |
|
169 if (in_parens) |
|
170 os << ")"; |
|
171 } |
|
172 |
|
173 // Postfix expressions. |
|
174 |
|
175 tree_postfix_expression::~tree_postfix_expression (void) |
|
176 { |
|
177 delete id; |
|
178 } |
|
179 |
|
180 tree_constant |
|
181 tree_postfix_expression::eval (int print) |
|
182 { |
|
183 tree_constant retval; |
|
184 |
|
185 if (error_state) |
|
186 return retval; |
|
187 |
|
188 if (id) |
|
189 { |
|
190 retval = id->eval (print); |
|
191 id->bump_value (etype); |
|
192 if (error_state) |
|
193 { |
|
194 retval = tree_constant (); |
|
195 if (error_state) |
|
196 eval_error (); |
|
197 } |
|
198 } |
|
199 return retval; |
|
200 } |
|
201 |
|
202 char * |
|
203 tree_postfix_expression::oper (void) const |
|
204 { |
|
205 static char *op; |
|
206 switch (etype) |
|
207 { |
|
208 case tree_expression::increment: |
|
209 op = "++"; |
|
210 break; |
|
211 |
|
212 case tree_expression::decrement: |
|
213 op = "--"; |
|
214 break; |
|
215 |
|
216 default: |
|
217 op = "<unknown>"; |
|
218 break; |
|
219 } |
|
220 return op; |
|
221 } |
|
222 |
|
223 void |
|
224 tree_postfix_expression::eval_error (void) |
|
225 { |
|
226 if (error_state > 0) |
|
227 { |
|
228 char *op = oper (); |
|
229 |
|
230 ::error ("evaluating postfix operator `%s' near line %d, column %d", |
|
231 op, line (), column ()); |
|
232 } |
|
233 } |
|
234 |
|
235 void |
|
236 tree_postfix_expression::print_code (ostream& os) |
|
237 { |
|
238 print_code_indent (os); |
|
239 |
|
240 if (in_parens) |
|
241 os << "("; |
|
242 |
|
243 if (id) |
|
244 id->print_code (os); |
|
245 |
|
246 os << oper (); |
|
247 |
|
248 if (in_parens) |
|
249 os << ")"; |
|
250 } |
|
251 |
|
252 // Unary expressions. |
|
253 |
|
254 tree_constant |
|
255 tree_unary_expression::eval (int /* print */) |
|
256 { |
|
257 if (error_state) |
|
258 return tree_constant (); |
|
259 |
|
260 tree_constant retval; |
|
261 |
|
262 switch (etype) |
|
263 { |
|
264 case tree_expression::not: |
|
265 case tree_expression::uminus: |
|
266 case tree_expression::hermitian: |
|
267 case tree_expression::transpose: |
|
268 if (op) |
|
269 { |
|
270 tree_constant u = op->eval (0); |
|
271 if (error_state) |
|
272 eval_error (); |
|
273 else if (u.is_defined ()) |
|
274 { |
|
275 retval = do_unary_op (u, etype); |
|
276 if (error_state) |
|
277 { |
|
278 retval = tree_constant (); |
|
279 if (error_state) |
|
280 eval_error (); |
|
281 } |
|
282 } |
|
283 } |
|
284 break; |
|
285 |
|
286 default: |
|
287 ::error ("unary operator %d not implemented", etype); |
|
288 break; |
|
289 } |
|
290 |
|
291 return retval; |
|
292 } |
|
293 |
|
294 char * |
|
295 tree_unary_expression::oper (void) const |
|
296 { |
|
297 static char *op; |
|
298 switch (etype) |
|
299 { |
|
300 case tree_expression::not: |
|
301 op = "!"; |
|
302 break; |
|
303 |
|
304 case tree_expression::uminus: |
|
305 op = "-"; |
|
306 break; |
|
307 |
|
308 case tree_expression::hermitian: |
|
309 op = "'"; |
|
310 break; |
|
311 |
|
312 case tree_expression::transpose: |
|
313 op = ".'"; |
|
314 break; |
|
315 |
|
316 default: |
|
317 op = "<unknown>"; |
|
318 break; |
|
319 } |
|
320 return op; |
|
321 } |
|
322 |
|
323 void |
|
324 tree_unary_expression::eval_error (void) |
|
325 { |
|
326 if (error_state > 0) |
|
327 { |
|
328 char *op = oper (); |
|
329 |
|
330 ::error ("evaluating unary operator `%s' near line %d, column %d", |
|
331 op, line (), column ()); |
|
332 } |
|
333 } |
|
334 |
|
335 void |
|
336 tree_unary_expression::print_code (ostream& os) |
|
337 { |
|
338 print_code_indent (os); |
|
339 |
|
340 if (in_parens) |
|
341 os << "("; |
|
342 |
|
343 switch (etype) |
|
344 { |
|
345 case tree_expression::not: |
|
346 case tree_expression::uminus: |
|
347 os << oper (); |
|
348 if (op) |
|
349 op->print_code (os); |
|
350 break; |
|
351 |
|
352 case tree_expression::hermitian: |
|
353 case tree_expression::transpose: |
|
354 if (op) |
|
355 op->print_code (os); |
|
356 os << oper (); |
|
357 break; |
|
358 |
|
359 default: |
|
360 os << oper (); |
|
361 if (op) |
|
362 op->print_code (os); |
|
363 break; |
|
364 } |
|
365 |
|
366 if (in_parens) |
|
367 os << ")"; |
|
368 } |
|
369 |
|
370 // Binary expressions. |
|
371 |
|
372 tree_constant |
|
373 tree_binary_expression::eval (int /* print */) |
|
374 { |
|
375 if (error_state) |
|
376 return tree_constant (); |
|
377 |
|
378 tree_constant retval; |
|
379 |
|
380 switch (etype) |
|
381 { |
|
382 case tree_expression::add: |
|
383 case tree_expression::subtract: |
|
384 case tree_expression::multiply: |
|
385 case tree_expression::el_mul: |
|
386 case tree_expression::divide: |
|
387 case tree_expression::el_div: |
|
388 case tree_expression::leftdiv: |
|
389 case tree_expression::el_leftdiv: |
|
390 case tree_expression::power: |
|
391 case tree_expression::elem_pow: |
|
392 case tree_expression::cmp_lt: |
|
393 case tree_expression::cmp_le: |
|
394 case tree_expression::cmp_eq: |
|
395 case tree_expression::cmp_ge: |
|
396 case tree_expression::cmp_gt: |
|
397 case tree_expression::cmp_ne: |
|
398 case tree_expression::and: |
|
399 case tree_expression::or: |
|
400 if (op1) |
|
401 { |
|
402 tree_constant a = op1->eval (0); |
|
403 if (error_state) |
|
404 eval_error (); |
|
405 else if (a.is_defined () && op2) |
|
406 { |
|
407 tree_constant b = op2->eval (0); |
|
408 if (error_state) |
|
409 eval_error (); |
|
410 else if (b.is_defined ()) |
|
411 { |
|
412 retval = do_binary_op (a, b, etype); |
|
413 if (error_state) |
|
414 { |
|
415 retval = tree_constant (); |
|
416 if (error_state) |
|
417 eval_error (); |
|
418 } |
|
419 } |
|
420 } |
|
421 } |
|
422 break; |
|
423 |
|
424 case tree_expression::and_and: |
|
425 case tree_expression::or_or: |
|
426 { |
|
427 int result = 0; |
|
428 if (op1) |
|
429 { |
|
430 tree_constant a = op1->eval (0); |
|
431 if (error_state) |
|
432 { |
|
433 eval_error (); |
|
434 break; |
|
435 } |
|
436 |
|
437 int a_true = a.is_true (); |
|
438 if (error_state) |
|
439 { |
|
440 eval_error (); |
|
441 break; |
|
442 } |
|
443 |
|
444 if (a_true) |
|
445 { |
|
446 if (etype == tree_expression::or_or) |
|
447 { |
|
448 result = 1; |
|
449 goto done; |
|
450 } |
|
451 } |
|
452 else |
|
453 { |
|
454 if (etype == tree_expression::and_and) |
|
455 { |
|
456 result = 0; |
|
457 goto done; |
|
458 } |
|
459 } |
|
460 |
|
461 if (op2) |
|
462 { |
|
463 tree_constant b = op2->eval (0); |
|
464 if (error_state) |
|
465 { |
|
466 eval_error (); |
|
467 break; |
|
468 } |
|
469 |
|
470 result = b.is_true (); |
|
471 if (error_state) |
|
472 { |
|
473 eval_error (); |
|
474 break; |
|
475 } |
|
476 } |
|
477 } |
|
478 done: |
|
479 retval = tree_constant ((double) result); |
|
480 } |
|
481 break; |
|
482 |
|
483 default: |
|
484 ::error ("binary operator %d not implemented", etype); |
|
485 break; |
|
486 } |
|
487 |
|
488 return retval; |
|
489 } |
|
490 |
|
491 char * |
|
492 tree_binary_expression::oper (void) const |
|
493 { |
|
494 static char *op; |
|
495 switch (etype) |
|
496 { |
|
497 case tree_expression::add: |
|
498 op = "+"; |
|
499 break; |
|
500 |
|
501 case tree_expression::subtract: |
|
502 op = "-"; |
|
503 break; |
|
504 |
|
505 case tree_expression::multiply: |
|
506 op = "*"; |
|
507 break; |
|
508 |
|
509 case tree_expression::el_mul: |
|
510 op = ".*"; |
|
511 break; |
|
512 |
|
513 case tree_expression::divide: |
|
514 op = "/"; |
|
515 break; |
|
516 |
|
517 case tree_expression::el_div: |
|
518 op = "./"; |
|
519 break; |
|
520 |
|
521 case tree_expression::leftdiv: |
|
522 op = "\\"; |
|
523 break; |
|
524 |
|
525 case tree_expression::el_leftdiv: |
|
526 op = ".\\"; |
|
527 break; |
|
528 |
|
529 case tree_expression::power: |
|
530 op = "^"; |
|
531 break; |
|
532 |
|
533 case tree_expression::elem_pow: |
|
534 op = ".^"; |
|
535 break; |
|
536 |
|
537 case tree_expression::cmp_lt: |
|
538 op = "<"; |
|
539 break; |
|
540 |
|
541 case tree_expression::cmp_le: |
|
542 op = "<="; |
|
543 break; |
|
544 |
|
545 case tree_expression::cmp_eq: |
|
546 op = "=="; |
|
547 break; |
|
548 |
|
549 case tree_expression::cmp_ge: |
|
550 op = ">="; |
|
551 break; |
|
552 |
|
553 case tree_expression::cmp_gt: |
|
554 op = ">"; |
|
555 break; |
|
556 |
|
557 case tree_expression::cmp_ne: |
|
558 op = "!="; |
|
559 break; |
|
560 |
|
561 case tree_expression::and_and: |
|
562 op = "&&"; |
|
563 break; |
|
564 |
|
565 case tree_expression::or_or: |
|
566 op = "||"; |
|
567 break; |
|
568 |
|
569 case tree_expression::and: |
|
570 op = "&"; |
|
571 break; |
|
572 |
|
573 case tree_expression::or: |
|
574 op = "|"; |
|
575 break; |
|
576 |
|
577 default: |
|
578 op = "<unknown>"; |
|
579 break; |
|
580 } |
|
581 return op; |
|
582 } |
|
583 |
|
584 void |
|
585 tree_binary_expression::eval_error (void) |
|
586 { |
|
587 if (error_state > 0) |
|
588 { |
|
589 char *op = oper (); |
|
590 |
|
591 ::error ("evaluating binary operator `%s' near line %d, column %d", |
|
592 op, line (), column ()); |
|
593 } |
|
594 } |
|
595 |
|
596 void |
|
597 tree_binary_expression::print_code (ostream& os) |
|
598 { |
|
599 print_code_indent (os); |
|
600 |
|
601 if (in_parens) |
|
602 os << "("; |
|
603 |
|
604 if (op1) |
|
605 op1->print_code (os); |
|
606 |
|
607 os << " " << oper () << " "; |
|
608 |
|
609 if (op2) |
|
610 op2->print_code (os); |
|
611 |
|
612 if (in_parens) |
|
613 os << ")"; |
|
614 } |
|
615 |
|
616 // Simple assignment expressions. |
|
617 |
|
618 tree_simple_assignment_expression::tree_simple_assignment_expression |
|
619 (tree_identifier *i, tree_expression *r, int plhs, int ans_assign, |
|
620 int l, int c) |
|
621 : tree_expression (l, c) |
|
622 { |
|
623 init (plhs, ans_assign); |
|
624 lhs = new tree_indirect_ref (i); |
|
625 rhs = r; |
|
626 } |
|
627 |
|
628 tree_simple_assignment_expression::tree_simple_assignment_expression |
|
629 (tree_index_expression *idx_expr, tree_expression *r, int plhs, |
|
630 int ans_assign, int l, int c) |
|
631 : tree_expression (l, c) |
|
632 { |
|
633 init (plhs, ans_assign); |
|
634 lhs_idx_expr = idx_expr; // cache this -- we may need to delete it. |
|
635 lhs = idx_expr->ident (); |
|
636 index = idx_expr->arg_list (); |
|
637 rhs = r; |
|
638 } |
|
639 |
|
640 tree_simple_assignment_expression::~tree_simple_assignment_expression (void) |
|
641 { |
|
642 if (! preserve) |
|
643 { |
|
644 if (lhs_idx_expr) |
|
645 delete lhs_idx_expr; |
|
646 else |
|
647 delete lhs; |
|
648 } |
|
649 |
|
650 delete rhs; |
|
651 } |
|
652 |
|
653 int |
|
654 tree_simple_assignment_expression::left_hand_side_is_identifier_only (void) |
|
655 { |
|
656 return lhs->is_identifier_only (); |
|
657 } |
|
658 |
|
659 tree_identifier * |
|
660 tree_simple_assignment_expression::left_hand_side_id (void) |
|
661 { |
|
662 return lhs->ident (); |
|
663 } |
|
664 |
|
665 tree_constant |
|
666 tree_simple_assignment_expression::eval (int print) |
|
667 { |
|
668 assert (etype == tree_expression::assignment); |
|
669 |
|
670 tree_constant retval; |
|
671 |
|
672 if (error_state) |
|
673 return retval; |
|
674 |
|
675 if (rhs) |
|
676 { |
|
677 tree_constant rhs_val = rhs->eval (0); |
|
678 if (error_state) |
|
679 { |
|
680 eval_error (); |
|
681 } |
|
682 else if (rhs_val.is_undefined ()) |
|
683 { |
|
684 error ("value on right hand side of assignment is undefined"); |
|
685 eval_error (); |
|
686 } |
|
687 else if (! index) |
|
688 { |
|
689 retval = lhs->assign (rhs_val); |
|
690 if (error_state) |
|
691 eval_error (); |
|
692 } |
|
693 else |
|
694 { |
|
695 // Extract the arguments into a simple vector. |
|
696 |
|
697 Octave_object args = index->convert_to_const_vector (); |
|
698 |
|
699 if (error_state) |
|
700 eval_error (); |
|
701 else |
|
702 { |
|
703 int nargin = args.length (); |
|
704 |
|
705 if (error_state) |
|
706 eval_error (); |
|
707 else if (nargin > 0) |
|
708 { |
|
709 retval = lhs->assign (rhs_val, args); |
|
710 if (error_state) |
|
711 eval_error (); |
|
712 } |
|
713 } |
|
714 } |
|
715 } |
|
716 |
|
717 if (! error_state && print && retval.is_defined ()) |
|
718 print_constant (retval, lhs->name ()); |
|
719 |
|
720 return retval; |
|
721 } |
|
722 |
|
723 void |
|
724 tree_simple_assignment_expression::eval_error (void) |
|
725 { |
|
726 if (error_state > 0) |
|
727 { |
|
728 int l = line (); |
|
729 int c = column (); |
|
730 if (l != -1 && c != -1) |
|
731 ::error ("evaluating assignment expression near line %d, column %d", |
|
732 l, c); |
|
733 } |
|
734 } |
|
735 |
|
736 void |
|
737 tree_simple_assignment_expression::print_code (ostream& os) |
|
738 { |
|
739 print_code_indent (os); |
|
740 |
|
741 if (in_parens) |
|
742 os << "("; |
|
743 |
|
744 if (! is_ans_assign ()) |
|
745 { |
|
746 if (lhs) |
|
747 lhs->print_code (os); |
|
748 |
|
749 if (index) |
|
750 { |
|
751 os << " ("; |
|
752 index->print_code (os); |
|
753 os << ")"; |
|
754 } |
|
755 |
|
756 os << " = "; |
|
757 } |
|
758 |
|
759 if (rhs) |
|
760 rhs->print_code (os); |
|
761 |
|
762 if (in_parens) |
|
763 os << ")"; |
|
764 } |
|
765 |
|
766 // Colon expressions. |
|
767 |
|
768 int |
|
769 tree_colon_expression::is_range_constant (void) const |
|
770 { |
|
771 int tmp = (op1 && op1->is_constant () |
|
772 && op2 && op2->is_constant ()); |
|
773 |
|
774 return op3 ? (tmp && op3->is_constant ()) : tmp; |
|
775 } |
|
776 |
|
777 tree_colon_expression * |
|
778 tree_colon_expression::chain (tree_expression *t) |
|
779 { |
|
780 tree_colon_expression *retval = 0; |
|
781 if (! op1 || op3) |
|
782 ::error ("invalid colon expression"); |
|
783 else |
|
784 { |
|
785 op3 = op2; // Stupid syntax. |
|
786 op2 = t; |
|
787 |
|
788 retval = this; |
|
789 } |
|
790 return retval; |
|
791 } |
|
792 |
|
793 tree_constant |
|
794 tree_colon_expression::eval (int /* print */) |
|
795 { |
|
796 tree_constant retval; |
|
797 |
|
798 if (error_state || ! op1 || ! op2) |
|
799 return retval; |
|
800 |
|
801 tree_constant tmp = op1->eval (0); |
|
802 |
|
803 if (tmp.is_undefined ()) |
|
804 { |
|
805 eval_error ("invalid null value in colon expression"); |
|
806 return retval; |
|
807 } |
|
808 |
|
809 double base = tmp.double_value (); |
|
810 |
|
811 if (error_state) |
|
812 { |
|
813 error ("colon expression elements must be scalars"); |
|
814 eval_error ("evaluating colon expression"); |
|
815 return retval; |
|
816 } |
|
817 |
|
818 tmp = op2->eval (0); |
|
819 |
|
820 if (tmp.is_undefined ()) |
|
821 { |
|
822 eval_error ("invalid null value in colon expression"); |
|
823 return retval; |
|
824 } |
|
825 |
|
826 double limit = tmp.double_value (); |
|
827 |
|
828 if (error_state) |
|
829 { |
|
830 error ("colon expression elements must be scalars"); |
|
831 eval_error ("evaluating colon expression"); |
|
832 return retval; |
|
833 } |
|
834 |
|
835 double inc = 1.0; |
|
836 if (op3) |
|
837 { |
|
838 tmp = op3->eval (0); |
|
839 |
|
840 if (tmp.is_undefined ()) |
|
841 { |
|
842 eval_error ("invalid null value in colon expression"); |
|
843 return retval; |
|
844 } |
|
845 |
|
846 inc = tmp.double_value (); |
|
847 |
|
848 if (error_state) |
|
849 { |
|
850 error ("colon expression elements must be scalars"); |
|
851 eval_error ("evaluating colon expression"); |
|
852 return retval; |
|
853 } |
|
854 } |
|
855 |
|
856 retval = tree_constant (base, limit, inc); |
|
857 |
|
858 if (error_state) |
|
859 { |
|
860 if (error_state) |
|
861 eval_error ("evaluating colon expression"); |
|
862 return tree_constant (); |
|
863 } |
|
864 |
|
865 return retval; |
|
866 } |
|
867 |
|
868 void |
|
869 tree_colon_expression::eval_error (const char *s) |
|
870 { |
|
871 if (error_state > 0) |
|
872 ::error ("%s near line %d column %d", s, line (), column ()); |
|
873 } |
|
874 |
|
875 void |
|
876 tree_colon_expression::print_code (ostream& os) |
|
877 { |
|
878 print_code_indent (os); |
|
879 |
|
880 if (in_parens) |
|
881 os << "("; |
|
882 |
|
883 if (op1) |
|
884 op1->print_code (os); |
|
885 |
|
886 // Stupid syntax. |
|
887 |
|
888 if (op3) |
|
889 { |
|
890 os << ":"; |
|
891 op3->print_code (os); |
|
892 } |
|
893 |
|
894 if (op2) |
|
895 { |
|
896 os << ":"; |
|
897 op2->print_code (os); |
|
898 } |
|
899 |
|
900 if (in_parens) |
|
901 os << ")"; |
|
902 } |
|
903 |
|
904 |
|
905 /* |
|
906 ;;; Local Variables: *** |
|
907 ;;; mode: C++ *** |
|
908 ;;; page-delimiter: "^/\\*" *** |
|
909 ;;; End: *** |
|
910 */ |