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