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 |
|
23 #if defined (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
3503
|
31 #include <iostream> |
|
32 #include <strstream> |
3353
|
33 |
|
34 #include "Cell.h" |
|
35 #include "defun.h" |
|
36 #include "error.h" |
|
37 #include "oct-obj.h" |
|
38 #include "pt-arg-list.h" |
|
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 |
|
51 int nr = length (); |
|
52 int nc = -1; |
|
53 |
|
54 for (Pix p = first (); p != 0; next (p)) |
|
55 { |
|
56 tree_argument_list *elt = this->operator () (p); |
|
57 |
|
58 if (nc < 0) |
|
59 nc = elt->length (); |
|
60 else if (nc != elt->length ()) |
|
61 { |
|
62 ::error ("number of columns must match"); |
|
63 return retval; |
|
64 } |
|
65 } |
|
66 |
|
67 Cell val (nr, nc); |
|
68 |
|
69 int i = 0; |
|
70 |
|
71 for (Pix p = first (); p != 0; next (p)) |
|
72 { |
|
73 tree_argument_list *elt = this->operator () (p); |
|
74 |
|
75 octave_value_list row = elt->convert_to_const_vector (); |
|
76 |
|
77 for (int j = 0; j < nc; j++) |
|
78 val(i,j) = row(j); |
|
79 |
|
80 i++; |
|
81 } |
|
82 |
|
83 retval = val; |
|
84 |
|
85 return retval; |
|
86 } |
|
87 |
|
88 void |
|
89 tree_cell::accept (tree_walker& tw) |
|
90 { |
|
91 tw.visit_cell (*this); |
|
92 } |
|
93 |
|
94 /* |
|
95 ;;; Local Variables: *** |
|
96 ;;; mode: C++ *** |
|
97 ;;; End: *** |
|
98 */ |