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