2980
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
|
4 2007 John W. Eaton |
2980
|
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. |
2980
|
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/>. |
2980
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
3933
|
28 #include "Cell.h" |
2980
|
29 #include "error.h" |
3930
|
30 #include "oct-map.h" |
2980
|
31 #include "oct-obj.h" |
|
32 #include "oct-lvalue.h" |
|
33 #include "ov.h" |
3930
|
34 #include "pager.h" |
2982
|
35 #include "pt-arg-list.h" |
3930
|
36 #include "pt-bp.h" |
7336
|
37 #include "pt-id.h" |
2980
|
38 #include "pt-idx.h" |
|
39 #include "pt-walk.h" |
3930
|
40 #include "utils.h" |
|
41 #include "variables.h" |
2980
|
42 |
|
43 // Index expressions. |
|
44 |
5861
|
45 tree_index_expression::tree_index_expression (int l, int c) |
|
46 : tree_expression (l, c), expr (), args (), type (), |
|
47 arg_nm (), dyn_field () { } |
|
48 |
3546
|
49 tree_index_expression::tree_index_expression (tree_expression *e, |
|
50 tree_argument_list *lst, |
3933
|
51 int l, int c, char t) |
4131
|
52 : tree_expression (l, c), expr (e), args (), type (), |
|
53 arg_nm (), dyn_field () |
3933
|
54 { |
|
55 append (lst, t); |
|
56 } |
3215
|
57 |
3930
|
58 tree_index_expression::tree_index_expression (tree_expression *e, |
|
59 const std::string& n, |
3944
|
60 int l, int c) |
4131
|
61 : tree_expression (l, c), expr (e), args (), type (), |
|
62 arg_nm (), dyn_field () |
3933
|
63 { |
|
64 append (n); |
|
65 } |
|
66 |
4131
|
67 tree_index_expression::tree_index_expression (tree_expression *e, |
|
68 tree_expression *df, |
|
69 int l, int c) |
|
70 : tree_expression (l, c), expr (e), args (), type (), |
|
71 arg_nm (), dyn_field () |
|
72 { |
|
73 append (df); |
|
74 } |
|
75 |
3933
|
76 void |
|
77 tree_index_expression::append (tree_argument_list *lst, char t) |
|
78 { |
4219
|
79 args.push_back (lst); |
3933
|
80 type.append (1, t); |
4219
|
81 arg_nm.push_back (lst ? lst->get_arg_names () : string_vector ()); |
|
82 dyn_field.push_back (static_cast<tree_expression *> (0)); |
3933
|
83 } |
|
84 |
|
85 void |
|
86 tree_index_expression::append (const std::string& n) |
|
87 { |
4219
|
88 args.push_back (static_cast<tree_argument_list *> (0)); |
3933
|
89 type.append ("."); |
4219
|
90 arg_nm.push_back (n); |
|
91 dyn_field.push_back (static_cast<tree_expression *> (0)); |
4131
|
92 } |
|
93 |
|
94 void |
|
95 tree_index_expression::append (tree_expression *df) |
|
96 { |
4219
|
97 args.push_back (static_cast<tree_argument_list *> (0)); |
4131
|
98 type.append ("."); |
4219
|
99 arg_nm.push_back (""); |
|
100 dyn_field.push_back (df); |
3933
|
101 } |
3930
|
102 |
2980
|
103 tree_index_expression::~tree_index_expression (void) |
|
104 { |
|
105 delete expr; |
3933
|
106 |
|
107 while (! args.empty ()) |
|
108 { |
4219
|
109 std::list<tree_argument_list *>::iterator p = args.begin (); |
|
110 delete *p; |
|
111 args.erase (p); |
3933
|
112 } |
2980
|
113 } |
|
114 |
5099
|
115 bool |
|
116 tree_index_expression::has_magic_end (void) const |
|
117 { |
|
118 for (std::list<tree_argument_list *>::const_iterator p = args.begin (); |
|
119 p != args.end (); |
|
120 p++) |
|
121 { |
|
122 tree_argument_list *elt = *p; |
|
123 |
|
124 if (elt && elt->has_magic_end ()) |
|
125 return true; |
|
126 } |
|
127 |
|
128 return false; |
|
129 } |
|
130 |
2991
|
131 // This is useful for printing the name of the variable in an indexed |
|
132 // assignment. |
|
133 |
3536
|
134 std::string |
2991
|
135 tree_index_expression::name (void) const |
|
136 { |
4131
|
137 return expr->name (); |
3933
|
138 } |
|
139 |
|
140 static Cell |
|
141 make_subs_cell (tree_argument_list *args, const string_vector& arg_nm) |
|
142 { |
|
143 Cell retval; |
|
144 |
|
145 octave_value_list arg_values; |
|
146 |
|
147 if (args) |
|
148 arg_values = args->convert_to_const_vector (); |
|
149 |
|
150 if (! error_state) |
|
151 { |
|
152 int n = arg_values.length (); |
|
153 |
|
154 if (n > 0) |
|
155 { |
|
156 arg_values.stash_name_tags (arg_nm); |
|
157 |
4548
|
158 retval.resize (dim_vector (1, n)); |
3933
|
159 |
|
160 for (int i = 0; i < n; i++) |
|
161 retval(0,i) = arg_values(i); |
|
162 } |
|
163 } |
|
164 |
|
165 return retval; |
|
166 } |
|
167 |
|
168 static inline octave_value_list |
4234
|
169 make_value_list (tree_argument_list *args, const string_vector& arg_nm, |
|
170 const octave_value *object) |
3933
|
171 { |
|
172 octave_value_list retval; |
|
173 |
|
174 if (args) |
4234
|
175 retval = args->convert_to_const_vector (object); |
3933
|
176 |
|
177 if (! error_state) |
|
178 { |
|
179 int n = retval.length (); |
|
180 |
|
181 if (n > 0) |
|
182 retval.stash_name_tags (arg_nm); |
|
183 } |
|
184 |
|
185 return retval; |
|
186 } |
|
187 |
4131
|
188 std::string |
4219
|
189 tree_index_expression::get_struct_index |
|
190 (std::list<string_vector>::const_iterator p_arg_nm, |
|
191 std::list<tree_expression *>::const_iterator p_dyn_field) const |
4131
|
192 { |
4219
|
193 std::string fn = (*p_arg_nm)(0); |
4131
|
194 |
|
195 if (fn.empty ()) |
|
196 { |
4219
|
197 tree_expression *df = *p_dyn_field; |
4131
|
198 |
|
199 if (df) |
|
200 { |
|
201 octave_value t = df->rvalue (); |
|
202 |
|
203 if (! error_state) |
4143
|
204 { |
|
205 fn = t.string_value (); |
|
206 |
|
207 if (! valid_identifier (fn)) |
6811
|
208 ::error ("invalid structure field name `%s'", fn.c_str ()); |
4143
|
209 } |
4131
|
210 } |
|
211 else |
|
212 panic_impossible (); |
|
213 } |
|
214 |
|
215 return fn; |
|
216 } |
|
217 |
3933
|
218 Octave_map |
|
219 tree_index_expression::make_arg_struct (void) const |
|
220 { |
4219
|
221 int n = args.size (); |
3933
|
222 |
7336
|
223 Cell type_field (n, 1); |
|
224 Cell subs_field (n, 1); |
3933
|
225 |
4219
|
226 std::list<tree_argument_list *>::const_iterator p_args = args.begin (); |
|
227 std::list<string_vector>::const_iterator p_arg_nm = arg_nm.begin (); |
|
228 std::list<tree_expression *>::const_iterator p_dyn_field = dyn_field.begin (); |
3933
|
229 |
|
230 Octave_map m; |
|
231 |
|
232 for (int i = 0; i < n; i++) |
|
233 { |
|
234 switch (type[i]) |
|
235 { |
|
236 case '(': |
7336
|
237 subs_field(i) = make_subs_cell (*p_args, *p_arg_nm); |
3933
|
238 break; |
|
239 |
|
240 case '{': |
7336
|
241 subs_field(i) = make_subs_cell (*p_args, *p_arg_nm); |
3933
|
242 break; |
|
243 |
|
244 case '.': |
4143
|
245 { |
7336
|
246 subs_field(i) = get_struct_index (p_arg_nm, p_dyn_field); |
4143
|
247 |
|
248 if (error_state) |
|
249 eval_error (); |
|
250 } |
3933
|
251 break; |
|
252 |
|
253 default: |
|
254 panic_impossible (); |
|
255 } |
|
256 |
|
257 if (error_state) |
|
258 return m; |
|
259 |
4219
|
260 p_args++; |
|
261 p_arg_nm++; |
|
262 p_dyn_field++; |
3933
|
263 } |
|
264 |
7336
|
265 m.assign ("type", type_field); |
|
266 m.assign ("subs", subs_field); |
3933
|
267 |
|
268 return m; |
2991
|
269 } |
|
270 |
2980
|
271 octave_value_list |
|
272 tree_index_expression::rvalue (int nargout) |
|
273 { |
|
274 octave_value_list retval; |
|
275 |
|
276 if (error_state) |
|
277 return retval; |
|
278 |
7336
|
279 octave_value first_expr_val; |
|
280 |
|
281 octave_value_list first_args; |
|
282 |
|
283 bool have_args = false; |
|
284 |
|
285 if (expr->is_identifier () && type[0] == '(') |
|
286 { |
|
287 tree_identifier *id = dynamic_cast<tree_identifier *> (expr); |
|
288 |
|
289 if (! (id->is_variable () || args.empty ())) |
|
290 { |
|
291 tree_argument_list *al = *(args.begin ()); |
|
292 |
|
293 size_t n = al ? al->length () : 0; |
|
294 |
|
295 if (n > 0) |
|
296 { |
|
297 string_vector anm = *(arg_nm.begin ()); |
|
298 |
|
299 first_expr_val = id->do_lookup (al, anm, first_args, have_args); |
|
300 } |
|
301 } |
|
302 } |
2980
|
303 |
|
304 if (! error_state) |
|
305 { |
7336
|
306 if (first_expr_val.is_undefined ()) |
|
307 first_expr_val = expr->rvalue (); |
|
308 |
|
309 octave_value tmp = first_expr_val; |
|
310 |
4219
|
311 std::list<octave_value_list> idx; |
3930
|
312 |
4219
|
313 int n = args.size (); |
3933
|
314 |
4219
|
315 std::list<tree_argument_list *>::iterator p_args = args.begin (); |
|
316 std::list<string_vector>::iterator p_arg_nm = arg_nm.begin (); |
|
317 std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin (); |
3930
|
318 |
3933
|
319 for (int i = 0; i < n; i++) |
|
320 { |
4432
|
321 if (i > 0) |
|
322 { |
|
323 tree_argument_list *al = *p_args; |
|
324 |
|
325 if (al && al->has_magic_end ()) |
|
326 { |
|
327 // We have an expression like |
|
328 // |
|
329 // x{end}.a(end) |
|
330 // |
|
331 // and we are looking at the argument list that |
|
332 // contains the second (or third, etc.) "end" token, |
|
333 // so we must evaluate everything up to the point of |
7336
|
334 // that argument list so we can pass the appropriate |
4432
|
335 // value to the built-in __end__ function. |
|
336 |
|
337 octave_value_list tmp_list |
7336
|
338 = first_expr_val.subsref (type.substr (0, i), idx, nargout); |
4432
|
339 |
|
340 tmp = tmp_list(0); |
|
341 |
|
342 if (error_state) |
|
343 break; |
|
344 } |
|
345 } |
|
346 |
3933
|
347 switch (type[i]) |
|
348 { |
|
349 case '(': |
7336
|
350 if (have_args) |
|
351 { |
|
352 idx.push_back (first_args); |
|
353 have_args = false; |
|
354 } |
|
355 else |
|
356 idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp)); |
3933
|
357 break; |
3930
|
358 |
3933
|
359 case '{': |
4234
|
360 idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp)); |
3933
|
361 break; |
2980
|
362 |
3933
|
363 case '.': |
4143
|
364 { |
4233
|
365 idx.push_back (octave_value (get_struct_index (p_arg_nm, p_dyn_field))); |
4143
|
366 |
|
367 if (error_state) |
|
368 eval_error (); |
|
369 } |
3933
|
370 break; |
3930
|
371 |
3933
|
372 default: |
|
373 panic_impossible (); |
|
374 } |
3930
|
375 |
3933
|
376 if (error_state) |
|
377 break; |
|
378 |
4219
|
379 p_args++; |
|
380 p_arg_nm++; |
|
381 p_dyn_field++; |
2980
|
382 } |
3933
|
383 |
|
384 if (! error_state) |
4432
|
385 retval = first_expr_val.subsref (type, idx, nargout); |
2980
|
386 } |
|
387 |
|
388 return retval; |
|
389 } |
|
390 |
|
391 octave_value |
|
392 tree_index_expression::rvalue (void) |
|
393 { |
|
394 octave_value retval; |
|
395 |
|
396 octave_value_list tmp = rvalue (1); |
|
397 |
|
398 if (! tmp.empty ()) |
|
399 retval = tmp(0); |
|
400 |
|
401 return retval; |
|
402 } |
|
403 |
|
404 octave_lvalue |
|
405 tree_index_expression::lvalue (void) |
|
406 { |
|
407 octave_lvalue retval; |
|
408 |
4219
|
409 std::list<octave_value_list> idx; |
3933
|
410 |
4219
|
411 int n = args.size (); |
3933
|
412 |
4219
|
413 std::list<tree_argument_list *>::iterator p_args = args.begin (); |
|
414 std::list<string_vector>::iterator p_arg_nm = arg_nm.begin (); |
|
415 std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin (); |
3933
|
416 |
4234
|
417 retval = expr->lvalue (); |
3933
|
418 |
2980
|
419 if (! error_state) |
|
420 { |
7099
|
421 bool have_new_struct_field = false; |
|
422 |
|
423 octave_idx_type new_struct_field_nel = 0; |
|
424 |
4432
|
425 // I think it is OK to have a copy here. |
|
426 |
|
427 const octave_value *tro = retval.object (); |
|
428 |
|
429 octave_value first_retval_object; |
|
430 |
|
431 if (tro) |
|
432 first_retval_object = *tro; |
|
433 |
|
434 octave_value tmp = first_retval_object; |
4234
|
435 |
|
436 for (int i = 0; i < n; i++) |
|
437 { |
4432
|
438 if (i > 0) |
|
439 { |
|
440 tree_argument_list *al = *p_args; |
|
441 |
|
442 if (al && al->has_magic_end ()) |
|
443 { |
|
444 // We have an expression like |
|
445 // |
|
446 // x{end}.a(end) |
|
447 // |
|
448 // and we are looking at the argument list that |
|
449 // contains the second (or third, etc.) "end" token, |
|
450 // so we must evaluate everything up to the point of |
7336
|
451 // that argument list so we pass the appropriate |
4432
|
452 // value to the built-in __end__ function. |
|
453 |
|
454 octave_value_list tmp_list |
7336
|
455 = first_retval_object.subsref (type.substr (0, i), idx, 1); |
4432
|
456 |
|
457 tmp = tmp_list(0); |
|
458 |
|
459 if (error_state) |
|
460 break; |
|
461 } |
|
462 } |
|
463 |
4234
|
464 switch (type[i]) |
|
465 { |
|
466 case '(': |
4432
|
467 idx.push_back (make_value_list (*p_args, *p_arg_nm, &tmp)); |
4234
|
468 break; |
|
469 |
|
470 case '{': |
5846
|
471 { |
|
472 octave_value_list tidx |
|
473 = make_value_list (*p_args, *p_arg_nm, &tmp); |
|
474 |
|
475 idx.push_back (tidx); |
|
476 |
|
477 if (i == n-1) |
|
478 { |
|
479 // Last indexing element. Will this result in a |
|
480 // comma-separated list? |
|
481 |
|
482 if (tidx.has_magic_colon ()) |
|
483 { |
|
484 octave_value_list tmp_list |
|
485 = first_retval_object.subsref (type, idx, 1); |
|
486 |
|
487 if (! error_state) |
|
488 { |
|
489 octave_value val = tmp_list(0); |
|
490 |
|
491 if (val.is_cs_list ()) |
|
492 retval.numel (val.numel ()); |
|
493 } |
|
494 } |
|
495 else |
|
496 { |
|
497 octave_idx_type nel = 1; |
|
498 |
|
499 octave_idx_type nidx = tidx.length (); |
|
500 |
|
501 for (octave_idx_type j = 0; j < nidx; j++) |
|
502 { |
|
503 octave_value val = tidx(j); |
|
504 |
|
505 nel *= val.numel (); |
|
506 } |
|
507 |
|
508 retval.numel (nel); |
|
509 } |
|
510 } |
|
511 } |
4234
|
512 break; |
|
513 |
|
514 case '.': |
|
515 { |
6833
|
516 octave_value tidx = get_struct_index (p_arg_nm, p_dyn_field); |
|
517 |
|
518 if (! error_state) |
|
519 { |
|
520 if (i == n-1) |
|
521 { |
|
522 // Last indexing element. Will this result in a |
|
523 // comma-separated list? |
|
524 |
7099
|
525 if (have_new_struct_field) |
|
526 retval.numel (new_struct_field_nel); |
|
527 else if (i > 0) |
7057
|
528 { |
7099
|
529 std::string ttype = type.substr (0, i); |
|
530 |
7100
|
531 char c = ttype[ttype.length()-1]; |
|
532 if (c == '(' || c == '{') |
7057
|
533 { |
7099
|
534 octave_idx_type nel = 1; |
|
535 |
7057
|
536 octave_value_list xidx = idx.back (); |
|
537 |
7099
|
538 octave_idx_type nidx = xidx.length (); |
|
539 |
|
540 for (octave_idx_type j = 0; j < nidx; j++) |
|
541 { |
|
542 octave_value val = xidx(j); |
|
543 |
|
544 nel *= val.numel (); |
|
545 } |
|
546 |
|
547 retval.numel (nel); |
|
548 } |
7200
|
549 else if (first_retval_object.is_defined () |
|
550 && ! (first_retval_object.is_real_matrix () |
|
551 && first_retval_object.is_zero_by_zero ())) |
7099
|
552 { |
|
553 octave_value_list tmp_list |
|
554 = first_retval_object.subsref (ttype, idx, 1); |
|
555 |
|
556 if (! error_state) |
7057
|
557 { |
7099
|
558 octave_value val = tmp_list(0); |
7057
|
559 |
7099
|
560 retval.numel (val.numel ()); |
|
561 } |
|
562 } |
|
563 else |
|
564 retval.numel (1); |
|
565 } |
|
566 else |
|
567 { |
7200
|
568 if (first_retval_object.is_defined () |
|
569 && ! (first_retval_object.is_real_matrix () |
|
570 && first_retval_object.is_zero_by_zero ())) |
7099
|
571 retval.numel (first_retval_object.numel ()); |
|
572 else |
|
573 retval.numel (1); |
|
574 } |
|
575 } |
|
576 else |
|
577 { |
|
578 octave_value tobj = first_retval_object; |
|
579 |
|
580 if (! have_new_struct_field) |
|
581 { |
7200
|
582 if (i > 0 && first_retval_object.is_defined () |
|
583 && ! (first_retval_object.is_real_matrix () |
|
584 && first_retval_object.is_zero_by_zero ())) |
7099
|
585 { |
|
586 std::string ttype = type.substr (0, i); |
|
587 |
7100
|
588 char c = ttype[ttype.length()-1]; |
|
589 |
|
590 if (! (c == '(' || c == '{')) |
7099
|
591 { |
7057
|
592 octave_value_list tmp_list |
|
593 = first_retval_object.subsref (ttype, idx, 1); |
|
594 |
|
595 if (! error_state) |
7099
|
596 tobj = tmp_list(0); |
|
597 } |
|
598 } |
|
599 |
|
600 if (! error_state && tobj.is_map ()) |
|
601 { |
|
602 if (tidx.is_string ()) |
|
603 { |
|
604 Octave_map m = tobj.map_value (); |
|
605 |
|
606 std::string s = tidx.string_value (); |
|
607 |
|
608 if (! m.contains (s)) |
7057
|
609 { |
7099
|
610 have_new_struct_field = true; |
7057
|
611 |
7099
|
612 new_struct_field_nel = m.numel (); |
7057
|
613 } |
|
614 } |
|
615 } |
|
616 } |
6833
|
617 } |
7057
|
618 |
|
619 idx.push_back (octave_value (tidx)); |
6833
|
620 } |
|
621 else |
4234
|
622 eval_error (); |
|
623 } |
|
624 break; |
|
625 |
|
626 default: |
|
627 panic_impossible (); |
|
628 } |
|
629 |
|
630 if (error_state) |
|
631 break; |
|
632 |
|
633 p_args++; |
|
634 p_arg_nm++; |
|
635 p_dyn_field++; |
|
636 } |
3930
|
637 |
3933
|
638 if (! error_state) |
|
639 retval.set_index (type, idx); |
2980
|
640 } |
|
641 |
|
642 return retval; |
|
643 } |
|
644 |
7099
|
645 /* |
|
646 %!test |
|
647 %! x = {1, 2, 3}; |
|
648 %! [x{:}] = deal (4, 5, 6); |
|
649 %! assert (x, {4, 5, 6}); |
|
650 |
|
651 %!test |
|
652 %! [x.a, x.b.c] = deal (1, 2); |
|
653 %! assert (x.a == 1 && x.b.c == 2); |
|
654 |
|
655 %!test |
|
656 %! [x.a, x(2).b] = deal (1, 2); |
|
657 %! assert (x(1).a == 1 && isempty (x(2).a) && isempty (x(1).b) && x(2).b == 2); |
|
658 |
|
659 %!test |
|
660 %! x = struct (zeros (0, 1), {"a", "b"}); |
|
661 %! x(2).b = 1; |
|
662 %! assert (x(2).b == 1); |
|
663 |
|
664 %!test |
|
665 %! x = struct (zeros (0, 1), {"a", "b"}); |
|
666 %! x(2).b = 1; |
|
667 %! assert (x(2).b == 1); |
|
668 */ |
|
669 |
2980
|
670 void |
4143
|
671 tree_index_expression::eval_error (void) const |
2980
|
672 { |
3965
|
673 int l = line (); |
|
674 int c = column (); |
2980
|
675 |
3965
|
676 const char *type_str; |
3930
|
677 |
3965
|
678 if (type[0] == '.') |
|
679 type_str = "structure reference operator"; |
|
680 else if (args.front ()) |
|
681 type_str = "index expression"; |
|
682 else |
|
683 type_str = "expression"; |
3930
|
684 |
3965
|
685 if (l != -1 && c != -1) |
|
686 ::error ("evaluating %s near line %d, column %d", type_str, l, c); |
|
687 else |
|
688 ::error ("evaluating %s", type_str); |
2980
|
689 } |
|
690 |
5861
|
691 tree_index_expression * |
7336
|
692 tree_index_expression::dup (symbol_table::scope_id scope) |
5861
|
693 { |
|
694 tree_index_expression *new_idx_expr |
|
695 = new tree_index_expression (line (), column ()); |
|
696 |
7336
|
697 new_idx_expr->expr = expr ? expr->dup (scope) : 0; |
5861
|
698 |
|
699 std::list<tree_argument_list *> new_args; |
|
700 |
|
701 for (std::list<tree_argument_list *>::iterator p = args.begin (); |
|
702 p != args.end (); |
|
703 p++) |
|
704 { |
|
705 tree_argument_list *elt = *p; |
|
706 |
7336
|
707 new_args.push_back (elt ? elt->dup (scope) : 0); |
5861
|
708 } |
|
709 |
|
710 new_idx_expr->args = new_args; |
|
711 |
|
712 new_idx_expr->type = type; |
|
713 |
|
714 new_idx_expr->arg_nm = arg_nm; |
|
715 |
|
716 std::list<tree_expression *> new_dyn_field; |
|
717 |
|
718 for (std::list<tree_expression *>::iterator p = dyn_field.begin (); |
|
719 p != dyn_field.end (); |
|
720 p++) |
|
721 { |
|
722 tree_expression *elt = *p; |
|
723 |
7336
|
724 new_dyn_field.push_back (elt ? elt->dup (scope) : 0); |
5861
|
725 } |
|
726 |
|
727 new_idx_expr->dyn_field = new_dyn_field; |
|
728 |
|
729 new_idx_expr->copy_base (*this); |
|
730 |
|
731 return new_idx_expr; |
|
732 } |
|
733 |
2980
|
734 void |
|
735 tree_index_expression::accept (tree_walker& tw) |
|
736 { |
|
737 tw.visit_index_expression (*this); |
|
738 } |
|
739 |
|
740 /* |
|
741 ;;; Local Variables: *** |
|
742 ;;; mode: C++ *** |
|
743 ;;; End: *** |
|
744 */ |