Mercurial > hg > octave-nkf
comparison src/pt-const.h @ 1827:effa9400766f
[project @ 1996-02-02 14:07:51 by jwe]
author | jwe |
---|---|
date | Fri, 02 Feb 1996 14:10:10 +0000 |
parents | 74ab3c7079cf |
children | 003570e69c7b |
comparison
equal
deleted
inserted
replaced
1826:b14829582cc4 | 1827:effa9400766f |
---|---|
1 // pt-const.h -*- C++ -*- | 1 // pt-const.h -*- C++ -*- |
2 /* | 2 /* |
3 | 3 |
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton | 4 Copyright (C) 1996 John W. Eaton |
5 | 5 |
6 This file is part of Octave. | 6 This file is part of Octave. |
7 | 7 |
8 Octave is free software; you can redistribute it and/or modify it | 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 | 9 under the terms of the GNU General Public License as published by the |
52 | 52 |
53 // The actual representation of the tree_constant. | 53 // The actual representation of the tree_constant. |
54 | 54 |
55 class | 55 class |
56 tree_constant_rep | 56 tree_constant_rep |
57 { | 57 { |
58 private: | 58 public: |
59 | 59 |
60 friend class tree_constant; | 60 enum constant_type |
61 | 61 { |
62 enum constant_type | 62 unknown_constant, |
63 { | 63 scalar_constant, |
64 unknown_constant, | 64 matrix_constant, |
65 scalar_constant, | 65 complex_scalar_constant, |
66 matrix_constant, | 66 complex_matrix_constant, |
67 complex_scalar_constant, | 67 char_matrix_constant, |
68 complex_matrix_constant, | 68 char_matrix_constant_str, |
69 char_matrix_constant, | 69 range_constant, |
70 char_matrix_constant_str, | 70 map_constant, |
71 range_constant, | 71 magic_colon, |
72 map_constant, | 72 all_va_args, |
73 magic_colon, | 73 }; |
74 all_va_args, | 74 |
75 }; | 75 enum force_orient |
76 | 76 { |
77 enum force_orient | 77 no_orient, |
78 { | 78 row_orient, |
79 no_orient, | 79 column_orient, |
80 row_orient, | 80 }; |
81 column_orient, | 81 |
82 }; | 82 tree_constant_rep (void); |
83 | 83 |
84 tree_constant_rep (void); | 84 tree_constant_rep (double d); |
85 | 85 tree_constant_rep (const Matrix& m); |
86 tree_constant_rep (double d); | 86 tree_constant_rep (const DiagMatrix& d); |
87 tree_constant_rep (const Matrix& m); | 87 tree_constant_rep (const RowVector& v, int pcv); |
88 tree_constant_rep (const DiagMatrix& d); | 88 tree_constant_rep (const ColumnVector& v, int pcv); |
89 tree_constant_rep (const RowVector& v, int pcv); | 89 |
90 tree_constant_rep (const ColumnVector& v, int pcv); | 90 tree_constant_rep (const Complex& c); |
91 | 91 tree_constant_rep (const ComplexMatrix& m); |
92 tree_constant_rep (const Complex& c); | 92 tree_constant_rep (const ComplexDiagMatrix& d); |
93 tree_constant_rep (const ComplexMatrix& m); | 93 tree_constant_rep (const ComplexRowVector& v, int pcv); |
94 tree_constant_rep (const ComplexDiagMatrix& d); | 94 tree_constant_rep (const ComplexColumnVector& v, int pcv); |
95 tree_constant_rep (const ComplexRowVector& v, int pcv); | 95 |
96 tree_constant_rep (const ComplexColumnVector& v, int pcv); | 96 tree_constant_rep (const char *s); |
97 | 97 tree_constant_rep (const string& s); |
98 tree_constant_rep (const char *s); | 98 tree_constant_rep (const string_vector& s); |
99 tree_constant_rep (const string& s); | 99 tree_constant_rep (const charMatrix& chm, bool is_string); |
100 tree_constant_rep (const string_vector& s); | 100 |
101 tree_constant_rep (const charMatrix& chm, int is_string); | 101 tree_constant_rep (double base, double limit, double inc); |
102 | 102 tree_constant_rep (const Range& r); |
103 tree_constant_rep (double base, double limit, double inc); | 103 |
104 tree_constant_rep (const Range& r); | 104 tree_constant_rep (const Octave_map& m); |
105 | 105 |
106 tree_constant_rep (const Octave_map& m); | 106 tree_constant_rep (tree_constant_rep::constant_type t); |
107 | 107 |
108 tree_constant_rep (tree_constant_rep::constant_type t); | 108 tree_constant_rep (const tree_constant_rep& t); |
109 | 109 |
110 tree_constant_rep (const tree_constant_rep& t); | 110 ~tree_constant_rep (void); |
111 | 111 |
112 ~tree_constant_rep (void); | 112 void *operator new (size_t size); |
113 | 113 void operator delete (void *p, size_t size); |
114 void *operator new (size_t size); | 114 |
115 void operator delete (void *p, size_t size); | 115 int rows (void) const; |
116 | 116 int columns (void) const; |
117 int rows (void) const; | 117 |
118 int columns (void) const; | 118 bool is_defined (void) const |
119 | 119 { return type_tag != unknown_constant; } |
120 int is_defined (void) const | 120 |
121 { return type_tag != unknown_constant; } | 121 bool is_undefined (void) const |
122 | 122 { return type_tag == unknown_constant; } |
123 int is_undefined (void) const | 123 |
124 { return type_tag == unknown_constant; } | 124 bool is_unknown (void) const |
125 | 125 { return type_tag == unknown_constant; } |
126 int is_unknown (void) const | 126 |
127 { return type_tag == unknown_constant; } | 127 bool is_real_scalar (void) const |
128 | 128 { return type_tag == scalar_constant; } |
129 int is_real_scalar (void) const | 129 |
130 { return type_tag == scalar_constant; } | 130 bool is_real_matrix (void) const |
131 | 131 { return type_tag == matrix_constant; } |
132 int is_real_matrix (void) const | 132 |
133 { return type_tag == matrix_constant; } | 133 bool is_complex_scalar (void) const |
134 | 134 { return type_tag == complex_scalar_constant; } |
135 int is_complex_scalar (void) const | 135 |
136 { return type_tag == complex_scalar_constant; } | 136 bool is_complex_matrix (void) const |
137 | 137 { return type_tag == complex_matrix_constant; } |
138 int is_complex_matrix (void) const | 138 |
139 { return type_tag == complex_matrix_constant; } | 139 bool is_char_matrix (void) const |
140 | 140 { return type_tag == char_matrix_constant; } |
141 int is_char_matrix (void) const | 141 |
142 { return type_tag == char_matrix_constant; } | 142 bool is_string (void) const |
143 | 143 { return type_tag == char_matrix_constant_str; } |
144 int is_string (void) const | 144 |
145 { return type_tag == char_matrix_constant_str; } | 145 bool is_range (void) const |
146 | 146 { return type_tag == range_constant; } |
147 int is_range (void) const | 147 |
148 { return type_tag == range_constant; } | 148 bool is_map (void) const |
149 | 149 { return type_tag == map_constant; } |
150 int is_map (void) const | 150 |
151 { return type_tag == map_constant; } | 151 bool is_magic_colon (void) const |
152 | 152 { return type_tag == magic_colon; } |
153 int is_magic_colon (void) const | 153 |
154 { return type_tag == magic_colon; } | 154 bool is_all_va_args (void) const |
155 | 155 { return type_tag == all_va_args; } |
156 int is_all_va_args (void) const | 156 |
157 { return type_tag == all_va_args; } | 157 tree_constant all (void) const; |
158 | 158 tree_constant any (void) const; |
159 tree_constant all (void) const; | 159 |
160 tree_constant any (void) const; | 160 bool is_real_type (void) const |
161 | 161 { |
162 int is_real_type (void) const | 162 return (type_tag == scalar_constant |
163 { | 163 || type_tag == matrix_constant |
164 return (type_tag == scalar_constant | 164 || type_tag == range_constant |
165 || type_tag == matrix_constant | 165 || type_tag == char_matrix_constant |
166 || type_tag == range_constant | 166 || type_tag == char_matrix_constant_str); |
167 || type_tag == char_matrix_constant | 167 } |
168 || type_tag == char_matrix_constant_str); | 168 |
169 } | 169 bool is_complex_type (void) const |
170 | 170 { |
171 int is_complex_type (void) const | 171 return (type_tag == complex_matrix_constant |
172 { | 172 || type_tag == complex_scalar_constant); |
173 return (type_tag == complex_matrix_constant | 173 } |
174 || type_tag == complex_scalar_constant); | 174 |
175 } | 175 // Would be nice to get rid of the next four functions: |
176 | 176 |
177 // Would be nice to get rid of the next four functions: | 177 bool is_scalar_type (void) const |
178 | 178 { |
179 int is_scalar_type (void) const | 179 return (type_tag == scalar_constant |
180 { | 180 || type_tag == complex_scalar_constant); |
181 return (type_tag == scalar_constant | 181 } |
182 || type_tag == complex_scalar_constant); | 182 |
183 } | 183 bool is_matrix_type (void) const |
184 | 184 { |
185 int is_matrix_type (void) const | 185 return (type_tag == matrix_constant |
186 { | 186 || type_tag == complex_matrix_constant); |
187 return (type_tag == matrix_constant | 187 } |
188 || type_tag == complex_matrix_constant); | 188 |
189 } | 189 bool is_numeric_type (void) const |
190 | 190 { |
191 int is_numeric_type (void) const | 191 return (type_tag == scalar_constant |
192 { | 192 || type_tag == matrix_constant |
193 return (type_tag == scalar_constant | 193 || type_tag == complex_matrix_constant |
194 || type_tag == matrix_constant | 194 || type_tag == complex_scalar_constant); |
195 || type_tag == complex_matrix_constant | 195 } |
196 || type_tag == complex_scalar_constant); | 196 |
197 } | 197 bool valid_as_scalar_index (void) const; |
198 | 198 bool valid_as_zero_index (void) const; |
199 int valid_as_scalar_index (void) const; | 199 |
200 int valid_as_zero_index (void) const; | 200 bool is_true (void) const; |
201 | 201 |
202 int is_true (void) const; | 202 bool is_empty (void) const |
203 | 203 { |
204 int is_empty (void) const | 204 return ((! (is_magic_colon () |
205 { | 205 || is_all_va_args () |
206 return ((! (is_magic_colon () | 206 || is_unknown ())) |
207 || is_all_va_args () | 207 && (rows () == 0 |
208 || is_unknown ())) | 208 || columns () == 0)); |
209 && (rows () == 0 | 209 } |
210 || columns () == 0)); | 210 |
211 } | 211 double double_value (bool frc_str_conv = false) const; |
212 | 212 Matrix matrix_value (bool frc_str_conv = false) const; |
213 double double_value (int frc_str_conv = 0) const; | 213 Complex complex_value (bool frc_str_conv = false) const; |
214 Matrix matrix_value (int frc_str_conv = 0) const; | 214 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const; |
215 Complex complex_value (int frc_str_conv = 0) const; | 215 charMatrix char_matrix_value (bool frc_str_conv = false) const; |
216 ComplexMatrix complex_matrix_value (int frc_str_conv = 0) const; | 216 charMatrix all_strings (void) const; |
217 charMatrix char_matrix_value (int frc_str_conv = 0) const; | 217 string string_value (void) const; |
218 charMatrix all_strings (void) const; | 218 Range range_value (void) const; |
219 string string_value (void) const; | 219 Octave_map map_value (void) const; |
220 Range range_value (void) const; | 220 |
221 Octave_map map_value (void) const; | 221 tree_constant& lookup_map_element (const string& name, |
222 | 222 bool insert = false, |
223 tree_constant& lookup_map_element (const string& name, | 223 bool silent = false); |
224 int insert = 0, | 224 |
225 int silent = 0); | 225 ColumnVector vector_value (bool frc_str_conv = false, |
226 | 226 bool frc_vec_conv = false) const; |
227 ColumnVector vector_value (int frc_str_conv = 0, | 227 |
228 int frc_vec_conv = 0) const; | 228 ComplexColumnVector |
229 | 229 complex_vector_value (bool frc_str_conv = false, |
230 ComplexColumnVector complex_vector_value (int frc_str_conv = 0, | 230 bool frc_vec_conv = false) const; |
231 int frc_vec_conv = 0) const; | 231 |
232 | 232 tree_constant convert_to_str (void) const; |
233 tree_constant convert_to_str (void) const; | 233 |
234 | 234 void convert_to_row_or_column_vector (void); |
235 void convert_to_row_or_column_vector (void); | 235 |
236 | 236 void bump_value (tree_expression::type); |
237 void bump_value (tree_expression::type); | 237 |
238 | 238 void resize (int i, int j); |
239 void resize (int i, int j); | 239 void resize (int i, int j, double val); |
240 void resize (int i, int j, double val); | 240 |
241 | 241 void stash_original_text (const string& s); |
242 void stash_original_text (const string& s); | 242 |
243 | 243 void maybe_mutate (void); |
244 void maybe_mutate (void); | 244 |
245 | 245 void print (void); |
246 void print (void); | 246 void print (ostream& os); |
247 void print (ostream& os); | 247 |
248 | 248 void print_code (ostream& os); |
249 void print_code (ostream& os); | 249 |
250 | 250 void gripe_wrong_type_arg (const char *name, |
251 void gripe_wrong_type_arg (const char *name, | 251 const tree_constant_rep& tcr) const; |
252 const tree_constant_rep& tcr) const; | 252 |
253 | 253 char *type_as_string (void) const; |
254 char *type_as_string (void) const; | 254 |
255 | 255 // Binary and unary operations. |
256 // Binary and unary operations. | 256 |
257 | 257 friend tree_constant do_binary_op (tree_constant& a, tree_constant& b, |
258 friend tree_constant do_binary_op (tree_constant& a, tree_constant& b, | 258 tree_expression::type t); |
259 tree_expression::type t); | 259 |
260 | 260 friend tree_constant do_unary_op (tree_constant& a, |
261 friend tree_constant do_unary_op (tree_constant& a, | 261 tree_expression::type t); |
262 tree_expression::type t); | 262 |
263 | 263 // We want to eliminate this. |
264 // We want to eliminate this. | 264 |
265 | 265 constant_type const_type (void) const { return type_tag; } |
266 constant_type const_type (void) const { return type_tag; } | 266 |
267 | 267 // We want to get rid of these too: |
268 // We want to get rid of these too: | 268 |
269 | 269 void force_numeric (bool frc_str_conv = false); |
270 void force_numeric (int frc_str_conv = 0); | 270 tree_constant make_numeric (bool frc_str_conv = false) const; |
271 tree_constant make_numeric (int frc_str_conv = 0) const; | 271 |
272 | 272 // But not this. |
273 // But not this. | 273 |
274 | 274 void convert_to_matrix_type (bool make_complex); |
275 void convert_to_matrix_type (int make_complex); | 275 |
276 | 276 // Indexing and assignment. |
277 // Indexing and assignment. | 277 |
278 | 278 void clear_index (void); |
279 void clear_index (void); | 279 |
280 | 280 // void set_index (double d); |
281 // void set_index (double d); | 281 void set_index (const Range& r); |
282 void set_index (const Range& r); | 282 void set_index (const ColumnVector& v); |
283 void set_index (const ColumnVector& v); | 283 void set_index (const Matrix& m); |
284 void set_index (const Matrix& m); | 284 void set_index (char c); |
285 void set_index (char c); | 285 |
286 | 286 void set_index (const Octave_object& args, |
287 void set_index (const Octave_object& args, int rhs_is_complex = 0); | 287 bool rhs_is_complex = false); |
288 | 288 |
289 tree_constant do_index (const Octave_object& args); | 289 tree_constant do_index (const Octave_object& args); |
290 | 290 |
291 void maybe_widen (constant_type t); | 291 void maybe_widen (constant_type t); |
292 | 292 |
293 void assign (tree_constant& rhs, const Octave_object& args); | 293 void assign (tree_constant& rhs, const Octave_object& args); |
294 | 294 |
295 int print_as_scalar (void); | 295 bool print_as_scalar (void); |
296 | 296 |
297 int print_as_structure (void); | 297 bool print_as_structure (void); |
298 | 298 |
299 // Data. | 299 // Data. |
300 | 300 |
301 union | 301 union |
302 { | 302 { |
303 double scalar; // A real scalar constant. | 303 double scalar; // A real scalar constant. |
304 Matrix *matrix; // A real matrix constant. | 304 Matrix *matrix; // A real matrix constant. |
305 Complex *complex_scalar; // A real scalar constant. | 305 Complex *complex_scalar; // A real scalar constant. |
306 ComplexMatrix *complex_matrix; // A real matrix constant. | 306 ComplexMatrix *complex_matrix; // A real matrix constant. |
307 charMatrix *char_matrix; // A character string constant. | 307 charMatrix *char_matrix; // A character string constant. |
308 Range *range; // A set of evenly spaced values. | 308 Range *range; // A set of evenly spaced values. |
309 Octave_map *a_map; // An associative array. | 309 Octave_map *a_map; // An associative array. |
310 | 310 |
311 tree_constant_rep *freeptr; // For custom memory management. | 311 tree_constant_rep *freeptr; // For custom memory management. |
312 }; | 312 }; |
313 | 313 |
314 constant_type type_tag; | 314 constant_type type_tag; |
315 | 315 |
316 int count; | 316 int count; |
317 | 317 |
318 string orig_text; | 318 string orig_text; |
319 }; | 319 }; |
320 | 320 |
321 union | 321 union |
322 { | 322 { |
323 tree_constant *freeptr; // For custom memory management. | 323 tree_constant *freeptr; // For custom memory management. |
324 tree_constant_rep *rep; // The real representation. | 324 tree_constant_rep *rep; // The real representation. |
396 | 396 |
397 tree_constant (const string_vector& s, int l = -1, int c = -1) | 397 tree_constant (const string_vector& s, int l = -1, int c = -1) |
398 : tree_fvc (l, c) | 398 : tree_fvc (l, c) |
399 { rep = new tree_constant_rep (s); rep->count = 1; } | 399 { rep = new tree_constant_rep (s); rep->count = 1; } |
400 | 400 |
401 tree_constant (const charMatrix& chm, int is_string = 0) : tree_fvc () | 401 tree_constant (const charMatrix& chm, bool is_string = false) : tree_fvc () |
402 { rep = new tree_constant_rep (chm, is_string); rep->count = 1; } | 402 { rep = new tree_constant_rep (chm, is_string); rep->count = 1; } |
403 | 403 |
404 tree_constant (double base, double limit, double inc) : tree_fvc () | 404 tree_constant (double base, double limit, double inc) : tree_fvc () |
405 { rep = new tree_constant_rep (base, limit, inc); rep->count = 1; } | 405 { rep = new tree_constant_rep (base, limit, inc); rep->count = 1; } |
406 | 406 |
470 tree_constant& rhs, | 470 tree_constant& rhs, |
471 const Octave_object& args); | 471 const Octave_object& args); |
472 | 472 |
473 // Type. It would be nice to eliminate the need for this. | 473 // Type. It would be nice to eliminate the need for this. |
474 | 474 |
475 int is_constant (void) const { return 1; } | 475 bool is_constant (void) const { return true; } |
476 | 476 |
477 // Size. | 477 // Size. |
478 | 478 |
479 int rows (void) const { return rep->rows (); } | 479 int rows (void) const { return rep->rows (); } |
480 int columns (void) const { return rep->columns (); } | 480 int columns (void) const { return rep->columns (); } |
481 | 481 |
482 // Does this constant have a type? Both of these are provided since | 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 | 483 // it is sometimes more natural to write is_undefined() instead of |
484 // ! is_defined(). | 484 // ! is_defined(). |
485 | 485 |
486 int is_defined (void) const { return rep->is_defined (); } | 486 bool is_defined (void) const { return rep->is_defined (); } |
487 int is_undefined (void) const { return rep->is_undefined (); } | 487 bool is_undefined (void) const { return rep->is_undefined (); } |
488 | 488 |
489 // Is this constant a particular type, or does it belong to a | 489 // Is this constant a particular type, or does it belong to a |
490 // particular class of types? | 490 // particular class of types? |
491 | 491 |
492 int is_unknown (void) const { return rep->is_unknown (); } | 492 bool is_unknown (void) const { return rep->is_unknown (); } |
493 int is_real_scalar (void) const { return rep->is_real_scalar (); } | 493 bool is_real_scalar (void) const { return rep->is_real_scalar (); } |
494 int is_real_matrix (void) const { return rep->is_real_matrix (); } | 494 bool is_real_matrix (void) const { return rep->is_real_matrix (); } |
495 int is_complex_scalar (void) const { return rep->is_complex_scalar (); } | 495 bool is_complex_scalar (void) const { return rep->is_complex_scalar (); } |
496 int is_complex_matrix (void) const { return rep->is_complex_matrix (); } | 496 bool is_complex_matrix (void) const { return rep->is_complex_matrix (); } |
497 int is_string (void) const { return rep->is_string (); } | 497 bool is_string (void) const { return rep->is_string (); } |
498 int is_range (void) const { return rep->is_range (); } | 498 bool is_range (void) const { return rep->is_range (); } |
499 int is_map (void) const { return rep->is_map (); } | 499 bool is_map (void) const { return rep->is_map (); } |
500 int is_magic_colon (void) const { return rep->is_magic_colon (); } | 500 bool is_magic_colon (void) const { return rep->is_magic_colon (); } |
501 int is_all_va_args (void) const { return rep->is_all_va_args (); } | 501 bool is_all_va_args (void) const { return rep->is_all_va_args (); } |
502 | 502 |
503 // Are any or all of the elements in this constant nonzero? | 503 // Are any or all of the elements in this constant nonzero? |
504 | 504 |
505 tree_constant all (void) const { return rep->all (); } | 505 tree_constant all (void) const { return rep->all (); } |
506 tree_constant any (void) const { return rep->any (); } | 506 tree_constant any (void) const { return rep->any (); } |
507 | 507 |
508 // Other type stuff. | 508 // Other type stuff. |
509 | 509 |
510 int is_real_type (void) const { return rep->is_real_type (); } | 510 bool is_real_type (void) const { return rep->is_real_type (); } |
511 | 511 |
512 int is_complex_type (void) const { return rep->is_complex_type (); } | 512 bool is_complex_type (void) const { return rep->is_complex_type (); } |
513 | 513 |
514 int is_scalar_type (void) const { return rep->is_scalar_type (); } | 514 bool is_scalar_type (void) const { return rep->is_scalar_type (); } |
515 int is_matrix_type (void) const { return rep->is_matrix_type (); } | 515 bool is_matrix_type (void) const { return rep->is_matrix_type (); } |
516 | 516 |
517 int is_numeric_type (void) const | 517 bool is_numeric_type (void) const |
518 { return rep->is_numeric_type (); } | 518 { return rep->is_numeric_type (); } |
519 | 519 |
520 int valid_as_scalar_index (void) const | 520 bool valid_as_scalar_index (void) const |
521 { return rep->valid_as_scalar_index (); } | 521 { return rep->valid_as_scalar_index (); } |
522 | 522 |
523 int valid_as_zero_index (void) const | 523 bool valid_as_zero_index (void) const |
524 { return rep->valid_as_zero_index (); } | 524 { return rep->valid_as_zero_index (); } |
525 | 525 |
526 // Does this constant correspond to a truth value? | 526 // Does this constant correspond to a truth value? |
527 | 527 |
528 int is_true (void) const { return rep->is_true (); } | 528 bool is_true (void) const { return rep->is_true (); } |
529 | 529 |
530 // Is at least one of the dimensions of this constant zero? | 530 // Is at least one of the dimensions of this constant zero? |
531 | 531 |
532 int is_empty (void) const | 532 bool is_empty (void) const |
533 { return rep->is_empty (); } | 533 { return rep->is_empty (); } |
534 | 534 |
535 // Are the dimensions of this constant zero by zero? | 535 // Are the dimensions of this constant zero by zero? |
536 | 536 |
537 int is_zero_by_zero (void) const | 537 bool is_zero_by_zero (void) const |
538 { | 538 { |
539 return ((! (is_magic_colon () || is_all_va_args () || is_unknown ())) | 539 return ((! (is_magic_colon () || is_all_va_args () || is_unknown ())) |
540 && rows () == 0 && columns () == 0); | 540 && rows () == 0 && columns () == 0); |
541 } | 541 } |
542 | 542 |
543 // Values. | 543 // Values. |
544 | 544 |
545 double double_value (int frc_str_conv = 0) const | 545 double double_value (bool frc_str_conv = false) const |
546 { return rep->double_value (frc_str_conv); } | 546 { return rep->double_value (frc_str_conv); } |
547 | 547 |
548 Matrix matrix_value (int frc_str_conv = 0) const | 548 Matrix matrix_value (bool frc_str_conv = false) const |
549 { return rep->matrix_value (frc_str_conv); } | 549 { return rep->matrix_value (frc_str_conv); } |
550 | 550 |
551 Complex complex_value (int frc_str_conv = 0) const | 551 Complex complex_value (bool frc_str_conv = false) const |
552 { return rep->complex_value (frc_str_conv); } | 552 { return rep->complex_value (frc_str_conv); } |
553 | 553 |
554 ComplexMatrix complex_matrix_value (int frc_str_conv = 0) const | 554 ComplexMatrix complex_matrix_value (bool frc_str_conv = false) const |
555 { return rep->complex_matrix_value (frc_str_conv); } | 555 { return rep->complex_matrix_value (frc_str_conv); } |
556 | 556 |
557 charMatrix char_matrix_value (int frc_str_conv = 0) const | 557 charMatrix char_matrix_value (bool frc_str_conv = false) const |
558 { return rep->char_matrix_value (frc_str_conv); } | 558 { return rep->char_matrix_value (frc_str_conv); } |
559 | 559 |
560 charMatrix all_strings (void) const | 560 charMatrix all_strings (void) const |
561 { return rep->all_strings (); } | 561 { return rep->all_strings (); } |
562 | 562 |
566 Range range_value (void) const | 566 Range range_value (void) const |
567 { return rep->range_value (); } | 567 { return rep->range_value (); } |
568 | 568 |
569 Octave_map map_value (void) const; | 569 Octave_map map_value (void) const; |
570 | 570 |
571 tree_constant lookup_map_element (const string& ref, int insert = 0, | 571 tree_constant lookup_map_element (const string& ref, |
572 int silent = 0); | 572 bool insert = false, |
573 bool silent = false); | |
573 | 574 |
574 tree_constant lookup_map_element (SLList<string>& list, | 575 tree_constant lookup_map_element (SLList<string>& list, |
575 int insert = 0, int silent = 0); | 576 bool insert = false, |
576 | 577 bool silent = false); |
577 ColumnVector vector_value (int /* frc_str_conv */ = 0, | 578 |
578 int /* frc_vec_conv */ = 0) const | 579 ColumnVector vector_value (bool /* frc_str_conv */ = false, |
580 bool /* frc_vec_conv */ = false) const | |
579 { return rep->vector_value (); } | 581 { return rep->vector_value (); } |
580 | 582 |
581 ComplexColumnVector complex_vector_value (int /* frc_str_conv */ = 0, | 583 ComplexColumnVector |
582 int /* frc_vec_conv */ = 0) const | 584 complex_vector_value (bool /* frc_str_conv */ = false, |
585 bool /* frc_vec_conv */ = false) const | |
583 { return rep->complex_vector_value (); } | 586 { return rep->complex_vector_value (); } |
584 | 587 |
585 // Binary and unary operations. | 588 // Binary and unary operations. |
586 | 589 |
587 friend tree_constant do_binary_op (tree_constant& a, tree_constant& b, | 590 friend tree_constant do_binary_op (tree_constant& a, tree_constant& b, |
615 } | 618 } |
616 | 619 |
617 void print (void); | 620 void print (void); |
618 void print (ostream& os) { rep->print (os); } | 621 void print (ostream& os) { rep->print (os); } |
619 | 622 |
620 void print_with_name (const string& name, int print_padding = 1); | 623 void print_with_name (const string& name, bool print_padding = true); |
621 void print_with_name (ostream& os, const string& name, | 624 void print_with_name (ostream& os, const string& name, |
622 int print_padding = 1); | 625 bool print_padding = true); |
623 | 626 |
624 // Evaluate this constant, possibly converting complex to real, or | 627 // Evaluate this constant, possibly converting complex to real, or |
625 // matrix to scalar, etc. | 628 // matrix to scalar, etc. |
626 | 629 |
627 tree_constant eval (int print_result) | 630 tree_constant eval (bool print_result) |
628 { | 631 { |
629 if (print_result) | 632 if (print_result) |
630 { | 633 { |
631 rep->maybe_mutate (); // XXX FIXME XXX -- is this necessary? | 634 rep->maybe_mutate (); // XXX FIXME XXX -- is this necessary? |
632 print (); | 635 print (); |
633 } | 636 } |
634 | 637 |
635 return *this; | 638 return *this; |
636 } | 639 } |
637 | 640 |
638 Octave_object eval (int, int, const Octave_object&); | 641 Octave_object eval (bool, int, const Octave_object&); |
639 | 642 |
640 // Store the original text corresponding to this constant for later | 643 // Store the original text corresponding to this constant for later |
641 // pretty printing. | 644 // pretty printing. |
642 | 645 |
643 void stash_original_text (const string& s) | 646 void stash_original_text (const string& s) |
661 // We want to eliminate this, or at least make it private. | 664 // We want to eliminate this, or at least make it private. |
662 | 665 |
663 tree_constant_rep::constant_type const_type (void) const | 666 tree_constant_rep::constant_type const_type (void) const |
664 { return rep->const_type (); } | 667 { return rep->const_type (); } |
665 | 668 |
666 void convert_to_matrix_type (int make_complex) | 669 void convert_to_matrix_type (bool make_complex) |
667 { rep->convert_to_matrix_type (make_complex); } | 670 { rep->convert_to_matrix_type (make_complex); } |
668 | 671 |
669 // Can we make these go away? | 672 // Can we make these go away? |
670 | 673 |
671 // These need better names, since a range really is a numeric type. | 674 // These need better names, since a range really is a numeric type. |
672 | 675 |
673 void force_numeric (int frc_str_conv = 0) | 676 void force_numeric (bool frc_str_conv = false) |
674 { rep->force_numeric (frc_str_conv); } | 677 { rep->force_numeric (frc_str_conv); } |
675 | 678 |
676 tree_constant make_numeric (int frc_str_conv = 0) const | 679 tree_constant make_numeric (bool frc_str_conv = false) const |
677 { | 680 { |
678 if (is_numeric_type ()) | 681 if (is_numeric_type ()) |
679 return *this; | 682 return *this; |
680 else | 683 else |
681 return rep->make_numeric (frc_str_conv); | 684 return rep->make_numeric (frc_str_conv); |
682 } | 685 } |
683 | 686 |
684 int print_as_scalar (void) { return rep->print_as_scalar (); } | 687 bool print_as_scalar (void) { return rep->print_as_scalar (); } |
685 | 688 |
686 int print_as_structure (void) { return rep->print_as_structure (); } | 689 bool print_as_structure (void) { return rep->print_as_structure (); } |
687 }; | 690 }; |
688 | 691 |
689 #endif | 692 #endif |
690 | 693 |
691 /* | 694 /* |