3353
|
1 /* |
|
2 |
|
3 Copyright (C) 1999 John W. Eaton |
|
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 |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
3353
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
3503
|
28 #include <iostream> |
3353
|
29 |
|
30 #include "Cell.h" |
|
31 #include "defun.h" |
|
32 #include "error.h" |
|
33 #include "oct-obj.h" |
|
34 #include "pt-arg-list.h" |
3770
|
35 #include "pt-bp.h" |
3353
|
36 #include "pt-exp.h" |
|
37 #include "pt-cell.h" |
|
38 #include "pt-walk.h" |
|
39 #include "utils.h" |
|
40 #include "ov.h" |
|
41 #include "variables.h" |
|
42 |
|
43 octave_value |
|
44 tree_cell::rvalue (void) |
|
45 { |
|
46 octave_value retval; |
|
47 |
3770
|
48 MAYBE_DO_BREAKPOINT; |
|
49 |
5275
|
50 octave_idx_type nr = length (); |
|
51 octave_idx_type nc = -1; |
3353
|
52 |
4501
|
53 Cell val; |
3353
|
54 |
|
55 int i = 0; |
|
56 |
4219
|
57 for (iterator p = begin (); p != end (); p++) |
3353
|
58 { |
4219
|
59 tree_argument_list *elt = *p; |
3353
|
60 |
|
61 octave_value_list row = elt->convert_to_const_vector (); |
|
62 |
4501
|
63 if (nc < 0) |
|
64 { |
|
65 nc = row.length (); |
|
66 |
|
67 val = Cell (nr, nc); |
|
68 } |
|
69 else |
|
70 { |
5275
|
71 octave_idx_type this_nc = row.length (); |
4501
|
72 |
|
73 if (nc != this_nc) |
|
74 { |
|
75 ::error ("number of columns must match"); |
|
76 return retval; |
|
77 } |
|
78 } |
|
79 |
5275
|
80 for (octave_idx_type j = 0; j < nc; j++) |
3353
|
81 val(i,j) = row(j); |
|
82 |
|
83 i++; |
|
84 } |
|
85 |
|
86 retval = val; |
|
87 |
|
88 return retval; |
|
89 } |
|
90 |
3556
|
91 octave_value_list |
|
92 tree_cell::rvalue (int nargout) |
|
93 { |
|
94 octave_value_list retval; |
|
95 |
|
96 if (nargout > 1) |
|
97 error ("invalid number of output arguments for cell array"); |
|
98 else |
|
99 retval = rvalue (); |
|
100 |
|
101 return retval; |
|
102 } |
|
103 |
3353
|
104 void |
|
105 tree_cell::accept (tree_walker& tw) |
|
106 { |
|
107 tw.visit_cell (*this); |
|
108 } |
|
109 |
|
110 /* |
|
111 ;;; Local Variables: *** |
|
112 ;;; mode: C++ *** |
|
113 ;;; End: *** |
|
114 */ |