Mercurial > hg > octave-lyh
annotate libinterp/parse-tree/pt-arg-list.cc @ 17535:c12c688a35ed default tip lyh
Fix warnings
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Fri, 27 Sep 2013 17:43:27 +0800 |
parents | f0edd6c752e9 |
children |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2982 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2982 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2982 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
3503 | 27 #include <iostream> |
2982 | 28 #include <string> |
29 | |
30 #include "str-vec.h" | |
31 | |
4234 | 32 #include "defun.h" |
2982 | 33 #include "error.h" |
5846 | 34 #include "oct-lvalue.h" |
2982 | 35 #include "oct-obj.h" |
36 #include "ov.h" | |
37 #include "ov-usr-fcn.h" | |
8136
2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
38 #include "parse.h" |
2982 | 39 #include "pt-arg-list.h" |
40 #include "pt-exp.h" | |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
41 #include "pt-id.h" |
2982 | 42 #include "pt-pr-code.h" |
43 #include "pt-walk.h" | |
44 #include "toplev.h" | |
4234 | 45 #include "unwind-prot.h" |
2982 | 46 |
47 // Argument lists. | |
48 | |
49 tree_argument_list::~tree_argument_list (void) | |
50 { | |
4219 | 51 while (! empty ()) |
2982 | 52 { |
4219 | 53 iterator p = begin (); |
54 delete *p; | |
55 erase (p); | |
2982 | 56 } |
57 } | |
58 | |
4267 | 59 bool |
60 tree_argument_list::has_magic_end (void) const | |
61 { | |
62 for (const_iterator p = begin (); p != end (); p++) | |
63 { | |
64 tree_expression *elt = *p; | |
65 | |
66 if (elt && elt->has_magic_end ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
67 return true; |
4267 | 68 } |
69 | |
70 return false; | |
71 } | |
72 | |
4258 | 73 void |
74 tree_argument_list::append (const element_type& s) | |
75 { | |
76 octave_base_list<tree_expression *>::append (s); | |
77 | |
4267 | 78 if (! list_includes_magic_end && s && s->has_magic_end ()) |
79 list_includes_magic_end = true; | |
10206
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 (! list_includes_magic_tilde && s && s->is_identifier ()) |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
82 { |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
83 tree_identifier *id = dynamic_cast<tree_identifier *> (s); |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
84 list_includes_magic_tilde = id && id->is_black_hole (); |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
85 } |
4258 | 86 } |
87 | |
2982 | 88 bool |
89 tree_argument_list::all_elements_are_constant (void) const | |
90 { | |
4219 | 91 for (const_iterator p = begin (); p != end (); p++) |
2982 | 92 { |
4219 | 93 tree_expression *elt = *p; |
2982 | 94 |
95 if (! elt->is_constant ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
96 return false; |
2982 | 97 } |
98 | |
99 return true; | |
100 } | |
101 | |
16285
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
102 bool |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
103 tree_argument_list::is_valid_lvalue_list (void) const |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
104 { |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
105 bool retval = true; |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
106 |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
107 for (const_iterator p = begin (); p != end (); p++) |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
108 { |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
109 tree_expression *elt = *p; |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
110 |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
111 // There is no need for a separate check for the magic "~" because |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
112 // it represented by tree_black_hole, and that is derived from |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
113 // tree_identifier. |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
114 |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
115 if (! (elt->is_identifier () || elt->is_index_expression ())) |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
116 { |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
117 retval = false; |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
118 break; |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
119 } |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
120 } |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
121 |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
122 return retval; |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
123 } |
3389152014ca
improve validation of left hand side of assignment expressions in parser
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
124 |
4234 | 125 static const octave_value *indexed_object = 0; |
126 static int index_position = 0; | |
7751
7c020c067a60
F__end__: correctly handle fewer indices than dimensions
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
127 static int num_indices = 0; |
4234 | 128 |
17363
f0edd6c752e9
don't convert "end" token to "__end__" for indexing
John W. Eaton <jwe@octave.org>
parents:
16755
diff
changeset
|
129 DEFCONSTFUN (end, , , |
4234 | 130 "internal function") |
131 { | |
132 octave_value retval; | |
133 | |
134 if (indexed_object) | |
135 { | |
8136
2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
136 if (indexed_object->is_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
137 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
138 octave_value_list args; |
8136
2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
139 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
140 args(2) = num_indices; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
141 args(1) = index_position + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
142 args(0) = *indexed_object; |
8136
2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
143 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
144 std::string class_name = indexed_object->class_name (); |
8136
2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
145 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
146 octave_value meth = symbol_table::find_method ("end", class_name); |
8136
2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
147 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
148 if (meth.is_defined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
149 return feval (meth.function_value (), args, 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
150 } |
8136
2b2ca62f8ab6
dispatch to user-defined end function for classes if one is defined
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
151 |
4671 | 152 dim_vector dv = indexed_object->dims (); |
7751
7c020c067a60
F__end__: correctly handle fewer indices than dimensions
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
153 int ndims = dv.length (); |
4671 | 154 |
7751
7c020c067a60
F__end__: correctly handle fewer indices than dimensions
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
155 if (num_indices < ndims) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
156 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
157 for (int i = num_indices; i < ndims; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
158 dv(num_indices-1) *= dv(i); |
4256 | 159 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
160 if (num_indices == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
161 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
162 ndims = 2; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
163 dv.resize (ndims); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
164 dv(1) = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
165 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
166 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
167 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
168 ndims = num_indices; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
169 dv.resize (ndims); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
170 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
171 } |
4234 | 172 |
7751
7c020c067a60
F__end__: correctly handle fewer indices than dimensions
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
173 if (index_position < ndims) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
174 retval = dv(index_position); |
7751
7c020c067a60
F__end__: correctly handle fewer indices than dimensions
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
175 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
176 retval = 1; |
4234 | 177 } |
178 else | |
4256 | 179 ::error ("invalid use of end"); |
4234 | 180 |
181 return retval; | |
182 } | |
183 | |
2982 | 184 octave_value_list |
4234 | 185 tree_argument_list::convert_to_const_vector (const octave_value *object) |
2982 | 186 { |
4256 | 187 // END doesn't make sense for functions. Maybe we need a different |
188 // way of asking an octave_value object this question? | |
189 | |
4258 | 190 bool stash_object = (list_includes_magic_end |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
191 && object |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
192 && ! (object->is_function () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
193 || object->is_function_handle ())); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
194 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9702
diff
changeset
|
195 unwind_protect frame; |
4234 | 196 |
4256 | 197 if (stash_object) |
198 { | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9702
diff
changeset
|
199 frame.protect_var (indexed_object); |
4256 | 200 |
201 indexed_object = object; | |
202 } | |
4234 | 203 |
2982 | 204 int len = length (); |
205 | |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8173
diff
changeset
|
206 std::list<octave_value_list> args; |
2982 | 207 |
4219 | 208 iterator p = begin (); |
2982 | 209 for (int k = 0; k < len; k++) |
210 { | |
4974 | 211 if (stash_object) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
212 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
213 frame.protect_var (index_position); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
214 frame.protect_var (num_indices); |
4974 | 215 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
216 index_position = k; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
217 num_indices = len; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
218 } |
4234 | 219 |
4219 | 220 tree_expression *elt = *p++; |
2982 | 221 |
222 if (elt) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
223 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
224 octave_value tmp = elt->rvalue1 (); |
2982 | 225 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
226 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
227 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
228 ::error ("evaluating argument list element number %d", k+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
229 args.clear (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
230 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
231 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
232 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
233 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
234 if (tmp.is_cs_list ()) |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8173
diff
changeset
|
235 args.push_back (tmp.list_value ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
236 else if (tmp.is_defined ()) |
8580
188d38a553c7
further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents:
8173
diff
changeset
|
237 args.push_back (tmp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
238 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
239 } |
2982 | 240 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
241 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
242 args.push_back (octave_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
243 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10206
diff
changeset
|
244 } |
2982 | 245 } |
246 | |
247 return args; | |
248 } | |
249 | |
5846 | 250 std::list<octave_lvalue> |
251 tree_argument_list::lvalue_list (void) | |
252 { | |
253 std::list<octave_lvalue> retval; | |
254 | |
255 for (tree_argument_list::iterator p = begin (); | |
256 p != end (); | |
257 p++) | |
258 { | |
259 tree_expression *elt = *p; | |
260 | |
261 retval.push_back (elt->lvalue ()); | |
262 } | |
263 | |
264 return retval; | |
265 } | |
266 | |
2982 | 267 string_vector |
268 tree_argument_list::get_arg_names (void) const | |
269 { | |
270 int len = length (); | |
271 | |
272 string_vector retval (len); | |
273 | |
274 int k = 0; | |
275 | |
4219 | 276 for (const_iterator p = begin (); p != end (); p++) |
2982 | 277 { |
4219 | 278 tree_expression *elt = *p; |
2982 | 279 |
2991 | 280 retval(k++) = elt->str_print_code (); |
2982 | 281 } |
282 | |
283 return retval; | |
284 } | |
285 | |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
286 std::list<std::string> |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
287 tree_argument_list::variable_names (void) const |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
288 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
289 std::list<std::string> retval; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
290 |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
291 for (const_iterator p = begin (); p != end (); p++) |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
292 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
293 tree_expression *elt = *p; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
294 |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
295 if (elt->is_identifier ()) |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
296 { |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
297 tree_identifier *id = dynamic_cast<tree_identifier *> (elt); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
298 |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
299 retval.push_back (id->name ()); |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
300 } |
16755
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16360
diff
changeset
|
301 else if (elt->is_index_expression ()) |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16360
diff
changeset
|
302 { |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16360
diff
changeset
|
303 tree_index_expression *idx_expr |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16360
diff
changeset
|
304 = dynamic_cast<tree_index_expression *> (elt); |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16360
diff
changeset
|
305 |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16360
diff
changeset
|
306 retval.push_back (idx_expr->name ()); |
787168f5f858
tag symbols in indexed assignments as variables (bug #39240)
John W. Eaton <jwe@octave.org>
parents:
16360
diff
changeset
|
307 } |
16360
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
308 } |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
309 |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
310 return retval; |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
311 } |
11115c237231
recognize variables when parsing (bug #38576)
John W. Eaton <jwe@octave.org>
parents:
16285
diff
changeset
|
312 |
5861 | 313 tree_argument_list * |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7751
diff
changeset
|
314 tree_argument_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_argument_list *new_list = new tree_argument_list (); | |
318 | |
319 new_list->list_includes_magic_end = list_includes_magic_end; | |
320 new_list->simple_assign_lhs = simple_assign_lhs; | |
321 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
322 for (const_iterator p = begin (); p != end (); p++) |
5861 | 323 { |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
324 const tree_expression *elt = *p; |
5861 | 325 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7751
diff
changeset
|
326 new_list->append (elt ? elt->dup (scope, context) : 0); |
5861 | 327 } |
328 | |
329 return new_list; | |
330 } | |
331 | |
2982 | 332 void |
333 tree_argument_list::accept (tree_walker& tw) | |
334 { | |
335 tw.visit_argument_list (*this); | |
336 } |