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