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