529
|
1 // tree-const.h -*- C++ -*- |
1
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
1
|
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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_tree_const_h) |
|
25 #define octave_tree_const_h 1 |
1
|
26 |
1298
|
27 #if defined (__GNUG__) |
|
28 #pragma interface |
|
29 #endif |
|
30 |
1355
|
31 #include <cstdlib> |
|
32 |
581
|
33 #include <iostream.h> |
|
34 |
1355
|
35 #include "Range.h" |
500
|
36 #include "mx-base.h" |
|
37 |
1355
|
38 #include "oct-obj.h" |
|
39 #include "oct-str.h" |
1
|
40 #include "tree-base.h" |
495
|
41 #include "tree-expr.h" |
164
|
42 |
|
43 class idx_vector; |
747
|
44 class Octave_map; |
1
|
45 |
529
|
46 struct Mapper_fcn; |
|
47 |
581
|
48 // Constants. |
|
49 |
1
|
50 class |
495
|
51 tree_constant : public tree_fvc |
1
|
52 { |
620
|
53 private: |
|
54 |
1558
|
55 // The actual representation of the tree_constant. |
|
56 |
|
57 class |
|
58 tree_constant_rep |
|
59 { |
|
60 friend class tree_constant; |
|
61 |
|
62 private: |
|
63 |
|
64 enum constant_type |
|
65 { |
|
66 unknown_constant, |
|
67 scalar_constant, |
|
68 matrix_constant, |
|
69 complex_scalar_constant, |
|
70 complex_matrix_constant, |
|
71 string_constant, |
|
72 range_constant, |
|
73 map_constant, |
|
74 magic_colon, |
|
75 all_va_args, |
|
76 }; |
|
77 |
|
78 enum force_orient |
|
79 { |
|
80 no_orient, |
|
81 row_orient, |
|
82 column_orient, |
|
83 }; |
|
84 |
|
85 tree_constant_rep (void); |
|
86 |
|
87 tree_constant_rep (double d); |
|
88 tree_constant_rep (const Matrix& m); |
|
89 tree_constant_rep (const DiagMatrix& d); |
|
90 tree_constant_rep (const RowVector& v, int pcv); |
|
91 tree_constant_rep (const ColumnVector& v, int pcv); |
|
92 |
|
93 tree_constant_rep (const Complex& c); |
|
94 tree_constant_rep (const ComplexMatrix& m); |
|
95 tree_constant_rep (const ComplexDiagMatrix& d); |
|
96 tree_constant_rep (const ComplexRowVector& v, int pcv); |
|
97 tree_constant_rep (const ComplexColumnVector& v, int pcv); |
|
98 |
|
99 tree_constant_rep (const char *s); |
|
100 tree_constant_rep (const Octave_str_obj& s); |
|
101 |
|
102 tree_constant_rep (double base, double limit, double inc); |
|
103 tree_constant_rep (const Range& r); |
|
104 |
|
105 tree_constant_rep (const Octave_map& m); |
|
106 |
|
107 tree_constant_rep (tree_constant_rep::constant_type t); |
|
108 |
|
109 tree_constant_rep (const tree_constant_rep& t); |
|
110 |
|
111 ~tree_constant_rep (void); |
|
112 |
|
113 void *operator new (size_t size); |
|
114 void operator delete (void *p, size_t size); |
|
115 |
|
116 int rows (void) const; |
|
117 int columns (void) const; |
|
118 |
|
119 int is_defined (void) const |
|
120 { return type_tag != tree_constant_rep::unknown_constant; } |
|
121 |
|
122 int is_undefined (void) const |
|
123 { return type_tag == tree_constant_rep::unknown_constant; } |
|
124 |
|
125 int is_unknown (void) const |
|
126 { return type_tag == tree_constant_rep::unknown_constant; } |
|
127 |
|
128 int is_real_scalar (void) const |
|
129 { return type_tag == tree_constant_rep::scalar_constant; } |
|
130 |
|
131 int is_real_matrix (void) const |
|
132 { return type_tag == tree_constant_rep::matrix_constant; } |
|
133 |
|
134 int is_complex_scalar (void) const |
|
135 { return type_tag == tree_constant_rep::complex_scalar_constant; } |
|
136 |
|
137 int is_complex_matrix (void) const |
|
138 { return type_tag == tree_constant_rep::complex_matrix_constant; } |
|
139 |
|
140 int is_string (void) const |
|
141 { return type_tag == tree_constant_rep::string_constant; } |
|
142 |
|
143 int is_range (void) const |
|
144 { return type_tag == tree_constant_rep::range_constant; } |
|
145 |
|
146 int is_map (void) const |
|
147 { return type_tag == tree_constant_rep::map_constant; } |
|
148 |
|
149 int is_magic_colon (void) const |
|
150 { return type_tag == tree_constant_rep::magic_colon; } |
|
151 |
|
152 int is_all_va_args (void) const |
|
153 { return type_tag == tree_constant_rep::all_va_args; } |
|
154 |
|
155 tree_constant all (void) const; |
|
156 tree_constant any (void) const; |
|
157 |
|
158 int is_real_type (void) const |
|
159 { |
|
160 return (type_tag == scalar_constant |
|
161 || type_tag == matrix_constant |
|
162 || type_tag == range_constant |
|
163 || type_tag == string_constant); |
|
164 } |
|
165 |
|
166 int is_complex_type (void) const |
|
167 { |
|
168 return (type_tag == complex_matrix_constant |
|
169 || type_tag == complex_scalar_constant); |
|
170 } |
|
171 |
|
172 // Would be nice to get rid of the next four functions: |
|
173 |
|
174 int is_scalar_type (void) const |
|
175 { |
|
176 return (type_tag == scalar_constant |
|
177 || type_tag == complex_scalar_constant); |
|
178 } |
1168
|
179 |
1558
|
180 int is_matrix_type (void) const |
|
181 { |
|
182 return (type_tag == matrix_constant |
|
183 || type_tag == complex_matrix_constant); |
|
184 } |
|
185 |
|
186 int is_numeric_type (void) const |
|
187 { |
|
188 return (type_tag == scalar_constant |
|
189 || type_tag == matrix_constant |
|
190 || type_tag == complex_matrix_constant |
|
191 || type_tag == complex_scalar_constant); |
|
192 } |
|
193 |
|
194 int valid_as_scalar_index (void) const; |
|
195 int valid_as_zero_index (void) const; |
|
196 |
|
197 int is_true (void) const; |
|
198 |
|
199 int is_empty (void) const |
|
200 { |
|
201 return ((! (is_magic_colon () |
|
202 || is_all_va_args () |
|
203 || is_unknown ())) |
|
204 && (rows () == 0 |
|
205 || columns () == 0)); |
|
206 } |
|
207 |
|
208 double double_value (int frc_str_conv = 0) const; |
|
209 Matrix matrix_value (int frc_str_conv = 0) const; |
|
210 Complex complex_value (int frc_str_conv = 0) const; |
|
211 ComplexMatrix complex_matrix_value (int frc_str_conv = 0) const; |
|
212 Octave_str_obj all_strings (void) const; |
|
213 const char *string_value (void) const; |
|
214 Range range_value (void) const; |
|
215 Octave_map map_value (void) const; |
|
216 |
|
217 tree_constant& lookup_map_element (const char *name, int insert = 0, |
|
218 int silent = 0); |
|
219 |
|
220 ColumnVector vector_value (int frc_str_conv = 0, |
|
221 int frc_vec_conv = 0) const; |
|
222 |
|
223 ComplexColumnVector complex_vector_value (int frc_str_conv = 0, |
|
224 int frc_vec_conv = 0) const; |
|
225 |
|
226 tree_constant convert_to_str (void) const; |
|
227 |
|
228 void convert_to_row_or_column_vector (void); |
|
229 |
|
230 void bump_value (tree_expression::type); |
|
231 |
|
232 void resize (int i, int j); |
|
233 void resize (int i, int j, double val); |
|
234 |
|
235 void stash_original_text (char *s); |
|
236 |
|
237 void maybe_mutate (void); |
|
238 |
|
239 void print (void); |
|
240 void print (ostream& os); |
|
241 |
|
242 void print_code (ostream& os); |
|
243 |
|
244 void gripe_wrong_type_arg (const char *name, |
|
245 const tree_constant_rep& tcr) const; |
|
246 |
|
247 char *type_as_string (void) const; |
|
248 |
|
249 // Binary and unary operations. |
|
250 |
|
251 friend tree_constant do_binary_op (tree_constant& a, tree_constant& b, |
|
252 tree_expression::type t); |
|
253 |
|
254 friend tree_constant do_unary_op (tree_constant& a, |
|
255 tree_expression::type t); |
|
256 |
|
257 // We want to eliminate this. |
|
258 |
|
259 constant_type const_type (void) const { return type_tag; } |
|
260 |
|
261 // We want to get rid of these too: |
|
262 |
|
263 void force_numeric (int frc_str_conv = 0); |
|
264 tree_constant make_numeric (int frc_str_conv = 0) const; |
|
265 |
|
266 // But not this. |
|
267 |
|
268 void convert_to_matrix_type (void); |
|
269 |
|
270 // Indexing and assignment. |
|
271 |
|
272 void clear_index (void); |
|
273 |
|
274 // void set_index (double d); |
|
275 void set_index (const Range& r); |
|
276 void set_index (const ColumnVector& v); |
|
277 void set_index (const Matrix& m); |
|
278 void set_index (char c); |
|
279 |
|
280 void set_index (const Octave_object& args); |
|
281 |
|
282 tree_constant do_index (const Octave_object& args); |
|
283 |
|
284 void maybe_widen (constant_type t); |
|
285 |
|
286 void assign (tree_constant& rhs, const Octave_object& args); |
|
287 |
|
288 // Data. |
|
289 |
|
290 union |
|
291 { |
|
292 double scalar; // A real scalar constant. |
|
293 Matrix *matrix; // A real matrix constant. |
|
294 Complex *complex_scalar; // A real scalar constant. |
|
295 ComplexMatrix *complex_matrix; // A real matrix constant. |
|
296 Octave_str_obj *str_obj; // A character string constant. |
|
297 Range *range; // A set of evenly spaced values. |
|
298 Octave_map *a_map; // An associative array. |
|
299 |
|
300 tree_constant_rep *freeptr; // For custom memory management. |
|
301 }; |
|
302 |
|
303 constant_type type_tag; |
|
304 |
|
305 int count; |
|
306 |
|
307 char *orig_text; |
|
308 }; |
620
|
309 |
1168
|
310 union |
|
311 { |
|
312 tree_constant *freeptr; // For custom memory management. |
|
313 tree_constant_rep *rep; // The real representation. |
|
314 }; |
1
|
315 |
|
316 public: |
620
|
317 |
|
318 enum magic_colon { magic_colon_t }; |
922
|
319 enum all_va_args { all_va_args_t }; |
620
|
320 |
1558
|
321 // Constructors. It is possible to create the following types of |
|
322 // constants: |
|
323 // |
|
324 // constant type constructor arguments |
|
325 // ------------- --------------------- |
|
326 // unknown none |
|
327 // real scalar double |
|
328 // real matrix Matrix |
|
329 // DiagMatrix |
|
330 // RowVector |
|
331 // ColumnVector |
|
332 // complex scalar Complex |
|
333 // complex matrix ComplexMatrix |
|
334 // ComplexDiagMatrix |
|
335 // ComplexRowVector |
|
336 // ComplexColumnVector |
|
337 // string char* (null terminated) |
|
338 // Octave_str_obj |
|
339 // range double, double, double |
|
340 // Range |
|
341 // map Octave_map |
|
342 // magic colon tree_constant::magic_colon |
|
343 // all_va_args tree_constant::all_va_args |
620
|
344 |
581
|
345 tree_constant (void) : tree_fvc () |
1
|
346 { rep = new tree_constant_rep (); rep->count = 1; } |
|
347 |
581
|
348 tree_constant (double d) : tree_fvc () |
1
|
349 { rep = new tree_constant_rep (d); rep->count = 1; } |
620
|
350 |
581
|
351 tree_constant (const Matrix& m) : tree_fvc () |
1
|
352 { rep = new tree_constant_rep (m); rep->count = 1; } |
620
|
353 |
581
|
354 tree_constant (const DiagMatrix& d) : tree_fvc () |
1
|
355 { rep = new tree_constant_rep (d); rep->count = 1; } |
620
|
356 |
581
|
357 tree_constant (const RowVector& v, int pcv = -1) : tree_fvc () |
1
|
358 { rep = new tree_constant_rep (v, pcv); rep->count = 1; } |
620
|
359 |
581
|
360 tree_constant (const ColumnVector& v, int pcv = -1) : tree_fvc () |
1
|
361 { rep = new tree_constant_rep (v, pcv); rep->count = 1; } |
|
362 |
581
|
363 tree_constant (const Complex& c) : tree_fvc () |
1
|
364 { rep = new tree_constant_rep (c); rep->count = 1; } |
620
|
365 |
581
|
366 tree_constant (const ComplexMatrix& m) : tree_fvc () |
1
|
367 { rep = new tree_constant_rep (m); rep->count = 1; } |
620
|
368 |
581
|
369 tree_constant (const ComplexDiagMatrix& d) : tree_fvc () |
1
|
370 { rep = new tree_constant_rep (d); rep->count = 1; } |
620
|
371 |
581
|
372 tree_constant (const ComplexRowVector& v, int pcv = -1) : tree_fvc () |
|
373 { rep = new tree_constant_rep (v, pcv); rep->count = 1; } |
620
|
374 |
581
|
375 tree_constant (const ComplexColumnVector& v, int pcv = -1) : tree_fvc () |
|
376 { rep = new tree_constant_rep (v, pcv); rep->count = 1; } |
1
|
377 |
581
|
378 tree_constant (const char *s) : tree_fvc () |
1
|
379 { rep = new tree_constant_rep (s); rep->count = 1; } |
|
380 |
1355
|
381 tree_constant (const Octave_str_obj& s) : tree_fvc () |
|
382 { rep = new tree_constant_rep (s); rep->count = 1; } |
|
383 |
581
|
384 tree_constant (double base, double limit, double inc) : tree_fvc () |
1
|
385 { rep = new tree_constant_rep (base, limit, inc); rep->count = 1; } |
620
|
386 |
581
|
387 tree_constant (const Range& r) : tree_fvc () |
1
|
388 { rep = new tree_constant_rep (r); rep->count = 1; } |
|
389 |
747
|
390 tree_constant (const Octave_map& m) : tree_fvc () |
|
391 { rep = new tree_constant_rep (m); rep->count = 1; } |
|
392 |
1487
|
393 tree_constant (tree_constant::magic_colon) : tree_fvc () |
620
|
394 { |
|
395 tree_constant_rep::constant_type tmp; |
|
396 tmp = tree_constant_rep::magic_colon; |
|
397 rep = new tree_constant_rep (tmp); |
|
398 rep->count = 1; |
|
399 } |
|
400 |
1487
|
401 tree_constant (tree_constant::all_va_args) : tree_fvc () |
922
|
402 { |
|
403 tree_constant_rep::constant_type tmp; |
|
404 tmp = tree_constant_rep::all_va_args; |
|
405 rep = new tree_constant_rep (tmp); |
|
406 rep->count = 1; |
|
407 } |
|
408 |
1558
|
409 // Copy constructor. |
1
|
410 |
581
|
411 tree_constant (const tree_constant& a) : tree_fvc () |
1
|
412 { rep = a.rep; rep->count++; } |
|
413 |
1558
|
414 // Delete the representation of this constant if the count drops to |
|
415 // zero. |
620
|
416 |
1
|
417 ~tree_constant (void); |
|
418 |
|
419 void *operator new (size_t size); |
|
420 void operator delete (void *p, size_t size); |
|
421 |
1558
|
422 // Simple assignment. |
620
|
423 |
747
|
424 tree_constant operator = (const tree_constant& a); |
1
|
425 |
1558
|
426 // Indexed assignment. |
1
|
427 |
782
|
428 tree_constant assign (tree_constant& rhs, const Octave_object& args) |
1
|
429 { |
|
430 if (rep->count > 1) |
|
431 { |
|
432 --rep->count; |
|
433 rep = new tree_constant_rep (*rep); |
|
434 rep->count = 1; |
|
435 } |
1004
|
436 |
506
|
437 rep->assign (rhs, args); |
1004
|
438 |
1
|
439 return *this; |
|
440 } |
|
441 |
1558
|
442 // Simple structure assignment. |
747
|
443 |
782
|
444 tree_constant assign_map_element (SLList<char*>& list, |
|
445 tree_constant& rhs); |
747
|
446 |
1558
|
447 // Indexed structure assignment. |
747
|
448 |
782
|
449 tree_constant assign_map_element (SLList<char*>& list, |
|
450 tree_constant& rhs, |
747
|
451 const Octave_object& args); |
|
452 |
1558
|
453 // Type. It would be nice to eliminate the need for this. |
620
|
454 |
|
455 int is_constant (void) const { return 1; } |
|
456 |
1558
|
457 // Size. |
620
|
458 |
|
459 int rows (void) const { return rep->rows (); } |
|
460 int columns (void) const { return rep->columns (); } |
|
461 |
1558
|
462 // Does this constant have a type? Both of these are provided since |
|
463 // it is sometimes more natural to write is_undefined() instead of |
|
464 // ! is_defined(). |
620
|
465 |
|
466 int is_defined (void) const { return rep->is_defined (); } |
|
467 int is_undefined (void) const { return rep->is_undefined (); } |
|
468 |
1558
|
469 // Is this constant a particular type, or does it belong to a |
|
470 // particular class of types? |
620
|
471 |
|
472 int is_unknown (void) const { return rep->is_unknown (); } |
|
473 int is_real_scalar (void) const { return rep->is_real_scalar (); } |
|
474 int is_real_matrix (void) const { return rep->is_real_matrix (); } |
|
475 int is_complex_scalar (void) const { return rep->is_complex_scalar (); } |
|
476 int is_complex_matrix (void) const { return rep->is_complex_matrix (); } |
|
477 int is_string (void) const { return rep->is_string (); } |
|
478 int is_range (void) const { return rep->is_range (); } |
747
|
479 int is_map (void) const { return rep->is_map (); } |
620
|
480 int is_magic_colon (void) const { return rep->is_magic_colon (); } |
922
|
481 int is_all_va_args (void) const { return rep->is_all_va_args (); } |
620
|
482 |
1558
|
483 // Are any or all of the elements in this constant nonzero? |
620
|
484 |
|
485 tree_constant all (void) const { return rep->all (); } |
|
486 tree_constant any (void) const { return rep->any (); } |
|
487 |
1558
|
488 // Other type stuff. |
|
489 |
620
|
490 int is_real_type (void) const { return rep->is_real_type (); } |
628
|
491 |
620
|
492 int is_complex_type (void) const { return rep->is_complex_type (); } |
|
493 |
636
|
494 int is_scalar_type (void) const { return rep->is_scalar_type (); } |
|
495 int is_matrix_type (void) const { return rep->is_matrix_type (); } |
620
|
496 |
628
|
497 int is_numeric_type (void) const |
|
498 { return rep->is_numeric_type (); } |
620
|
499 |
|
500 int valid_as_scalar_index (void) const |
|
501 { return rep->valid_as_scalar_index (); } |
|
502 |
1041
|
503 int valid_as_zero_index (void) const |
|
504 { return rep->valid_as_zero_index (); } |
|
505 |
1558
|
506 // Does this constant correspond to a truth value? |
620
|
507 |
|
508 int is_true (void) const { return rep->is_true (); } |
|
509 |
1558
|
510 // Is at least one of the dimensions of this constant zero? |
620
|
511 |
|
512 int is_empty (void) const |
1277
|
513 { return rep->is_empty (); } |
620
|
514 |
1558
|
515 // Are the dimensions of this constant zero by zero? |
620
|
516 |
|
517 int is_zero_by_zero (void) const |
|
518 { |
922
|
519 return ((! (is_magic_colon () || is_all_va_args () || is_unknown ())) |
620
|
520 && rows () == 0 && columns () == 0); |
|
521 } |
|
522 |
1558
|
523 // Values. |
620
|
524 |
1558
|
525 double double_value (int frc_str_conv = 0) const |
|
526 { return rep->double_value (frc_str_conv); } |
628
|
527 |
1558
|
528 Matrix matrix_value (int frc_str_conv = 0) const |
|
529 { return rep->matrix_value (frc_str_conv); } |
628
|
530 |
1558
|
531 Complex complex_value (int frc_str_conv = 0) const |
|
532 { return rep->complex_value (frc_str_conv); } |
628
|
533 |
1558
|
534 ComplexMatrix complex_matrix_value (int frc_str_conv = 0) const |
|
535 { return rep->complex_matrix_value (frc_str_conv); } |
628
|
536 |
1355
|
537 Octave_str_obj all_strings (void) const |
|
538 { return rep->all_strings (); } |
|
539 |
|
540 const char *string_value (void) const |
628
|
541 { return rep->string_value (); } |
|
542 |
|
543 Range range_value (void) const |
|
544 { return rep->range_value (); } |
|
545 |
747
|
546 Octave_map map_value (void) const; |
|
547 |
1277
|
548 tree_constant lookup_map_element (const char *ref, int insert = 0, |
|
549 int silent = 0); |
|
550 |
|
551 tree_constant lookup_map_element (SLList<char*>& list, |
|
552 int insert = 0, int silent = 0); |
747
|
553 |
1558
|
554 ColumnVector vector_value (int /* frc_str_conv */ = 0, |
|
555 int /* frc_vec_conv */ = 0) const |
628
|
556 { return rep->vector_value (); } |
|
557 |
1558
|
558 ComplexColumnVector complex_vector_value (int /* frc_str_conv */ = 0, |
|
559 int /* frc_vec_conv */ = 0) const |
628
|
560 { return rep->complex_vector_value (); } |
1
|
561 |
1558
|
562 // Binary and unary operations. |
1204
|
563 |
|
564 friend tree_constant do_binary_op (tree_constant& a, tree_constant& b, |
|
565 tree_expression::type t); |
|
566 |
|
567 friend tree_constant do_unary_op (tree_constant& a, |
|
568 tree_expression::type t); |
|
569 |
1558
|
570 // Conversions. These should probably be private. If a user of this |
|
571 // class wants a certain kind of constant, he should simply ask for |
|
572 // it, and we should convert it if possible. |
1
|
573 |
628
|
574 tree_constant convert_to_str (void) |
|
575 { return rep->convert_to_str (); } |
1
|
576 |
435
|
577 void convert_to_row_or_column_vector (void) |
455
|
578 { rep->convert_to_row_or_column_vector (); } |
435
|
579 |
1558
|
580 // Increment or decrement this constant. |
1
|
581 |
578
|
582 void bump_value (tree_expression::type et) |
1
|
583 { |
|
584 if (rep->count > 1) |
|
585 { |
|
586 --rep->count; |
|
587 rep = new tree_constant_rep (*rep); |
|
588 rep->count = 1; |
|
589 } |
1004
|
590 |
1
|
591 rep->bump_value (et); |
|
592 } |
|
593 |
1199
|
594 void print (void); |
|
595 void print (ostream& os) { rep->print (os); } |
|
596 |
1558
|
597 // Evaluate this constant, possibly converting complex to real, or |
|
598 // matrix to scalar, etc. |
620
|
599 |
1199
|
600 tree_constant eval (int print_result) |
495
|
601 { |
1004
|
602 if (! is_scalar_type ()) |
|
603 rep->maybe_mutate (); |
|
604 |
1199
|
605 if (print_result) |
|
606 print (); |
1004
|
607 |
495
|
608 return *this; |
|
609 } |
1
|
610 |
1487
|
611 Octave_object eval (int print, int /* nargout */, const Octave_object& args) |
1
|
612 { |
565
|
613 Octave_object retval; |
495
|
614 |
506
|
615 if (args.length () > 0) |
|
616 retval(0) = rep->do_index (args); |
495
|
617 else |
500
|
618 retval(0) = *this; |
495
|
619 |
500
|
620 if (retval(0).is_defined ()) |
|
621 retval(0).eval (print); |
1004
|
622 |
1
|
623 return retval; |
|
624 } |
|
625 |
1558
|
626 // Store the original text corresponding to this constant for later |
|
627 // pretty printing. |
620
|
628 |
|
629 void stash_original_text (char *s) |
|
630 { rep->stash_original_text (s); } |
|
631 |
1558
|
632 // Pretty print this constant. |
620
|
633 |
581
|
634 void print_code (ostream& os); |
|
635 |
628
|
636 char *type_as_string (void) const |
|
637 { return rep->type_as_string (); } |
|
638 |
1558
|
639 // We really do need this, and it should be private: |
747
|
640 |
|
641 private: |
|
642 |
|
643 void make_unique (void); |
|
644 |
|
645 tree_constant_rep *make_unique_map (void); |
|
646 |
1558
|
647 // We want to eliminate this, or at least make it private. |
620
|
648 |
|
649 tree_constant_rep::constant_type const_type (void) const |
|
650 { return rep->const_type (); } |
|
651 |
1558
|
652 void convert_to_matrix_type (void) { rep->convert_to_matrix_type (); } |
636
|
653 |
1558
|
654 // Can we make these go away? |
636
|
655 |
1558
|
656 // These need better names, since a range really is a numeric type. |
636
|
657 |
1558
|
658 void force_numeric (int frc_str_conv = 0) |
|
659 { rep->force_numeric (frc_str_conv); } |
636
|
660 |
1558
|
661 tree_constant make_numeric (int frc_str_conv = 0) const |
636
|
662 { |
|
663 if (is_numeric_type ()) |
|
664 return *this; |
|
665 else |
1558
|
666 return rep->make_numeric (frc_str_conv); |
636
|
667 } |
1
|
668 }; |
|
669 |
1199
|
670 extern int print_as_scalar (const tree_constant& val); |
|
671 |
|
672 extern int print_as_structure (const tree_constant& val); |
|
673 |
1
|
674 #endif |
|
675 |
|
676 /* |
|
677 ;;; Local Variables: *** |
|
678 ;;; mode: C++ *** |
|
679 ;;; page-delimiter: "^/\\*" *** |
|
680 ;;; End: *** |
|
681 */ |