Mercurial > octave-nkf
annotate src/pt-cell.cc @ 7961:a5d1e27ee1f4 ss-3-1-51
3.1.51 snapshot
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Jul 2008 11:40:48 -0400 |
parents | 71f068b22fcc |
children | 79845b1793cf |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 |
4 John W. Eaton | |
3353 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3353 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
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 | |
5861 | 104 tree_expression * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
105 tree_cell::dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
106 symbol_table::context_id context) |
5861 | 107 { |
108 tree_cell *new_cell = new tree_cell (0, line (), column ()); | |
109 | |
110 for (iterator p = begin (); p != end (); p++) | |
111 { | |
112 tree_argument_list *elt = *p; | |
113 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
114 new_cell->append (elt ? elt->dup (scope, context) : 0); |
5861 | 115 } |
116 | |
117 new_cell->copy_base (*this); | |
118 | |
119 return new_cell; | |
120 } | |
121 | |
3353 | 122 void |
123 tree_cell::accept (tree_walker& tw) | |
124 { | |
125 tw.visit_cell (*this); | |
126 } | |
127 | |
128 /* | |
129 ;;; Local Variables: *** | |
130 ;;; mode: C++ *** | |
131 ;;; End: *** | |
132 */ |