Mercurial > hg > octave-nkf
annotate src/pt-misc.cc @ 10454:79a56d0a6a0d ss-3-3-51
version is now 3.3.51
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 24 Mar 2010 16:27:05 -0400 |
parents | 57a59eae83cc |
children | 1b2fcd122c6a |
rev | line source |
---|---|
577 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004, |
8920 | 4 2005, 2006, 2007, 2008, 2009 John W. Eaton |
577 | 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. | |
577 | 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/>. | |
577 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
1192 | 25 #include <config.h> |
577 | 26 #endif |
27 | |
5848 | 28 #include "Cell.h" |
29 | |
4466 | 30 #include "defun.h" |
2982 | 31 #include "error.h" |
32 #include "ov.h" | |
33 #include "oct-lvalue.h" | |
34 #include "pt-id.h" | |
35 #include "pt-idx.h" | |
36 #include "pt-misc.h" | |
37 #include "pt-walk.h" | |
4466 | 38 #include "utils.h" |
39 | |
577 | 40 // Parameter lists. |
41 | |
1742 | 42 tree_parameter_list::~tree_parameter_list (void) |
43 { | |
4219 | 44 while (! empty ()) |
1742 | 45 { |
4219 | 46 iterator p = begin (); |
47 delete *p; | |
48 erase (p); | |
1742 | 49 } |
50 } | |
51 | |
577 | 52 void |
53 tree_parameter_list::mark_as_formal_parameters (void) | |
54 { | |
4219 | 55 for (iterator p = begin (); p != end (); p++) |
577 | 56 { |
6215 | 57 tree_decl_elt *elt = *p; |
577 | 58 elt->mark_as_formal_parameter (); |
59 } | |
60 } | |
61 | |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
62 bool |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
63 tree_parameter_list::validate (in_or_out type) |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
64 { |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
65 bool retval = true; |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
66 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
67 std::set<std::string> dict; |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
68 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
69 for (iterator p = begin (); p != end (); p++) |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
70 { |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
71 tree_decl_elt *elt = *p; |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
72 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
73 tree_identifier *id = elt->ident (); |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
74 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
75 if (id) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
76 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
77 std::string name = id->name (); |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
78 |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
79 if (id->is_black_hole ()) |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
80 { |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
81 if (type != in) |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
82 error ("invalid use of ~ in output list"); |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
83 } |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
84 else if (dict.find (name) != dict.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
85 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
86 retval = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
87 error ("`%s' appears more than once in parameter list", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
88 name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
89 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
90 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
91 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
92 dict.insert (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
93 } |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
94 } |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
95 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
96 if (! error_state) |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
97 { |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
98 std::string va_type = (type == in ? "varargin" : "varargout"); |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
99 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
100 size_t len = length (); |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
101 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
102 if (len > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
103 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
104 tree_decl_elt *elt = back (); |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
105 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
106 tree_identifier *id = elt->ident (); |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
107 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
108 if (id && id->name () == va_type) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
109 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
110 if (len == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
111 mark_varargs_only (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
112 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
113 mark_varargs (); |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
114 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
115 iterator p = end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
116 --p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
117 delete *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
118 erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
119 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
120 } |
7587
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
121 } |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
122 |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
123 return retval; |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
124 } |
1f662945c2be
handle varargin and varargout without keywords
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
125 |
577 | 126 void |
4466 | 127 tree_parameter_list::initialize_undefined_elements (const std::string& warnfor, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
128 int nargout, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
129 const octave_value& val) |
1093 | 130 { |
4466 | 131 bool warned = false; |
132 | |
133 int count = 0; | |
134 | |
4219 | 135 for (iterator p = begin (); p != end (); p++) |
1093 | 136 { |
4466 | 137 if (++count > nargout) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
138 break; |
4466 | 139 |
6215 | 140 tree_decl_elt *elt = *p; |
2948 | 141 |
7336 | 142 if (! elt->is_variable ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
143 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
144 if (! warned) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
145 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
146 warned = true; |
5781 | 147 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
148 warning_with_id |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
149 ("Octave:undefined-return-values", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
150 "%s: some elements in list of return values are undefined", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
151 warnfor.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
152 } |
4466 | 153 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
154 octave_lvalue tmp = elt->lvalue (); |
2973 | 155 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
156 tmp.assign (octave_value::op_asn_eq, val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
157 } |
1093 | 158 } |
159 } | |
160 | |
161 void | |
2086 | 162 tree_parameter_list::define_from_arg_vector (const octave_value_list& args) |
577 | 163 { |
712 | 164 int nargin = args.length (); |
165 | |
166 int expected_nargin = length (); | |
577 | 167 |
4219 | 168 iterator p = begin (); |
577 | 169 |
712 | 170 for (int i = 0; i < expected_nargin; i++) |
577 | 171 { |
6215 | 172 tree_decl_elt *elt = *p++; |
577 | 173 |
2979 | 174 octave_lvalue ref = elt->lvalue (); |
2959 | 175 |
577 | 176 if (i < nargin) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
177 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
178 if (args(i).is_defined () && args(i).is_magic_colon ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
179 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
180 if (! elt->eval ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
181 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
182 ::error ("no default value for argument %d\n", i+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
183 return; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
184 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
185 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
186 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
187 ref.define (args(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
188 } |
2891 | 189 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
190 elt->eval (); |
577 | 191 } |
192 } | |
193 | |
3239 | 194 void |
4219 | 195 tree_parameter_list::undefine (void) |
3239 | 196 { |
197 int len = length (); | |
198 | |
4219 | 199 iterator p = begin (); |
3239 | 200 |
201 for (int i = 0; i < len; i++) | |
202 { | |
6215 | 203 tree_decl_elt *elt = *p++; |
3239 | 204 |
205 octave_lvalue ref = elt->lvalue (); | |
206 | |
3538 | 207 ref.assign (octave_value::op_asn_eq, octave_value ()); |
3239 | 208 } |
209 } | |
210 | |
2086 | 211 octave_value_list |
9644
080e11f1b0c1
don't return undefined output values from user functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
212 tree_parameter_list::convert_to_const_vector (int nargout, |
080e11f1b0c1
don't return undefined output values from user functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
213 const Cell& varargout) |
577 | 214 { |
5848 | 215 octave_idx_type vlen = varargout.numel (); |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
216 int len = length (); |
577 | 217 |
9644
080e11f1b0c1
don't return undefined output values from user functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
218 // Special case. Will do a shallow copy. |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
219 if (len == 0) |
9644
080e11f1b0c1
don't return undefined output values from user functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
220 return varargout; |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
221 else if (nargout <= len) |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
222 { |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
223 octave_value_list retval (nargout); |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
224 |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
225 int i = 0; |
723 | 226 |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
227 for (iterator p = begin (); p != end (); p++) |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
228 { |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
229 tree_decl_elt *elt = *p; |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
230 if (elt->is_defined ()) |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
231 retval(i++) = elt->rvalue1 (); |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
232 else |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
233 break; |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
234 } |
577 | 235 |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
236 return retval; |
577 | 237 } |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
238 else |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
239 { |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
240 octave_value_list retval (len + vlen); |
577 | 241 |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
242 int i = 0; |
9644
080e11f1b0c1
don't return undefined output values from user functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
243 |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
244 for (iterator p = begin (); p != end (); p++) |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
245 { |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
246 tree_decl_elt *elt = *p; |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
247 retval(i++) = elt->rvalue1 (); |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
248 } |
723 | 249 |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
250 for (octave_idx_type j = 0; j < vlen; j++) |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
251 retval(i++) = varargout(j); |
9644
080e11f1b0c1
don't return undefined output values from user functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
252 |
9691
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
253 return retval; |
318e0cdd31bd
improve OOP subsref handling
Jaroslav Hajek <highegg@gmail.com>
parents:
9644
diff
changeset
|
254 } |
577 | 255 } |
256 | |
1827 | 257 bool |
577 | 258 tree_parameter_list::is_defined (void) |
259 { | |
1827 | 260 bool status = true; |
577 | 261 |
4219 | 262 for (iterator p = begin (); p != end (); p++) |
577 | 263 { |
6215 | 264 tree_decl_elt *elt = *p; |
577 | 265 |
7336 | 266 if (! elt->is_variable ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
267 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
268 status = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
269 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
270 } |
577 | 271 } |
272 | |
273 return status; | |
274 } | |
275 | |
5861 | 276 tree_parameter_list * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7587
diff
changeset
|
277 tree_parameter_list::dup (symbol_table::scope_id scope, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
278 symbol_table::context_id context) const |
5861 | 279 { |
280 tree_parameter_list *new_list = new tree_parameter_list (); | |
281 | |
282 if (takes_varargs ()) | |
283 new_list->mark_varargs (); | |
284 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
285 for (const_iterator p = begin (); p != end (); p++) |
5861 | 286 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
287 const tree_decl_elt *elt = *p; |
5861 | 288 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7587
diff
changeset
|
289 new_list->append (elt->dup (scope, context)); |
5861 | 290 } |
291 | |
292 return new_list; | |
293 } | |
294 | |
577 | 295 void |
2124 | 296 tree_parameter_list::accept (tree_walker& tw) |
581 | 297 { |
2124 | 298 tw.visit_parameter_list (*this); |
581 | 299 } |
300 | |
301 // Return lists. | |
302 | |
1742 | 303 tree_return_list::~tree_return_list (void) |
304 { | |
4219 | 305 while (! empty ()) |
1742 | 306 { |
4219 | 307 iterator p = begin (); |
308 delete *p; | |
309 erase (p); | |
1742 | 310 } |
311 } | |
312 | |
5861 | 313 tree_return_list * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7587
diff
changeset
|
314 tree_return_list::dup (symbol_table::scope_id scope, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
315 symbol_table::context_id context) const |
5861 | 316 { |
317 tree_return_list *new_list = new tree_return_list (); | |
318 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
319 for (const_iterator p = begin (); p != end (); p++) |
5861 | 320 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
321 const tree_index_expression *elt = *p; |
5861 | 322 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7587
diff
changeset
|
323 new_list->append (elt->dup (scope, context)); |
5861 | 324 } |
325 | |
326 return new_list; | |
327 } | |
328 | |
581 | 329 void |
2124 | 330 tree_return_list::accept (tree_walker& tw) |
581 | 331 { |
2124 | 332 tw.visit_return_list (*this); |
581 | 333 } |