2376
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
2376
|
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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2376
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "Array-flags.h" |
2942
|
32 #include "str-vec.h" |
4153
|
33 #include "quit.h" |
2376
|
34 |
2974
|
35 #include "oct-obj.h" |
2376
|
36 #include "ov.h" |
|
37 #include "ov-base.h" |
2825
|
38 #include "ov-bool.h" |
|
39 #include "ov-bool-mat.h" |
3351
|
40 #include "ov-cell.h" |
2376
|
41 #include "ov-scalar.h" |
|
42 #include "ov-re-mat.h" |
|
43 #include "ov-complex.h" |
|
44 #include "ov-cx-mat.h" |
|
45 #include "ov-ch-mat.h" |
|
46 #include "ov-str-mat.h" |
|
47 #include "ov-range.h" |
|
48 #include "ov-struct.h" |
2903
|
49 #include "ov-file.h" |
4643
|
50 #include "ov-streamoff.h" |
2880
|
51 #include "ov-list.h" |
3977
|
52 #include "ov-cs-list.h" |
2376
|
53 #include "ov-colon.h" |
|
54 #include "ov-va-args.h" |
2974
|
55 #include "ov-builtin.h" |
|
56 #include "ov-mapper.h" |
|
57 #include "ov-usr-fcn.h" |
4342
|
58 #include "ov-fcn-handle.h" |
2376
|
59 #include "ov-typeinfo.h" |
|
60 |
|
61 #include "defun.h" |
2880
|
62 #include "error.h" |
2376
|
63 #include "gripes.h" |
|
64 #include "pager.h" |
4005
|
65 #include "parse.h" |
2376
|
66 #include "pr-output.h" |
|
67 #include "utils.h" |
|
68 #include "variables.h" |
|
69 |
2477
|
70 // We are likely to have a lot of octave_value objects to allocate, so |
|
71 // make the grow_size large. |
3219
|
72 DEFINE_OCTAVE_ALLOCATOR2(octave_value, 1024); |
2477
|
73 |
4005
|
74 // If TRUE, turn off printing of results in functions (as if a |
|
75 // semicolon has been appended to each statement). |
|
76 static bool Vsilent_functions; |
|
77 |
4455
|
78 // If TRUE, print a warning for assignments like |
2376
|
79 // |
|
80 // octave> A(1) = 3; A(2) = 5 |
|
81 // |
|
82 // for A already defined and a matrix type. |
4455
|
83 bool Vwarn_fortran_indexing; |
2376
|
84 |
4452
|
85 // Should we warn about conversions from complex to real? |
|
86 int Vwarn_imag_to_real; |
4257
|
87 |
4452
|
88 // Should we print a warning when converting `[97, 98, 99, "123"]' |
|
89 // to a character string? |
|
90 bool Vwarn_num_to_str; |
|
91 |
|
92 // If TRUE, warn for operations like |
2376
|
93 // |
|
94 // octave> 'abc' + 0 |
|
95 // 97 98 99 |
|
96 // |
4452
|
97 int Vwarn_str_to_num; |
2376
|
98 |
|
99 // If TRUE, print the name along with the value. |
|
100 bool Vprint_answer_id_name; |
|
101 |
|
102 // How many levels of structure elements should we print? |
|
103 int Vstruct_levels_to_print; |
|
104 |
|
105 // Allow divide by zero errors to be suppressed. |
|
106 bool Vwarn_divide_by_zero; |
|
107 |
4461
|
108 // If TRUE, print a warning when a matrix is resized by an indexed |
|
109 // assignment with indices outside the current bounds. |
|
110 bool Vwarn_resize_on_range_error; |
2948
|
111 |
2880
|
112 // XXX FIXME XXX |
|
113 |
2376
|
114 // Octave's value type. |
|
115 |
3536
|
116 std::string |
3203
|
117 octave_value::unary_op_as_string (unary_op op) |
|
118 { |
3523
|
119 std::string retval; |
3203
|
120 |
|
121 switch (op) |
|
122 { |
3533
|
123 case op_not: |
3203
|
124 retval = "!"; |
|
125 break; |
|
126 |
3533
|
127 case op_uminus: |
3203
|
128 retval = "-"; |
|
129 break; |
|
130 |
3533
|
131 case op_transpose: |
3203
|
132 retval = ".'"; |
|
133 break; |
|
134 |
3533
|
135 case op_hermitian: |
3203
|
136 retval = "'"; |
|
137 break; |
|
138 |
3533
|
139 case op_incr: |
3203
|
140 retval = "++"; |
|
141 break; |
|
142 |
3533
|
143 case op_decr: |
3203
|
144 retval = "--"; |
|
145 break; |
|
146 |
|
147 default: |
|
148 retval = "<unknown>"; |
|
149 } |
|
150 |
|
151 return retval; |
|
152 } |
|
153 |
3536
|
154 std::string |
2376
|
155 octave_value::binary_op_as_string (binary_op op) |
|
156 { |
3523
|
157 std::string retval; |
2376
|
158 |
|
159 switch (op) |
|
160 { |
3533
|
161 case op_add: |
2376
|
162 retval = "+"; |
|
163 break; |
|
164 |
3533
|
165 case op_sub: |
2376
|
166 retval = "-"; |
|
167 break; |
|
168 |
3533
|
169 case op_mul: |
2376
|
170 retval = "*"; |
|
171 break; |
|
172 |
3533
|
173 case op_div: |
2376
|
174 retval = "/"; |
|
175 break; |
|
176 |
3533
|
177 case op_pow: |
2376
|
178 retval = "^"; |
|
179 break; |
|
180 |
3533
|
181 case op_ldiv: |
2376
|
182 retval = "\\"; |
|
183 break; |
|
184 |
3533
|
185 case op_lshift: |
2903
|
186 retval = "<<"; |
|
187 break; |
|
188 |
3533
|
189 case op_rshift: |
2903
|
190 retval = ">>"; |
|
191 break; |
|
192 |
3533
|
193 case op_lt: |
2376
|
194 retval = "<"; |
|
195 break; |
|
196 |
3533
|
197 case op_le: |
2376
|
198 retval = "<="; |
|
199 break; |
|
200 |
3533
|
201 case op_eq: |
2376
|
202 retval = "=="; |
|
203 break; |
|
204 |
3533
|
205 case op_ge: |
2376
|
206 retval = ">="; |
|
207 break; |
|
208 |
3533
|
209 case op_gt: |
2376
|
210 retval = ">"; |
|
211 break; |
|
212 |
3533
|
213 case op_ne: |
2376
|
214 retval = "!="; |
|
215 break; |
|
216 |
3533
|
217 case op_el_mul: |
2376
|
218 retval = ".*"; |
|
219 break; |
|
220 |
3533
|
221 case op_el_div: |
2376
|
222 retval = "./"; |
|
223 break; |
|
224 |
3533
|
225 case op_el_pow: |
2376
|
226 retval = ".^"; |
|
227 break; |
|
228 |
3533
|
229 case op_el_ldiv: |
2376
|
230 retval = ".\\"; |
|
231 break; |
|
232 |
3533
|
233 case op_el_and: |
2376
|
234 retval = "&"; |
|
235 break; |
|
236 |
3533
|
237 case op_el_or: |
2376
|
238 retval = "|"; |
|
239 break; |
|
240 |
3533
|
241 case op_struct_ref: |
2376
|
242 retval = "."; |
|
243 break; |
|
244 |
|
245 default: |
|
246 retval = "<unknown>"; |
|
247 } |
|
248 |
|
249 return retval; |
|
250 } |
|
251 |
3536
|
252 std::string |
2880
|
253 octave_value::assign_op_as_string (assign_op op) |
|
254 { |
3523
|
255 std::string retval; |
2880
|
256 |
|
257 switch (op) |
|
258 { |
3533
|
259 case op_asn_eq: |
2880
|
260 retval = "="; |
|
261 break; |
|
262 |
3533
|
263 case op_add_eq: |
2880
|
264 retval = "+="; |
|
265 break; |
|
266 |
3533
|
267 case op_sub_eq: |
2880
|
268 retval = "-="; |
|
269 break; |
|
270 |
3533
|
271 case op_mul_eq: |
2880
|
272 retval = "*="; |
|
273 break; |
|
274 |
3533
|
275 case op_div_eq: |
2880
|
276 retval = "/="; |
|
277 break; |
|
278 |
3533
|
279 case op_ldiv_eq: |
3204
|
280 retval = "\\="; |
|
281 break; |
|
282 |
4018
|
283 case op_pow_eq: |
|
284 retval = "^="; |
|
285 break; |
|
286 |
3533
|
287 case op_lshift_eq: |
2903
|
288 retval = "<<="; |
|
289 break; |
|
290 |
3533
|
291 case op_rshift_eq: |
2903
|
292 retval = ">>="; |
|
293 break; |
|
294 |
3533
|
295 case op_el_mul_eq: |
2880
|
296 retval = ".*="; |
|
297 break; |
|
298 |
3533
|
299 case op_el_div_eq: |
2880
|
300 retval = "./="; |
|
301 break; |
|
302 |
3533
|
303 case op_el_ldiv_eq: |
3204
|
304 retval = ".\\="; |
|
305 break; |
|
306 |
4018
|
307 case op_el_pow_eq: |
|
308 retval = ".^="; |
|
309 break; |
|
310 |
3533
|
311 case op_el_and_eq: |
2880
|
312 retval = "&="; |
|
313 break; |
|
314 |
3533
|
315 case op_el_or_eq: |
2880
|
316 retval = "|="; |
|
317 break; |
|
318 |
|
319 default: |
|
320 retval = "<unknown>"; |
|
321 } |
|
322 |
|
323 return retval; |
|
324 } |
|
325 |
4513
|
326 octave_value * |
|
327 octave_value::nil_rep (void) const |
|
328 { |
|
329 static octave_base_value *nr = new octave_base_value (); |
|
330 return nr; |
|
331 } |
|
332 |
2376
|
333 octave_value::octave_value (void) |
4513
|
334 : rep (nil_rep ()) |
2825
|
335 { |
4513
|
336 rep->count++; |
2825
|
337 } |
2376
|
338 |
4254
|
339 octave_value::octave_value (short int i) |
|
340 : rep (new octave_scalar (i)) |
|
341 { |
|
342 rep->count = 1; |
|
343 } |
|
344 |
|
345 octave_value::octave_value (unsigned short int i) |
|
346 : rep (new octave_scalar (i)) |
|
347 { |
|
348 rep->count = 1; |
|
349 } |
|
350 |
4233
|
351 octave_value::octave_value (int i) |
|
352 : rep (new octave_scalar (i)) |
|
353 { |
|
354 rep->count = 1; |
|
355 } |
|
356 |
4254
|
357 octave_value::octave_value (unsigned int i) |
|
358 : rep (new octave_scalar (i)) |
|
359 { |
|
360 rep->count = 1; |
|
361 } |
|
362 |
|
363 octave_value::octave_value (long int i) |
|
364 : rep (new octave_scalar (i)) |
|
365 { |
|
366 rep->count = 1; |
|
367 } |
|
368 |
|
369 octave_value::octave_value (unsigned long int i) |
|
370 : rep (new octave_scalar (i)) |
|
371 { |
|
372 rep->count = 1; |
|
373 } |
|
374 |
4353
|
375 #if defined (HAVE_LONG_LONG_INT) |
|
376 octave_value::octave_value (long long int i) |
|
377 : rep (new octave_scalar (i)) |
|
378 { |
|
379 rep->count = 1; |
|
380 } |
|
381 #endif |
|
382 |
4355
|
383 #if defined (HAVE_UNSIGNED_LONG_LONG_INT) |
4353
|
384 octave_value::octave_value (unsigned long long int i) |
|
385 : rep (new octave_scalar (i)) |
|
386 { |
|
387 rep->count = 1; |
|
388 } |
|
389 #endif |
|
390 |
4254
|
391 octave_value::octave_value (octave_time t) |
|
392 : rep (new octave_scalar (t)) |
|
393 { |
|
394 rep->count = 1; |
|
395 } |
|
396 |
2376
|
397 octave_value::octave_value (double d) |
2825
|
398 : rep (new octave_scalar (d)) |
|
399 { |
|
400 rep->count = 1; |
|
401 } |
2376
|
402 |
4587
|
403 octave_value::octave_value (const Cell& c, bool is_csl) |
4513
|
404 : rep (0) |
3351
|
405 { |
4587
|
406 if (is_csl) |
4513
|
407 rep = new octave_cs_list (c); |
|
408 else |
|
409 rep = new octave_cell (c); |
|
410 |
3351
|
411 rep->count = 1; |
|
412 } |
|
413 |
4587
|
414 octave_value::octave_value (const ArrayN<octave_value>& a, bool is_csl) |
4532
|
415 : rep (0) |
|
416 { |
|
417 Cell c (a); |
|
418 |
4587
|
419 if (is_csl) |
4532
|
420 rep = new octave_cs_list (c); |
|
421 else |
|
422 rep = new octave_cell (c); |
|
423 |
|
424 rep->count = 1; |
|
425 } |
|
426 |
2376
|
427 octave_value::octave_value (const Matrix& m) |
2423
|
428 : rep (new octave_matrix (m)) |
|
429 { |
|
430 rep->count = 1; |
|
431 maybe_mutate (); |
|
432 } |
2376
|
433 |
4507
|
434 octave_value::octave_value (const NDArray& a) |
4513
|
435 : rep (new octave_matrix (a)) |
4478
|
436 { |
|
437 rep->count = 1; |
|
438 maybe_mutate (); |
|
439 } |
|
440 |
2376
|
441 octave_value::octave_value (const DiagMatrix& d) |
2423
|
442 : rep (new octave_matrix (d)) |
|
443 { |
|
444 rep->count = 1; |
|
445 maybe_mutate (); |
|
446 } |
2376
|
447 |
3418
|
448 octave_value::octave_value (const RowVector& v) |
|
449 : rep (new octave_matrix (v)) |
2423
|
450 { |
|
451 rep->count = 1; |
|
452 maybe_mutate (); |
|
453 } |
2376
|
454 |
3418
|
455 octave_value::octave_value (const ColumnVector& v) |
|
456 : rep (new octave_matrix (v)) |
2423
|
457 { |
|
458 rep->count = 1; |
|
459 maybe_mutate (); |
|
460 } |
2376
|
461 |
|
462 octave_value::octave_value (const Complex& C) |
2423
|
463 : rep (new octave_complex (C)) |
|
464 { |
|
465 rep->count = 1; |
|
466 maybe_mutate (); |
|
467 } |
2376
|
468 |
|
469 octave_value::octave_value (const ComplexMatrix& m) |
2423
|
470 : rep (new octave_complex_matrix (m)) |
|
471 { |
|
472 rep->count = 1; |
|
473 maybe_mutate (); |
|
474 } |
2376
|
475 |
4513
|
476 octave_value::octave_value (const ComplexNDArray& a) |
|
477 : rep (new octave_complex_matrix (a)) |
4478
|
478 { |
|
479 rep->count = 1; |
|
480 maybe_mutate (); |
|
481 } |
|
482 |
2376
|
483 octave_value::octave_value (const ComplexDiagMatrix& d) |
2423
|
484 : rep (new octave_complex_matrix (d)) |
|
485 { |
|
486 rep->count = 1; |
|
487 maybe_mutate (); |
|
488 } |
2376
|
489 |
3418
|
490 octave_value::octave_value (const ComplexRowVector& v) |
|
491 : rep (new octave_complex_matrix (v)) |
2423
|
492 { |
|
493 rep->count = 1; |
|
494 maybe_mutate (); |
|
495 } |
2376
|
496 |
3418
|
497 octave_value::octave_value (const ComplexColumnVector& v) |
|
498 : rep (new octave_complex_matrix (v)) |
2423
|
499 { |
|
500 rep->count = 1; |
|
501 maybe_mutate (); |
|
502 } |
2376
|
503 |
2825
|
504 octave_value::octave_value (bool b) |
|
505 : rep (new octave_bool (b)) |
|
506 { |
|
507 rep->count = 1; |
|
508 } |
|
509 |
|
510 octave_value::octave_value (const boolMatrix& bm) |
|
511 : rep (new octave_bool_matrix (bm)) |
|
512 { |
|
513 rep->count = 1; |
|
514 maybe_mutate (); |
|
515 } |
|
516 |
4513
|
517 octave_value::octave_value (const boolNDArray& bnda) |
|
518 : rep (new octave_bool_matrix (bnda)) |
|
519 { |
|
520 rep->count = 1; |
|
521 maybe_mutate (); |
|
522 } |
|
523 |
3189
|
524 octave_value::octave_value (char c) |
|
525 : rep (new octave_char_matrix_str (c)) |
|
526 { |
|
527 rep->count = 1; |
|
528 maybe_mutate (); |
|
529 } |
|
530 |
2376
|
531 octave_value::octave_value (const char *s) |
2423
|
532 : rep (new octave_char_matrix_str (s)) |
|
533 { |
|
534 rep->count = 1; |
|
535 maybe_mutate (); |
|
536 } |
2376
|
537 |
3523
|
538 octave_value::octave_value (const std::string& s) |
2423
|
539 : rep (new octave_char_matrix_str (s)) |
|
540 { |
|
541 rep->count = 1; |
|
542 maybe_mutate (); |
|
543 } |
2376
|
544 |
|
545 octave_value::octave_value (const string_vector& s) |
2423
|
546 : rep (new octave_char_matrix_str (s)) |
|
547 { |
|
548 rep->count = 1; |
|
549 maybe_mutate (); |
|
550 } |
2376
|
551 |
4587
|
552 octave_value::octave_value (const charMatrix& chm, bool is_str) |
|
553 : rep (is_str |
4513
|
554 ? new octave_char_matrix_str (chm) |
|
555 : new octave_char_matrix (chm)) |
2409
|
556 { |
4513
|
557 rep->count = 1; |
|
558 maybe_mutate (); |
|
559 } |
2376
|
560 |
4587
|
561 octave_value::octave_value (const charNDArray& chm, bool is_str) |
|
562 : rep (is_str |
4513
|
563 ? new octave_char_matrix_str (chm) |
|
564 : new octave_char_matrix (chm)) |
|
565 { |
2409
|
566 rep->count = 1; |
2423
|
567 maybe_mutate (); |
2409
|
568 } |
2376
|
569 |
|
570 octave_value::octave_value (double base, double limit, double inc) |
2423
|
571 : rep (new octave_range (base, limit, inc)) |
|
572 { |
|
573 rep->count = 1; |
|
574 maybe_mutate (); |
|
575 } |
2376
|
576 |
|
577 octave_value::octave_value (const Range& r) |
2423
|
578 : rep (new octave_range (r)) |
|
579 { |
|
580 rep->count = 1; |
|
581 maybe_mutate (); |
|
582 } |
2376
|
583 |
|
584 octave_value::octave_value (const Octave_map& m) |
2825
|
585 : rep (new octave_struct (m)) |
|
586 { |
|
587 rep->count = 1; |
2880
|
588 } |
|
589 |
3340
|
590 octave_value::octave_value (const octave_stream& s, int n) |
2903
|
591 : rep (new octave_file (s, n)) |
|
592 { |
|
593 rep->count = 1; |
|
594 } |
|
595 |
4643
|
596 octave_value::octave_value (const streamoff_array& off) |
|
597 : rep (new octave_streamoff (off)) |
|
598 { |
|
599 rep->count = 1; |
|
600 } |
|
601 |
2974
|
602 octave_value::octave_value (octave_function *f) |
|
603 : rep (f) |
|
604 { |
|
605 rep->count = 1; |
|
606 } |
|
607 |
4342
|
608 octave_value::octave_value (const octave_fcn_handle& fh) |
|
609 : rep (new octave_fcn_handle (fh)) |
|
610 { |
|
611 rep->count = 1; |
|
612 } |
|
613 |
4587
|
614 octave_value::octave_value (const octave_value_list& l, bool is_csl) |
4591
|
615 : rep (0) |
2880
|
616 { |
4591
|
617 if (is_csl) |
|
618 rep = new octave_cs_list (l); |
|
619 else |
|
620 rep = new octave_list (l); |
|
621 |
2880
|
622 rep->count = 1; |
|
623 } |
2376
|
624 |
|
625 octave_value::octave_value (octave_value::magic_colon) |
2825
|
626 : rep (new octave_magic_colon ()) |
|
627 { |
|
628 rep->count = 1; |
|
629 } |
2376
|
630 |
|
631 octave_value::octave_value (octave_value::all_va_args) |
2825
|
632 : rep (new octave_all_va_args ()) |
|
633 { |
|
634 rep->count = 1; |
|
635 } |
2376
|
636 |
4276
|
637 octave_value::octave_value (octave_value *new_rep, int cnt) |
2825
|
638 : rep (new_rep) |
|
639 { |
4276
|
640 rep->count = cnt; |
2825
|
641 } |
2376
|
642 |
|
643 octave_value::~octave_value (void) |
|
644 { |
|
645 #if defined (MDEBUG) |
3531
|
646 std::cerr << "~octave_value: rep: " << rep |
|
647 << " rep->count: " << rep->count << "\n"; |
2376
|
648 #endif |
|
649 |
|
650 if (rep && --rep->count == 0) |
|
651 { |
|
652 delete rep; |
|
653 rep = 0; |
|
654 } |
|
655 } |
|
656 |
2880
|
657 octave_value * |
3933
|
658 octave_value::clone (void) const |
2880
|
659 { |
|
660 panic_impossible (); |
3546
|
661 return 0; |
2880
|
662 } |
|
663 |
2409
|
664 void |
|
665 octave_value::maybe_mutate (void) |
|
666 { |
2410
|
667 octave_value *tmp = rep->try_narrowing_conversion (); |
2409
|
668 |
|
669 if (tmp && tmp != rep) |
|
670 { |
|
671 if (--rep->count == 0) |
|
672 delete rep; |
|
673 |
|
674 rep = tmp; |
|
675 rep->count = 1; |
|
676 } |
|
677 } |
|
678 |
4247
|
679 octave_value |
4271
|
680 octave_value::single_subsref (const std::string& type, |
|
681 const octave_value_list& idx) |
4247
|
682 { |
|
683 std::list<octave_value_list> i; |
|
684 |
|
685 i.push_back (idx); |
|
686 |
|
687 return rep->subsref (type, i); |
|
688 } |
|
689 |
2974
|
690 octave_value_list |
4247
|
691 octave_value::subsref (const std::string& type, |
4219
|
692 const std::list<octave_value_list>& idx, int nargout) |
3933
|
693 { |
|
694 if (is_constant ()) |
|
695 return rep->subsref (type, idx); |
|
696 else |
|
697 return rep->subsref (type, idx, nargout); |
|
698 } |
|
699 |
|
700 octave_value |
4247
|
701 octave_value::next_subsref (const std::string& type, |
4219
|
702 const std::list<octave_value_list>& idx, |
4233
|
703 size_t skip) |
3933
|
704 { |
4582
|
705 if (! error_state && idx.size () > skip) |
3933
|
706 { |
4219
|
707 std::list<octave_value_list> new_idx (idx); |
4233
|
708 for (size_t i = 0; i < skip; i++) |
4219
|
709 new_idx.erase (new_idx.begin ()); |
3933
|
710 return subsref (type.substr (skip), new_idx); |
|
711 } |
|
712 else |
|
713 return *this; |
|
714 } |
|
715 |
|
716 octave_value_list |
3544
|
717 octave_value::do_multi_index_op (int nargout, const octave_value_list& idx) |
2974
|
718 { |
3544
|
719 return rep->do_multi_index_op (nargout, idx); |
2974
|
720 } |
|
721 |
2376
|
722 static void |
3933
|
723 gripe_no_conversion (const std::string& on, const std::string& tn1, |
|
724 const std::string& tn2) |
2376
|
725 { |
3203
|
726 error ("operator %s: no conversion for assignment of `%s' to indexed `%s'", |
|
727 on.c_str (), tn2.c_str (), tn1.c_str ()); |
2376
|
728 } |
|
729 |
3933
|
730 #if 0 |
3204
|
731 static void |
3933
|
732 gripe_assign_failed (const std::string& on, const std::string& tn1, |
|
733 const std::string& tn2) |
3204
|
734 { |
|
735 error ("assignment failed for `%s %s %s'", |
|
736 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
737 } |
3933
|
738 #endif |
3204
|
739 |
|
740 static void |
3933
|
741 gripe_assign_failed_or_no_method (const std::string& on, |
|
742 const std::string& tn1, |
3523
|
743 const std::string& tn2) |
3204
|
744 { |
|
745 error ("assignment failed, or no method for `%s %s %s'", |
|
746 tn1.c_str (), on.c_str (), tn2.c_str ()); |
|
747 } |
|
748 |
3933
|
749 octave_value |
4247
|
750 octave_value::subsasgn (const std::string& type, |
4219
|
751 const std::list<octave_value_list>& idx, |
3933
|
752 const octave_value& rhs) |
|
753 { |
|
754 return rep->subsasgn (type, idx, rhs); |
|
755 } |
|
756 |
|
757 octave_value |
4247
|
758 octave_value::assign (assign_op op, const std::string& type, |
4219
|
759 const std::list<octave_value_list>& idx, |
3933
|
760 const octave_value& rhs) |
|
761 { |
|
762 octave_value retval; |
|
763 |
|
764 make_unique (); |
|
765 |
|
766 octave_value t_rhs = rhs; |
|
767 |
|
768 if (op != op_asn_eq) |
|
769 { |
|
770 // XXX FIXME XXX -- only do the following stuff if we can't find |
|
771 // a specific function to call to handle the op= operation for |
|
772 // the types we have. |
|
773 |
|
774 octave_value t = subsref (type, idx); |
|
775 |
|
776 if (! error_state) |
|
777 { |
|
778 binary_op binop = op_eq_to_binary_op (op); |
|
779 |
|
780 if (! error_state) |
|
781 t_rhs = do_binary_op (binop, t, rhs); |
|
782 } |
|
783 } |
|
784 |
|
785 if (! error_state) |
|
786 { |
|
787 if (type[0] == '.' && ! is_map ()) |
|
788 { |
|
789 octave_value tmp = Octave_map (); |
|
790 retval = tmp.subsasgn (type, idx, t_rhs); |
|
791 } |
|
792 else |
|
793 retval = subsasgn (type, idx, t_rhs); |
|
794 } |
|
795 |
|
796 if (error_state) |
|
797 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
798 type_name (), rhs.type_name ()); |
|
799 |
|
800 return retval; |
|
801 } |
|
802 |
|
803 const octave_value& |
3203
|
804 octave_value::assign (assign_op op, const octave_value& rhs) |
2880
|
805 { |
3533
|
806 if (op == op_asn_eq) |
3203
|
807 operator = (rhs); |
|
808 else |
|
809 { |
3204
|
810 // XXX FIXME XXX -- only do the following stuff if we can't find |
|
811 // a specific function to call to handle the op= operation for |
|
812 // the types we have. |
|
813 |
|
814 binary_op binop = op_eq_to_binary_op (op); |
|
815 |
|
816 if (! error_state) |
|
817 { |
|
818 octave_value t = do_binary_op (binop, *this, rhs); |
|
819 |
|
820 if (! error_state) |
|
821 operator = (t); |
|
822 } |
|
823 |
|
824 if (error_state) |
|
825 gripe_assign_failed_or_no_method (assign_op_as_string (op), |
|
826 type_name (), rhs.type_name ()); |
|
827 } |
|
828 |
3933
|
829 return *this; |
2376
|
830 } |
|
831 |
4563
|
832 int |
|
833 octave_value::rows (void) const |
|
834 { |
|
835 dim_vector dv = dims (); |
|
836 |
|
837 return (dv.length () > 0) ? dv(0) : -1; |
|
838 } |
|
839 |
|
840 int |
|
841 octave_value::columns (void) const |
|
842 { |
|
843 dim_vector dv = dims (); |
|
844 |
|
845 return (dv.length () > 1) ? dv(1) : -1; |
|
846 } |
|
847 |
|
848 int |
|
849 octave_value::length (void) const |
|
850 { |
|
851 int retval = 0; |
|
852 |
|
853 dim_vector dv = dims (); |
4584
|
854 |
4563
|
855 for (int i = 0; i < dv.length (); i++) |
|
856 { |
|
857 if (dv(i) < 0) |
|
858 { |
|
859 retval = -1; |
|
860 break; |
|
861 } |
|
862 |
4584
|
863 if (dv(i) == 0) |
|
864 { |
|
865 retval = 0; |
|
866 break; |
|
867 } |
|
868 |
4563
|
869 if (dv(i) > retval) |
|
870 retval = dv(i); |
|
871 } |
|
872 |
|
873 return retval; |
|
874 } |
|
875 |
|
876 int |
|
877 octave_value::ndims (void) const |
|
878 { |
|
879 dim_vector dv = dims (); |
|
880 |
|
881 int n_dims = dv.length (); |
|
882 |
|
883 // Remove trailing singleton dimensions. |
|
884 |
|
885 for (int i = n_dims; i > 2; i--) |
|
886 { |
|
887 if (dv(i-1) == 1) |
|
888 n_dims--; |
|
889 else |
|
890 break; |
|
891 } |
|
892 |
|
893 // The result is always >= 2. |
|
894 |
|
895 if (n_dims < 2) |
|
896 n_dims = 2; |
|
897 |
|
898 return n_dims; |
|
899 } |
|
900 |
|
901 int |
|
902 octave_value::numel (void) const |
|
903 { |
|
904 dim_vector dv = dims (); |
|
905 |
4567
|
906 return dv.numel (); |
4563
|
907 } |
|
908 |
3351
|
909 Cell |
|
910 octave_value::cell_value (void) const |
|
911 { |
|
912 return rep->cell_value (); |
|
913 } |
|
914 |
2376
|
915 Octave_map |
|
916 octave_value::map_value (void) const |
|
917 { |
|
918 return rep->map_value (); |
|
919 } |
|
920 |
3340
|
921 octave_stream |
2903
|
922 octave_value::stream_value (void) const |
|
923 { |
|
924 return rep->stream_value (); |
|
925 } |
|
926 |
|
927 int |
|
928 octave_value::stream_number (void) const |
|
929 { |
|
930 return rep->stream_number (); |
|
931 } |
|
932 |
4645
|
933 std::streamoff |
4643
|
934 octave_value::streamoff_value (void) const |
|
935 { |
|
936 return rep->streamoff_value (); |
|
937 } |
|
938 |
4645
|
939 streamoff_array |
|
940 octave_value::streamoff_array_value (void) const |
|
941 { |
|
942 return rep->streamoff_array_value (); |
|
943 } |
|
944 |
2974
|
945 octave_function * |
|
946 octave_value::function_value (bool silent) |
|
947 { |
|
948 return rep->function_value (silent); |
|
949 } |
|
950 |
4346
|
951 octave_fcn_handle * |
4343
|
952 octave_value::fcn_handle_value (bool silent) |
|
953 { |
|
954 return rep->fcn_handle_value (silent); |
|
955 } |
|
956 |
2880
|
957 octave_value_list |
|
958 octave_value::list_value (void) const |
|
959 { |
|
960 return rep->list_value (); |
|
961 } |
|
962 |
2376
|
963 ColumnVector |
3419
|
964 octave_value::column_vector_value (bool force_string_conv, |
|
965 bool force_vector_conversion) const |
|
966 { |
|
967 ColumnVector retval; |
|
968 |
|
969 Matrix m = matrix_value (force_string_conv); |
|
970 |
|
971 if (error_state) |
|
972 return retval; |
|
973 |
|
974 int nr = m.rows (); |
|
975 int nc = m.columns (); |
|
976 |
|
977 if (nc == 1) |
|
978 { |
|
979 retval.resize (nr); |
|
980 for (int i = 0; i < nr; i++) |
|
981 retval (i) = m (i, 0); |
|
982 } |
|
983 else |
|
984 { |
3523
|
985 std::string tn = type_name (); |
3419
|
986 gripe_invalid_conversion (tn.c_str (), "real column vector"); |
|
987 } |
|
988 |
|
989 return retval; |
|
990 } |
|
991 |
|
992 ComplexColumnVector |
|
993 octave_value::complex_column_vector_value (bool force_string_conv, |
|
994 bool force_vector_conversion) const |
|
995 { |
|
996 ComplexColumnVector retval; |
|
997 |
|
998 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
999 |
|
1000 if (error_state) |
|
1001 return retval; |
|
1002 |
|
1003 int nr = m.rows (); |
|
1004 int nc = m.columns (); |
|
1005 |
|
1006 if (nc == 1) |
|
1007 { |
3465
|
1008 retval.resize (nr); |
|
1009 for (int i = 0; i < nr; i++) |
3419
|
1010 retval (i) = m (i, 0); |
|
1011 } |
|
1012 else |
|
1013 { |
3523
|
1014 std::string tn = type_name (); |
3419
|
1015 gripe_invalid_conversion (tn.c_str (), "complex column vector"); |
|
1016 } |
|
1017 |
|
1018 return retval; |
|
1019 } |
|
1020 |
|
1021 RowVector |
|
1022 octave_value::row_vector_value (bool force_string_conv, |
|
1023 bool force_vector_conversion) const |
|
1024 { |
|
1025 RowVector retval; |
|
1026 |
|
1027 Matrix m = matrix_value (force_string_conv); |
|
1028 |
|
1029 if (error_state) |
|
1030 return retval; |
|
1031 |
|
1032 int nr = m.rows (); |
|
1033 int nc = m.columns (); |
|
1034 |
|
1035 if (nr == 1) |
|
1036 { |
|
1037 retval.resize (nc); |
|
1038 for (int i = 0; i < nc; i++) |
|
1039 retval (i) = m (0, i); |
|
1040 } |
|
1041 else |
|
1042 { |
3523
|
1043 std::string tn = type_name (); |
3419
|
1044 gripe_invalid_conversion (tn.c_str (), "real row vector"); |
|
1045 } |
|
1046 |
|
1047 return retval; |
|
1048 } |
|
1049 |
|
1050 ComplexRowVector |
|
1051 octave_value::complex_row_vector_value (bool force_string_conv, |
|
1052 bool force_vector_conversion) const |
|
1053 { |
|
1054 ComplexRowVector retval; |
|
1055 |
|
1056 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1057 |
|
1058 if (error_state) |
|
1059 return retval; |
|
1060 |
|
1061 int nr = m.rows (); |
|
1062 int nc = m.columns (); |
|
1063 |
|
1064 if (nr == 1) |
|
1065 { |
|
1066 retval.resize (nc); |
|
1067 for (int i = 0; i < nc; i++) |
|
1068 retval (i) = m (0, i); |
|
1069 } |
|
1070 else |
|
1071 { |
3523
|
1072 std::string tn = type_name (); |
3419
|
1073 gripe_invalid_conversion (tn.c_str (), "complex row vector"); |
|
1074 } |
|
1075 |
|
1076 return retval; |
|
1077 } |
|
1078 |
|
1079 // Sloppy... |
|
1080 |
|
1081 Array<double> |
2376
|
1082 octave_value::vector_value (bool force_string_conv, |
|
1083 bool force_vector_conversion) const |
|
1084 { |
3419
|
1085 Array<double> retval; |
2376
|
1086 |
|
1087 Matrix m = matrix_value (force_string_conv); |
|
1088 |
|
1089 if (error_state) |
|
1090 return retval; |
|
1091 |
|
1092 int nr = m.rows (); |
|
1093 int nc = m.columns (); |
|
1094 |
|
1095 if (nr == 1) |
|
1096 { |
|
1097 retval.resize (nc); |
|
1098 for (int i = 0; i < nc; i++) |
|
1099 retval (i) = m (0, i); |
|
1100 } |
|
1101 else if (nc == 1) |
|
1102 { |
|
1103 retval.resize (nr); |
|
1104 for (int i = 0; i < nr; i++) |
|
1105 retval (i) = m (i, 0); |
|
1106 } |
4455
|
1107 else if (nr > 0 && nc > 0) |
2376
|
1108 { |
4455
|
1109 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1110 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1111 gripe_implicit_conversion (type_name (), "real vector"); |
|
1112 |
2376
|
1113 retval.resize (nr * nc); |
|
1114 int k = 0; |
|
1115 for (int j = 0; j < nc; j++) |
|
1116 for (int i = 0; i < nr; i++) |
4153
|
1117 { |
|
1118 OCTAVE_QUIT; |
|
1119 |
|
1120 retval (k++) = m (i, j); |
|
1121 } |
2376
|
1122 } |
|
1123 else |
|
1124 { |
3523
|
1125 std::string tn = type_name (); |
2376
|
1126 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1127 } |
|
1128 |
|
1129 return retval; |
|
1130 } |
|
1131 |
4044
|
1132 Array<int> |
|
1133 octave_value::int_vector_value (bool force_string_conv, bool require_int, |
|
1134 bool force_vector_conversion) const |
|
1135 { |
|
1136 Array<int> retval; |
|
1137 |
|
1138 Matrix m = matrix_value (force_string_conv); |
|
1139 |
|
1140 if (error_state) |
|
1141 return retval; |
|
1142 |
|
1143 int nr = m.rows (); |
|
1144 int nc = m.columns (); |
|
1145 |
|
1146 if (nr == 1) |
|
1147 { |
|
1148 retval.resize (nc); |
|
1149 for (int i = 0; i < nc; i++) |
|
1150 { |
4153
|
1151 OCTAVE_QUIT; |
|
1152 |
4044
|
1153 double d = m (0, i); |
|
1154 |
|
1155 if (require_int && D_NINT (d) != d) |
|
1156 { |
|
1157 error ("conversion to integer value failed"); |
|
1158 return retval; |
|
1159 } |
|
1160 |
|
1161 retval (i) = static_cast<int> (d); |
|
1162 } |
|
1163 } |
|
1164 else if (nc == 1) |
|
1165 { |
|
1166 retval.resize (nr); |
|
1167 for (int i = 0; i < nr; i++) |
|
1168 { |
4153
|
1169 OCTAVE_QUIT; |
|
1170 |
4044
|
1171 double d = m (i, 0); |
|
1172 |
|
1173 if (require_int && D_NINT (d) != d) |
|
1174 { |
|
1175 error ("conversion to integer value failed"); |
|
1176 return retval; |
|
1177 } |
|
1178 |
|
1179 retval (i) = static_cast<int> (d); |
|
1180 } |
|
1181 } |
4455
|
1182 else if (nr > 0 && nc > 0) |
4044
|
1183 { |
4455
|
1184 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1185 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1186 gripe_implicit_conversion (type_name (), "real vector"); |
|
1187 |
4044
|
1188 retval.resize (nr * nc); |
|
1189 int k = 0; |
|
1190 for (int j = 0; j < nc; j++) |
|
1191 { |
|
1192 for (int i = 0; i < nr; i++) |
|
1193 { |
4153
|
1194 OCTAVE_QUIT; |
|
1195 |
4044
|
1196 double d = m (i, j); |
|
1197 |
|
1198 if (require_int && D_NINT (d) != d) |
|
1199 { |
|
1200 error ("conversion to integer value failed"); |
|
1201 return retval; |
|
1202 } |
|
1203 |
|
1204 retval (k++) = static_cast<int> (d); |
|
1205 } |
|
1206 } |
|
1207 } |
|
1208 else |
|
1209 { |
|
1210 std::string tn = type_name (); |
|
1211 gripe_invalid_conversion (tn.c_str (), "real vector"); |
|
1212 } |
|
1213 |
|
1214 return retval; |
|
1215 } |
|
1216 |
3419
|
1217 Array<Complex> |
2376
|
1218 octave_value::complex_vector_value (bool force_string_conv, |
|
1219 bool force_vector_conversion) const |
|
1220 { |
3419
|
1221 Array<Complex> retval; |
2376
|
1222 |
|
1223 ComplexMatrix m = complex_matrix_value (force_string_conv); |
|
1224 |
|
1225 if (error_state) |
|
1226 return retval; |
|
1227 |
|
1228 int nr = m.rows (); |
|
1229 int nc = m.columns (); |
|
1230 |
|
1231 if (nr == 1) |
|
1232 { |
|
1233 retval.resize (nc); |
|
1234 for (int i = 0; i < nc; i++) |
4153
|
1235 { |
|
1236 OCTAVE_QUIT; |
|
1237 retval (i) = m (0, i); |
|
1238 } |
2376
|
1239 } |
|
1240 else if (nc == 1) |
|
1241 { |
|
1242 retval.resize (nr); |
|
1243 for (int i = 0; i < nr; i++) |
4153
|
1244 { |
|
1245 OCTAVE_QUIT; |
|
1246 retval (i) = m (i, 0); |
|
1247 } |
2376
|
1248 } |
4455
|
1249 else if (nr > 0 && nc > 0) |
2376
|
1250 { |
4455
|
1251 // XXX FIXME XXX -- is warn_fortran_indexing the right variable here? |
|
1252 if (! force_vector_conversion && Vwarn_fortran_indexing) |
|
1253 gripe_implicit_conversion (type_name (), "complex vector"); |
|
1254 |
2376
|
1255 retval.resize (nr * nc); |
|
1256 int k = 0; |
|
1257 for (int j = 0; j < nc; j++) |
|
1258 for (int i = 0; i < nr; i++) |
4153
|
1259 { |
|
1260 OCTAVE_QUIT; |
|
1261 retval (k++) = m (i, j); |
|
1262 } |
2376
|
1263 } |
|
1264 else |
|
1265 { |
3523
|
1266 std::string tn = type_name (); |
2376
|
1267 gripe_invalid_conversion (tn.c_str (), "complex vector"); |
|
1268 } |
|
1269 |
|
1270 return retval; |
|
1271 } |
|
1272 |
4452
|
1273 octave_value |
4457
|
1274 octave_value::convert_to_str (bool pad, bool force) const |
4452
|
1275 { |
4457
|
1276 octave_value retval = convert_to_str_internal (pad, force); |
4452
|
1277 |
4457
|
1278 if (! force && is_numeric_type () && Vwarn_num_to_str) |
4452
|
1279 gripe_implicit_conversion (type_name (), retval.type_name ()); |
|
1280 |
|
1281 return retval; |
|
1282 } |
|
1283 |
2376
|
1284 void |
4005
|
1285 octave_value::print_with_name (std::ostream& output_buf, |
|
1286 const std::string& name, |
2903
|
1287 bool print_padding) const |
2376
|
1288 { |
4005
|
1289 if (! (evaluating_function_body && Vsilent_functions)) |
|
1290 { |
|
1291 bool pad_after = print_name_tag (output_buf, name); |
2376
|
1292 |
4005
|
1293 print (output_buf); |
2376
|
1294 |
4005
|
1295 if (print_padding && pad_after) |
|
1296 newline (output_buf); |
|
1297 } |
2376
|
1298 } |
|
1299 |
|
1300 static void |
3523
|
1301 gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) |
2413
|
1302 { |
2903
|
1303 error ("assignment of `%s' to indexed `%s' not implemented", |
2413
|
1304 tn2.c_str (), tn1.c_str ()); |
|
1305 } |
|
1306 |
|
1307 static void |
3933
|
1308 gripe_assign_conversion_failed (const std::string& tn1, |
|
1309 const std::string& tn2) |
2413
|
1310 { |
2903
|
1311 error ("type conversion for assignment of `%s' to indexed `%s' failed", |
2413
|
1312 tn2.c_str (), tn1.c_str ()); |
|
1313 } |
|
1314 |
3933
|
1315 octave_value |
4247
|
1316 octave_value::numeric_assign (const std::string& type, |
4219
|
1317 const std::list<octave_value_list>& idx, |
2413
|
1318 const octave_value& rhs) |
|
1319 { |
3933
|
1320 octave_value retval; |
2413
|
1321 |
|
1322 int t_lhs = type_id (); |
|
1323 int t_rhs = rhs.type_id (); |
|
1324 |
2880
|
1325 assign_op_fcn f |
3933
|
1326 = octave_value_typeinfo::lookup_assign_op (op_asn_eq, t_lhs, t_rhs); |
|
1327 |
|
1328 bool done = false; |
2413
|
1329 |
|
1330 if (f) |
|
1331 { |
3933
|
1332 f (*this, idx.front (), rhs.get_rep ()); |
2413
|
1333 |
3933
|
1334 done = (! error_state); |
2413
|
1335 } |
3933
|
1336 |
|
1337 if (done) |
|
1338 retval = octave_value (this, count + 1); |
3196
|
1339 else |
|
1340 { |
3933
|
1341 int t_result |
|
1342 = octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, t_rhs); |
|
1343 |
|
1344 if (t_result >= 0) |
|
1345 { |
|
1346 type_conv_fcn cf |
|
1347 = octave_value_typeinfo::lookup_widening_op (t_lhs, t_result); |
|
1348 |
|
1349 if (cf) |
|
1350 { |
|
1351 octave_value *tmp (cf (*this)); |
3196
|
1352 |
3933
|
1353 if (tmp) |
|
1354 { |
|
1355 retval = tmp->subsasgn (type, idx, rhs); |
|
1356 |
4505
|
1357 // The assignment may have converted to a type that |
|
1358 // is wider than necessary. |
|
1359 |
|
1360 retval.maybe_mutate (); |
|
1361 |
3933
|
1362 done = (! error_state); |
|
1363 } |
|
1364 else |
|
1365 gripe_assign_conversion_failed (type_name (), |
|
1366 rhs.type_name ()); |
|
1367 } |
|
1368 else |
|
1369 gripe_indexed_assignment (type_name (), rhs.type_name ()); |
|
1370 } |
|
1371 |
|
1372 if (! (done || error_state)) |
3196
|
1373 { |
3933
|
1374 octave_value tmp_rhs; |
|
1375 type_conv_fcn cf_rhs = rhs.numeric_conversion_function (); |
|
1376 |
|
1377 if (cf_rhs) |
|
1378 { |
|
1379 octave_value *tmp = cf_rhs (rhs.get_rep ()); |
|
1380 |
|
1381 if (tmp) |
|
1382 tmp_rhs = octave_value (tmp); |
|
1383 else |
|
1384 { |
|
1385 gripe_assign_conversion_failed (type_name (), |
|
1386 rhs.type_name ()); |
|
1387 return octave_value (); |
|
1388 } |
|
1389 } |
|
1390 else |
|
1391 tmp_rhs = rhs; |
|
1392 |
|
1393 type_conv_fcn cf_this = numeric_conversion_function (); |
|
1394 |
|
1395 octave_value *tmp_lhs = this; |
3196
|
1396 |
3933
|
1397 if (cf_this) |
|
1398 { |
|
1399 octave_value *tmp = cf_this (*this); |
|
1400 |
|
1401 if (tmp) |
|
1402 tmp_lhs = tmp; |
|
1403 else |
|
1404 { |
|
1405 gripe_assign_conversion_failed (type_name (), |
|
1406 rhs.type_name ()); |
|
1407 return octave_value (); |
|
1408 } |
|
1409 } |
|
1410 |
|
1411 if (cf_this || cf_rhs) |
|
1412 { |
|
1413 retval = tmp_lhs->subsasgn (type, idx, tmp_rhs); |
|
1414 |
|
1415 done = (! error_state); |
|
1416 } |
|
1417 else |
|
1418 gripe_no_conversion (assign_op_as_string (op_asn_eq), |
|
1419 type_name (), rhs.type_name ()); |
3196
|
1420 } |
|
1421 } |
2413
|
1422 |
|
1423 return retval; |
|
1424 } |
|
1425 |
|
1426 static void |
3933
|
1427 gripe_binary_op (const std::string& on, const std::string& tn1, |
|
1428 const std::string& tn2) |
2376
|
1429 { |
2903
|
1430 error ("binary operator `%s' not implemented for `%s' by `%s' operations", |
2376
|
1431 on.c_str (), tn1.c_str (), tn2.c_str ()); |
|
1432 } |
|
1433 |
3203
|
1434 static void |
3523
|
1435 gripe_binary_op_conv (const std::string& on) |
3203
|
1436 { |
|
1437 error ("type conversion failed for binary operator `%s'", on.c_str ()); |
|
1438 } |
|
1439 |
2376
|
1440 octave_value |
3933
|
1441 do_binary_op (octave_value::binary_op op, |
|
1442 const octave_value& v1, const octave_value& v2) |
2376
|
1443 { |
|
1444 octave_value retval; |
|
1445 |
|
1446 int t1 = v1.type_id (); |
|
1447 int t2 = v2.type_id (); |
|
1448 |
2427
|
1449 binary_op_fcn f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1450 |
|
1451 if (f) |
|
1452 retval = f (*v1.rep, *v2.rep); |
|
1453 else |
|
1454 { |
|
1455 octave_value tv1; |
2427
|
1456 type_conv_fcn cf1 = v1.numeric_conversion_function (); |
2376
|
1457 |
|
1458 if (cf1) |
|
1459 { |
3203
|
1460 octave_value *tmp = cf1 (*v1.rep); |
|
1461 |
|
1462 if (tmp) |
|
1463 { |
|
1464 tv1 = octave_value (tmp); |
|
1465 t1 = tv1.type_id (); |
|
1466 } |
|
1467 else |
|
1468 { |
|
1469 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1470 return retval; |
|
1471 } |
2376
|
1472 } |
|
1473 else |
|
1474 tv1 = v1; |
|
1475 |
|
1476 octave_value tv2; |
2427
|
1477 type_conv_fcn cf2 = v2.numeric_conversion_function (); |
2376
|
1478 |
|
1479 if (cf2) |
|
1480 { |
3203
|
1481 octave_value *tmp = cf2 (*v2.rep); |
|
1482 |
|
1483 if (tmp) |
|
1484 { |
|
1485 tv2 = octave_value (tmp); |
|
1486 t2 = tv2.type_id (); |
|
1487 } |
|
1488 else |
|
1489 { |
|
1490 gripe_binary_op_conv (octave_value::binary_op_as_string (op)); |
|
1491 return retval; |
|
1492 } |
2376
|
1493 } |
|
1494 else |
|
1495 tv2 = v2; |
|
1496 |
|
1497 if (cf1 || cf2) |
|
1498 { |
4587
|
1499 f = octave_value_typeinfo::lookup_binary_op (op, t1, t2); |
2376
|
1500 |
|
1501 if (f) |
|
1502 retval = f (*tv1.rep, *tv2.rep); |
|
1503 else |
|
1504 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1505 v1.type_name (), v2.type_name ()); |
|
1506 } |
|
1507 else |
|
1508 gripe_binary_op (octave_value::binary_op_as_string (op), |
|
1509 v1.type_name (), v2.type_name ()); |
|
1510 } |
|
1511 |
|
1512 return retval; |
|
1513 } |
|
1514 |
3933
|
1515 void |
|
1516 octave_value::print_info (std::ostream& os, const std::string& prefix) const |
|
1517 { |
|
1518 os << prefix << "type_name: " << type_name () << "\n" |
|
1519 << prefix << "count: " << get_count () << "\n" |
|
1520 << prefix << "rep info: "; |
|
1521 |
|
1522 rep->print_info (os, prefix + " "); |
|
1523 } |
|
1524 |
3203
|
1525 static void |
3523
|
1526 gripe_unary_op (const std::string& on, const std::string& tn) |
3203
|
1527 { |
|
1528 error ("unary operator `%s' not implemented for `%s' operands", |
|
1529 on.c_str (), tn.c_str ()); |
|
1530 } |
|
1531 |
|
1532 static void |
3523
|
1533 gripe_unary_op_conv (const std::string& on) |
3203
|
1534 { |
|
1535 error ("type conversion failed for unary operator `%s'", on.c_str ()); |
|
1536 } |
|
1537 |
|
1538 octave_value |
|
1539 do_unary_op (octave_value::unary_op op, const octave_value& v) |
|
1540 { |
|
1541 octave_value retval; |
|
1542 |
|
1543 int t = v.type_id (); |
|
1544 |
|
1545 unary_op_fcn f = octave_value_typeinfo::lookup_unary_op (op, t); |
|
1546 |
|
1547 if (f) |
|
1548 retval = f (*v.rep); |
|
1549 else |
|
1550 { |
|
1551 octave_value tv; |
|
1552 type_conv_fcn cf = v.numeric_conversion_function (); |
|
1553 |
|
1554 if (cf) |
|
1555 { |
|
1556 octave_value *tmp = cf (*v.rep); |
|
1557 |
|
1558 if (tmp) |
|
1559 { |
|
1560 tv = octave_value (tmp); |
|
1561 t = tv.type_id (); |
|
1562 |
4587
|
1563 f = octave_value_typeinfo::lookup_unary_op (op, t); |
3203
|
1564 |
|
1565 if (f) |
|
1566 retval = f (*tv.rep); |
|
1567 else |
|
1568 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1569 v.type_name ()); |
|
1570 } |
|
1571 else |
|
1572 gripe_unary_op_conv (octave_value::unary_op_as_string (op)); |
|
1573 } |
|
1574 else |
|
1575 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1576 v.type_name ()); |
|
1577 } |
|
1578 |
|
1579 return retval; |
|
1580 } |
|
1581 |
|
1582 static void |
3933
|
1583 gripe_unary_op_conversion_failed (const std::string& op, |
|
1584 const std::string& tn) |
3203
|
1585 { |
|
1586 error ("operator %s: type conversion for `%s' failed", |
|
1587 op.c_str (), tn.c_str ()); |
|
1588 } |
|
1589 |
3933
|
1590 const octave_value& |
|
1591 octave_value::do_non_const_unary_op (unary_op op) |
3203
|
1592 { |
|
1593 octave_value retval; |
|
1594 |
|
1595 int t = type_id (); |
|
1596 |
|
1597 non_const_unary_op_fcn f |
|
1598 = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1599 |
|
1600 if (f) |
|
1601 { |
|
1602 make_unique (); |
|
1603 |
|
1604 f (*rep); |
|
1605 } |
|
1606 else |
|
1607 { |
|
1608 type_conv_fcn cf = numeric_conversion_function (); |
|
1609 |
|
1610 if (cf) |
|
1611 { |
|
1612 octave_value *tmp = cf (*rep); |
|
1613 |
|
1614 if (tmp) |
|
1615 { |
|
1616 octave_value *old_rep = rep; |
|
1617 rep = tmp; |
|
1618 rep->count = 1; |
|
1619 |
|
1620 t = type_id (); |
|
1621 |
|
1622 f = octave_value_typeinfo::lookup_non_const_unary_op (op, t); |
|
1623 |
|
1624 if (f) |
|
1625 { |
|
1626 f (*rep); |
|
1627 |
|
1628 if (old_rep && --old_rep->count == 0) |
|
1629 delete old_rep; |
|
1630 } |
|
1631 else |
|
1632 { |
|
1633 if (old_rep) |
|
1634 { |
|
1635 if (--rep->count == 0) |
|
1636 delete rep; |
|
1637 |
|
1638 rep = old_rep; |
|
1639 } |
|
1640 |
|
1641 gripe_unary_op (octave_value::unary_op_as_string (op), |
|
1642 type_name ()); |
|
1643 } |
|
1644 } |
|
1645 else |
|
1646 gripe_unary_op_conversion_failed |
|
1647 (octave_value::unary_op_as_string (op), type_name ()); |
|
1648 } |
|
1649 else |
|
1650 gripe_unary_op (octave_value::unary_op_as_string (op), type_name ()); |
|
1651 } |
3933
|
1652 |
|
1653 return *this; |
3203
|
1654 } |
|
1655 |
3933
|
1656 #if 0 |
3205
|
1657 static void |
3933
|
1658 gripe_unary_op_failed_or_no_method (const std::string& on, |
|
1659 const std::string& tn) |
3205
|
1660 { |
|
1661 error ("operator %s: no method, or unable to evaluate for %s operand", |
|
1662 on.c_str (), tn.c_str ()); |
|
1663 } |
3933
|
1664 #endif |
3205
|
1665 |
|
1666 void |
3933
|
1667 octave_value::do_non_const_unary_op (unary_op op, const octave_value_list& idx) |
3205
|
1668 { |
3933
|
1669 abort (); |
|
1670 } |
|
1671 |
|
1672 octave_value |
4247
|
1673 octave_value::do_non_const_unary_op (unary_op op, const std::string& type, |
4219
|
1674 const std::list<octave_value_list>& idx) |
3933
|
1675 { |
|
1676 octave_value retval; |
|
1677 |
|
1678 if (idx.empty ()) |
|
1679 { |
|
1680 do_non_const_unary_op (op); |
3205
|
1681 |
3933
|
1682 retval = *this; |
|
1683 } |
|
1684 else |
|
1685 { |
|
1686 // XXX FIXME XXX -- only do the following stuff if we can't find a |
|
1687 // specific function to call to handle the op= operation for the |
|
1688 // types we have. |
3205
|
1689 |
3933
|
1690 assign_op assop = unary_op_to_assign_op (op); |
|
1691 |
|
1692 retval = assign (assop, type, idx, 1.0); |
|
1693 } |
|
1694 |
|
1695 return retval; |
3205
|
1696 } |
|
1697 |
2903
|
1698 // Current indentation. |
|
1699 int octave_value::curr_print_indent_level = 0; |
|
1700 |
3018
|
1701 // TRUE means we are at the beginning of a line. |
2903
|
1702 bool octave_value::beginning_of_line = true; |
|
1703 |
|
1704 // Each print() function should call this before printing anything. |
|
1705 // |
|
1706 // This doesn't need to be fast, but isn't there a better way? |
|
1707 |
|
1708 void |
3523
|
1709 octave_value::indent (std::ostream& os) const |
2903
|
1710 { |
|
1711 assert (curr_print_indent_level >= 0); |
|
1712 |
|
1713 if (beginning_of_line) |
|
1714 { |
|
1715 // XXX FIXME XXX -- do we need this? |
|
1716 // os << prefix; |
|
1717 |
|
1718 for (int i = 0; i < curr_print_indent_level; i++) |
|
1719 os << " "; |
|
1720 |
|
1721 beginning_of_line = false; |
|
1722 } |
|
1723 } |
|
1724 |
|
1725 // All print() functions should use this to print new lines. |
|
1726 |
|
1727 void |
3523
|
1728 octave_value::newline (std::ostream& os) const |
2903
|
1729 { |
|
1730 os << "\n"; |
|
1731 |
|
1732 beginning_of_line = true; |
|
1733 } |
|
1734 |
|
1735 // For ressetting print state. |
|
1736 |
|
1737 void |
|
1738 octave_value::reset (void) const |
|
1739 { |
|
1740 beginning_of_line = true; |
|
1741 curr_print_indent_level = 0; |
|
1742 } |
|
1743 |
3205
|
1744 octave_value::assign_op |
|
1745 octave_value::unary_op_to_assign_op (unary_op op) |
|
1746 { |
|
1747 assign_op binop = unknown_assign_op; |
|
1748 |
|
1749 switch (op) |
|
1750 { |
3533
|
1751 case op_incr: |
|
1752 binop = op_add_eq; |
3205
|
1753 break; |
|
1754 |
3533
|
1755 case op_decr: |
|
1756 binop = op_sub_eq; |
3205
|
1757 break; |
|
1758 |
|
1759 default: |
|
1760 { |
3523
|
1761 std::string on = unary_op_as_string (op); |
3205
|
1762 error ("operator %s: no assign operator found", on.c_str ()); |
|
1763 } |
|
1764 } |
|
1765 |
|
1766 return binop; |
|
1767 } |
|
1768 |
3204
|
1769 octave_value::binary_op |
|
1770 octave_value::op_eq_to_binary_op (assign_op op) |
|
1771 { |
|
1772 binary_op binop = unknown_binary_op; |
|
1773 |
|
1774 switch (op) |
|
1775 { |
3533
|
1776 case op_add_eq: |
|
1777 binop = op_add; |
3204
|
1778 break; |
|
1779 |
3533
|
1780 case op_sub_eq: |
|
1781 binop = op_sub; |
3204
|
1782 break; |
|
1783 |
3533
|
1784 case op_mul_eq: |
|
1785 binop = op_mul; |
3204
|
1786 break; |
|
1787 |
3533
|
1788 case op_div_eq: |
|
1789 binop = op_div; |
3204
|
1790 break; |
|
1791 |
3533
|
1792 case op_ldiv_eq: |
|
1793 binop = op_ldiv; |
3204
|
1794 break; |
|
1795 |
4018
|
1796 case op_pow_eq: |
|
1797 binop = op_pow; |
|
1798 break; |
|
1799 |
3533
|
1800 case op_lshift_eq: |
|
1801 binop = op_lshift; |
3204
|
1802 break; |
|
1803 |
3533
|
1804 case op_rshift_eq: |
|
1805 binop = op_rshift; |
3204
|
1806 break; |
|
1807 |
3533
|
1808 case op_el_mul_eq: |
|
1809 binop = op_el_mul; |
3204
|
1810 break; |
|
1811 |
3533
|
1812 case op_el_div_eq: |
|
1813 binop = op_el_div; |
3204
|
1814 break; |
|
1815 |
3533
|
1816 case op_el_ldiv_eq: |
|
1817 binop = op_el_ldiv; |
3204
|
1818 break; |
|
1819 |
4018
|
1820 case op_el_pow_eq: |
|
1821 binop = op_el_pow; |
|
1822 break; |
|
1823 |
3533
|
1824 case op_el_and_eq: |
|
1825 binop = op_el_and; |
3204
|
1826 break; |
|
1827 |
3533
|
1828 case op_el_or_eq: |
|
1829 binop = op_el_or; |
3204
|
1830 break; |
|
1831 |
|
1832 default: |
|
1833 { |
3523
|
1834 std::string on = assign_op_as_string (op); |
3204
|
1835 error ("operator %s: no binary operator found", on.c_str ()); |
|
1836 } |
|
1837 } |
|
1838 |
|
1839 return binop; |
|
1840 } |
|
1841 |
3933
|
1842 octave_value |
|
1843 octave_value::empty_conv (const std::string& type, const octave_value& rhs) |
|
1844 { |
|
1845 octave_value retval; |
|
1846 |
|
1847 if (type.length () > 0) |
|
1848 { |
|
1849 switch (type[0]) |
|
1850 { |
|
1851 case '(': |
|
1852 { |
|
1853 if (type.length () > 1 && type[1] == '.') |
|
1854 retval = Octave_map (); |
|
1855 else |
|
1856 retval = octave_value (rhs.empty_clone ()); |
|
1857 } |
|
1858 break; |
|
1859 |
|
1860 case '{': |
|
1861 retval = Cell (); |
|
1862 break; |
|
1863 |
|
1864 case '.': |
|
1865 retval = Octave_map (); |
|
1866 break; |
|
1867 |
|
1868 default: |
|
1869 panic_impossible (); |
|
1870 } |
|
1871 } |
|
1872 else |
|
1873 retval = octave_value (rhs.empty_clone ()); |
|
1874 |
|
1875 return retval; |
|
1876 } |
|
1877 |
2376
|
1878 void |
|
1879 install_types (void) |
|
1880 { |
|
1881 octave_base_value::register_type (); |
3928
|
1882 octave_cell::register_type (); |
2376
|
1883 octave_scalar::register_type (); |
|
1884 octave_complex::register_type (); |
|
1885 octave_matrix::register_type (); |
|
1886 octave_complex_matrix::register_type (); |
|
1887 octave_range::register_type (); |
2825
|
1888 octave_bool::register_type (); |
|
1889 octave_bool_matrix::register_type (); |
2376
|
1890 octave_char_matrix::register_type (); |
|
1891 octave_char_matrix_str::register_type (); |
|
1892 octave_struct::register_type (); |
2903
|
1893 octave_file::register_type (); |
2880
|
1894 octave_list::register_type (); |
3977
|
1895 octave_cs_list::register_type (); |
2376
|
1896 octave_all_va_args::register_type (); |
|
1897 octave_magic_colon::register_type (); |
2974
|
1898 octave_builtin::register_type (); |
|
1899 octave_mapper::register_type (); |
|
1900 octave_user_function::register_type (); |
4643
|
1901 octave_fcn_handle::register_type (); |
|
1902 octave_streamoff::register_type (); |
2376
|
1903 } |
|
1904 |
|
1905 static int |
4455
|
1906 warn_fortran_indexing (void) |
2376
|
1907 { |
4455
|
1908 Vwarn_fortran_indexing = check_preference ("warn_fortran_indexing"); |
2376
|
1909 |
4455
|
1910 liboctave_wfi_flag = Vwarn_fortran_indexing; |
2376
|
1911 |
|
1912 return 0; |
|
1913 } |
|
1914 |
|
1915 static int |
4452
|
1916 warn_imag_to_real (void) |
4257
|
1917 { |
4452
|
1918 Vwarn_imag_to_real = check_preference ("warn_imag_to_real"); |
4257
|
1919 |
|
1920 return 0; |
|
1921 } |
|
1922 |
|
1923 static int |
4452
|
1924 warn_num_to_str (void) |
2376
|
1925 { |
4452
|
1926 Vwarn_num_to_str = check_preference ("warn_num_to_str"); |
2376
|
1927 |
|
1928 return 0; |
|
1929 } |
|
1930 |
|
1931 static int |
4452
|
1932 warn_str_to_num (void) |
2376
|
1933 { |
4452
|
1934 Vwarn_str_to_num = check_preference ("warn_str_to_num"); |
2376
|
1935 |
|
1936 return 0; |
|
1937 } |
|
1938 |
|
1939 static int |
|
1940 print_answer_id_name (void) |
|
1941 { |
|
1942 Vprint_answer_id_name = check_preference ("print_answer_id_name"); |
|
1943 |
|
1944 return 0; |
|
1945 } |
|
1946 |
|
1947 static int |
4461
|
1948 warn_resize_on_range_error (void) |
2376
|
1949 { |
4461
|
1950 Vwarn_resize_on_range_error |
|
1951 = check_preference ("warn_resize_on_range_error"); |
2376
|
1952 |
4461
|
1953 liboctave_wrore_flag = Vwarn_resize_on_range_error; |
2376
|
1954 |
|
1955 return 0; |
|
1956 } |
|
1957 |
|
1958 static int |
4005
|
1959 silent_functions (void) |
|
1960 { |
|
1961 Vsilent_functions = check_preference ("silent_functions"); |
|
1962 |
|
1963 return 0; |
|
1964 } |
|
1965 |
|
1966 static int |
2376
|
1967 struct_levels_to_print (void) |
|
1968 { |
|
1969 double val; |
|
1970 if (builtin_real_scalar_variable ("struct_levels_to_print", val) |
|
1971 && ! xisnan (val)) |
|
1972 { |
|
1973 int ival = NINT (val); |
3961
|
1974 if (ival == val) |
2376
|
1975 { |
|
1976 Vstruct_levels_to_print = ival; |
|
1977 return 0; |
|
1978 } |
|
1979 } |
|
1980 gripe_invalid_value_specified ("struct_levels_to_print"); |
|
1981 return -1; |
|
1982 } |
|
1983 |
|
1984 static int |
|
1985 warn_divide_by_zero (void) |
|
1986 { |
|
1987 Vwarn_divide_by_zero = check_preference ("warn_divide_by_zero"); |
|
1988 |
|
1989 return 0; |
|
1990 } |
|
1991 |
|
1992 void |
2909
|
1993 symbols_of_ov (void) |
2376
|
1994 { |
4233
|
1995 DEFVAR (print_answer_id_name, true, print_answer_id_name, |
3372
|
1996 "-*- texinfo -*-\n\ |
|
1997 @defvr {Built-in Variable} print_answer_id_name\n\ |
|
1998 If the value of @code{print_answer_id_name} is nonzero, variable\n\ |
|
1999 names are printed along with the result. Otherwise, only the result\n\ |
|
2000 values are printed. The default value is 1.\n\ |
|
2001 @end defvr"); |
2376
|
2002 |
4233
|
2003 DEFVAR (silent_functions, false, silent_functions, |
4005
|
2004 "-*- texinfo -*-\n\ |
|
2005 @defvr {Built-in Variable} silent_functions\n\ |
|
2006 If the value of @code{silent_functions} is nonzero, internal output\n\ |
|
2007 from a function is suppressed. Otherwise, the results of expressions\n\ |
|
2008 within a function body that are not terminated with a semicolon will\n\ |
|
2009 have their values printed. The default value is 0.\n\ |
|
2010 \n\ |
|
2011 For example, if the function\n\ |
|
2012 \n\ |
|
2013 @example\n\ |
|
2014 function f ()\n\ |
|
2015 2 + 2\n\ |
|
2016 endfunction\n\ |
|
2017 @end example\n\ |
|
2018 \n\ |
|
2019 @noindent\n\ |
|
2020 is executed, Octave will either print @samp{ans = 4} or nothing\n\ |
|
2021 depending on the value of @code{silent_functions}.\n\ |
|
2022 @end defvr"); |
|
2023 |
3258
|
2024 DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print, |
3361
|
2025 "-*- texinfo -*-\n\ |
|
2026 @defvr {Built-in Variable} struct_levels_to_print\n\ |
|
2027 You can tell Octave how many structure levels to display by setting the\n\ |
|
2028 built-in variable @code{struct_levels_to_print}. The default value is 2.\n\ |
3363
|
2029 @end defvr"); |
2376
|
2030 |
4233
|
2031 DEFVAR (warn_divide_by_zero, true, warn_divide_by_zero, |
3371
|
2032 "-*- texinfo -*-\n\ |
|
2033 @defvr {Built-in Variable} warn_divide_by_zero\n\ |
|
2034 If the value of @code{warn_divide_by_zero} is nonzero, a warning\n\ |
|
2035 is issued when Octave encounters a division by zero. If the value is\n\ |
|
2036 0, the warning is omitted. The default value is 1.\n\ |
|
2037 @end defvr"); |
4451
|
2038 |
4455
|
2039 DEFVAR (warn_fortran_indexing, false, warn_fortran_indexing, |
|
2040 "-*- texinfo -*-\n\ |
|
2041 @defvr {Built-in Variable} warn_fortran_indexing\n\ |
|
2042 If the value of @code{warn_fortran_indexing} is nonzero, a warning is\n\ |
|
2043 printed for expressions which select elements of a two-dimensional matrix\n\ |
|
2044 using a single index. The default value is 0.\n\ |
|
2045 @end defvr"); |
|
2046 |
4451
|
2047 DEFVAR (warn_imag_to_real, false, warn_imag_to_real, |
|
2048 "-*- texinfo -*-\n\ |
|
2049 @defvr {Built-in Variable} warn_imag_to_real\n\ |
|
2050 If the value of @code{warn_imag_to_real} is nonzero, a warning is\n\ |
|
2051 printed for implicit conversions of complex numbers to real numbers.\n\ |
|
2052 The default value is 0.\n\ |
|
2053 @end defvr"); |
4452
|
2054 |
|
2055 DEFVAR (warn_num_to_str, true, warn_num_to_str, |
|
2056 "-*- texinfo -*-\n\ |
|
2057 @defvr {Built-in Variable} warn_num_to_str\n\ |
|
2058 If the value of @code{warn_num_to_str} is nonzero, a warning is\n\ |
|
2059 printed for implicit conversions of numbers to their ASCII character\n\ |
|
2060 equivalents when strings are constructed using a mixture of strings and\n\ |
|
2061 numbers in matrix notation. For example,\n\ |
|
2062 \n\ |
|
2063 @example\n\ |
|
2064 @group\n\ |
|
2065 [ \"f\", 111, 111 ]\n\ |
|
2066 @result{} \"foo\"\n\ |
|
2067 @end group\n\ |
|
2068 @end example\n\ |
|
2069 elicits a warning if @code{warn_num_to_str} is nonzero. The default\n\ |
|
2070 value is 1.\n\ |
|
2071 @end defvr"); |
|
2072 |
4461
|
2073 DEFVAR (warn_resize_on_range_error, false, warn_resize_on_range_error, |
|
2074 "-*- texinfo -*-\n\ |
|
2075 @defvr {Built-in Variable} warn_resize_on_range_error\n\ |
|
2076 If the value of @code{warn_resize_on_range_error} is nonzero, print a\n\ |
|
2077 warning when a matrix is resized by an indexed assignment with\n\ |
|
2078 indices outside the current bounds. The default value is 0.\n\ |
|
2079 @end defvr"); |
|
2080 |
4452
|
2081 DEFVAR (warn_str_to_num, false, warn_str_to_num, |
|
2082 "-*- texinfo -*-\n\ |
|
2083 @defvr {Built-in Variable} warn_str_to_num\n\ |
|
2084 If the value of @code{warn_str_to_num} is nonzero, a warning is printed\n\ |
|
2085 for implicit conversions of strings to their numeric ASCII equivalents.\n\ |
|
2086 For example,\n\ |
|
2087 @example\n\ |
|
2088 @group\n\ |
|
2089 \"abc\" + 0\n\ |
|
2090 @result{} 97 98 99\n\ |
|
2091 @end group\n\ |
|
2092 @end example\n\ |
|
2093 elicits a warning if @code{warn_str_to_num} is nonzero. The default\n\ |
|
2094 value is 0.\n\ |
|
2095 @end defvr"); |
2376
|
2096 } |
|
2097 |
|
2098 /* |
|
2099 ;;; Local Variables: *** |
|
2100 ;;; mode: C++ *** |
|
2101 ;;; End: *** |
|
2102 */ |