annotate libinterp/parse-tree/pt-walk.cc @ 29359:7854d5752dd2

maint: merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 10:10:40 -0500
parents b8ab8b58547d 0a5b15007766
children c19f8cbe0fd5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
3 // Copyright (C) 2017-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
23424
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 # include "config.h"
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
30 #include "pt-all.h"
23424
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 namespace octave
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 {
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
34 void tree_walker::visit_anon_fcn_handle (tree_anon_fcn_handle&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
35 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
36 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
37 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
38
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
39 void tree_walker::visit_argument_list (tree_argument_list& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
40 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
41 auto p = lst.begin ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
42
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
43 while (p != lst.end ())
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
44 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
45 tree_expression *elt = *p++;
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
46
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
47 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
48 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
49 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
50 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
51
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
52 void tree_walker::visit_binary_expression (tree_binary_expression& expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
53 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
54 tree_expression *op1 = expr.lhs ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
55
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
56 if (op1)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
57 op1->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
58
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
59 tree_expression *op2 = expr.rhs ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
60
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
61 if (op2)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
62 op2->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
63 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
64
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
65 void tree_walker::visit_boolean_expression (tree_boolean_expression& expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
66 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
67 visit_binary_expression (expr);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
68 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
69
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
70 void tree_walker::visit_compound_binary_expression (tree_compound_binary_expression& expr)
23424
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 {
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 visit_binary_expression (expr);
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 }
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
75 void tree_walker::visit_break_command (tree_break_command&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
76 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
77 // Nothing to do.
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
78 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
79
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
80 void tree_walker::visit_colon_expression (tree_colon_expression& expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
81 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
82 tree_expression *op1 = expr.base ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
83
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
84 if (op1)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
85 op1->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
86
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
87 tree_expression *op3 = expr.increment ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
88
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
89 if (op3)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
90 op3->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
91
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
92 tree_expression *op2 = expr.limit ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
93
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
94 if (op2)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
95 op2->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
96 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
97
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
98 void tree_walker::visit_continue_command (tree_continue_command&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
99 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
100 // Nothing to do.
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
101 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
102
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
103 void tree_walker::visit_decl_command (tree_decl_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
104 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
105 tree_decl_init_list *init_list = cmd.initializer_list ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
106
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
107 if (init_list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
108 init_list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
109 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
110
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
111 void tree_walker::visit_decl_elt (tree_decl_elt& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
112 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
113 tree_identifier *id = cmd.ident ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
114
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
115 if (id)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
116 id->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
117
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
118 tree_expression *expr = cmd.expression ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
119
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
120 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
121 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
122 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
123
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
124 void tree_walker::visit_decl_init_list (tree_decl_init_list& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
125 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
126 // FIXME: tree_decl_elt is not derived from tree, so should it
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
127 // really have an accept method?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
128
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
129 for (tree_decl_elt *elt : lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
130 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
131 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
132 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
133 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
134 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
135
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
136 void tree_walker::visit_simple_for_command (tree_simple_for_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
137 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
138 tree_expression *lhs = cmd.left_hand_side ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
139
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
140 if (lhs)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
141 lhs->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
142
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
143 tree_expression *expr = cmd.control_expr ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
144
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
145 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
146 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
147
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
148 tree_expression *maxproc = cmd.maxproc_expr ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
149
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
150 if (maxproc)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
151 maxproc->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
152
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
153 tree_statement_list *list = cmd.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
154
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
155 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
156 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
157 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
158
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
159 void tree_walker::visit_complex_for_command (tree_complex_for_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
160 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
161 tree_argument_list *lhs = cmd.left_hand_side ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
162
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
163 if (lhs)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
164 lhs->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
165
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
166 tree_expression *expr = cmd.control_expr ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
167
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
168 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
169 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
170
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
171 tree_statement_list *list = cmd.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
172
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
173 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
174 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
175 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
176
28518
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
177 void tree_walker::visit_spmd_command (tree_spmd_command& cmd)
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
178 {
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
179 tree_statement_list *body = cmd.body ();
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
180
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
181 if (body)
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
182 body->accept (*this);
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
183 }
b8ab8b58547d accept spmd command blocks as language elements (bug #58676)
John W. Eaton <jwe@octave.org>
parents: 28317
diff changeset
184
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
185 void tree_walker::visit_octave_user_script (octave_user_script& fcn)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
186 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
187 tree_statement_list *cmd_list = fcn.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
188
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
189 if (cmd_list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
190 cmd_list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
191 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
192
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
193 void tree_walker::visit_octave_user_function (octave_user_function& fcn)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
194 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
195 tree_statement_list *cmd_list = fcn.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
196
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
197 if (cmd_list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
198 cmd_list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
199 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
200
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
201 void tree_walker::visit_function_def (tree_function_def& fdef)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
202 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
203 octave_value fcn = fdef.function ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
204
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
205 octave_function *f = fcn.function_value ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
206
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
207 if (f)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
208 f->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
209 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
210
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
211 void tree_walker::visit_identifier (tree_identifier&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
212 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
213 // Nothing to do.
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
214 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
215
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
216 void tree_walker::visit_if_clause (tree_if_clause& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
217 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
218 tree_expression *expr = cmd.condition ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
219
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
220 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
221 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
222
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
223 tree_statement_list *list = cmd.commands ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
224
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
225 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
226 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
227 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
228
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
229 void tree_walker::visit_if_command (tree_if_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
230 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
231 tree_if_command_list *list = cmd.cmd_list ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
232
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
233 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
234 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
235 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
236
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
237 void tree_walker::visit_if_command_list (tree_if_command_list& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
238 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
239 auto p = lst.begin ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
240
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
241 while (p != lst.end ())
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
242 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
243 tree_if_clause *elt = *p++;
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
244
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
245 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
246 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
247 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
248 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
249
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
250 void tree_walker::visit_switch_case (tree_switch_case& cs)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
251 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
252 tree_expression *label = cs.case_label ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
253
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
254 if (label)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
255 label->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
256
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
257 tree_statement_list *list = cs.commands ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
258
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
259 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
260 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
261 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
262
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
263 void tree_walker::visit_switch_case_list (tree_switch_case_list& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
264 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
265 auto p = lst.begin ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
266
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
267 while (p != lst.end ())
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
268 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
269 tree_switch_case *elt = *p++;
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
270
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
271 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
272 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
273 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
274 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
275
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
276 void tree_walker::visit_switch_command (tree_switch_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
277 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
278 tree_expression *expr = cmd.switch_value ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
279
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
280 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
281 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
282
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
283 tree_switch_case_list *list = cmd.case_list ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
284
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
285 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
286 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
287 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
288
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
289 void tree_walker::visit_index_expression (tree_index_expression& expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
290 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
291 tree_expression *e = expr.expression ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
292
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
293 if (e)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
294 e->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
295
28317
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
296 std::list<tree_argument_list *> arg_lists = expr.arg_lists ();
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
297 std::list<string_vector> arg_names = expr.arg_names ();
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
298 std::list<tree_expression *> dyn_fields = expr.dyn_fields ();
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
299
28317
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
300 auto p_arg_lists = arg_lists.begin ();
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
301 auto p_arg_names = arg_names.begin ();
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
302 auto p_dyn_fields = dyn_fields.begin ();
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
303
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
304 std::string type_tags = expr.type_tags ();
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
305 int n = type_tags.length ();
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
306
28317
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
307 for (int i = 0; i < n; i++)
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
308 {
28317
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
309 switch (type_tags[i])
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
310 {
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
311 case '(':
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
312 case '{':
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
313 {
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
314 tree_argument_list *l = *p_arg_lists;
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
315 if (l)
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
316 l->accept (*this);
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
317 }
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
318 break;
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
319
28317
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
320 case '.':
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
321 {
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
322 std::string fn = (*p_arg_names)(0);
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
323 if (fn.empty ())
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
324 {
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
325 tree_expression *df = *p_dyn_fields;
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
326 if (df)
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
327 df->accept (*this);
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
328 }
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
329 }
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
330 break;
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
331
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
332 default:
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
333 panic_impossible ();
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
334 }
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
335
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
336 p_arg_lists++;
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
337 p_arg_names++;
ac87763b1949 capture dynamic field variable values in anonymous functions (bug #58389)
John W. Eaton <jwe@octave.org>
parents: 28256
diff changeset
338 p_dyn_fields++;
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
339 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
340 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
341
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
342 void tree_walker::visit_matrix (tree_matrix& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
343 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
344 auto p = lst.begin ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
345
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
346 while (p != lst.end ())
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
347 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
348 tree_argument_list *elt = *p++;
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
349
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
350 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
351 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
352 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
353 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
354
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
355 void tree_walker::visit_cell (tree_cell& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
356 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
357 auto p = lst.begin ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
358
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
359 while (p != lst.end ())
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
360 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
361 tree_argument_list *elt = *p++;
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
362
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
363 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
364 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
365 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
366 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
367
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
368 void tree_walker::visit_multi_assignment (tree_multi_assignment& expr)
23424
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 {
27725
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
370 tree_argument_list *lhs = expr.left_hand_side ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
371
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
372 if (lhs)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
373 lhs->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
374
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
375 tree_expression *rhs = expr.right_hand_side ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
376
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
377 if (rhs)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
378 rhs->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
379 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
380
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
381 void tree_walker::visit_no_op_command (tree_no_op_command&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
382 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
383 // Nothing to do.
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
384 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
385
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
386 void tree_walker::visit_constant (tree_constant&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
387 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
388 // Nothing to do.
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
389 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
390
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
391 void tree_walker::visit_fcn_handle (tree_fcn_handle&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
392 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
393 // Nothing to do.
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
394 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
395
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
396 void tree_walker::visit_parameter_list (tree_parameter_list& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
397 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
398 auto p = lst.begin ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
399
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
400 while (p != lst.end ())
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
401 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
402 tree_decl_elt *elt = *p++;
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
403
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
404 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
405 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
406 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
407 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
408
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
409 void tree_walker::visit_postfix_expression (tree_postfix_expression& expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
410 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
411 tree_expression *e = expr.operand ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
412
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
413 if (e)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
414 e->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
415 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
416
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
417 void tree_walker::visit_prefix_expression (tree_prefix_expression& expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
418 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
419 tree_expression *e = expr.operand ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
420
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
421 if (e)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
422 e->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
423 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
424
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
425 void tree_walker::visit_return_command (tree_return_command&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
426 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
427 // Nothing to do.
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
428 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
429
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
430 void tree_walker::visit_simple_assignment (tree_simple_assignment& expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
431 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
432 tree_expression *lhs = expr.left_hand_side ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
433
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
434 if (lhs)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
435 lhs->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
436
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
437 tree_expression *rhs = expr.right_hand_side ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
438
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
439 if (rhs)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
440 rhs->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
441 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
442
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
443 void tree_walker::visit_statement (tree_statement& stmt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
444 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
445 tree_command *cmd = stmt.command ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
446
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
447 if (cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
448 cmd->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
449 else
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
450 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
451 tree_expression *expr = stmt.expression ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
452
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
453 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
454 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
455 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
456 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
457
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
458 void tree_walker::visit_statement_list (tree_statement_list& lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
459 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
460 for (tree_statement *elt : lst)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
461 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
462 if (elt)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
463 elt->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
464 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
465 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
466
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
467 void tree_walker::visit_try_catch_command (tree_try_catch_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
468 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
469 tree_statement_list *try_code = cmd.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
470
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
471 if (try_code)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
472 try_code->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
473
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
474 tree_identifier *expr_id = cmd.identifier ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
475
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
476 if (expr_id)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
477 expr_id->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
478
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
479 tree_statement_list *catch_code = cmd.cleanup ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
480
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
481 if (catch_code)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
482 catch_code->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
483 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
484
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
485 void tree_walker::visit_unwind_protect_command (tree_unwind_protect_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
486 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
487 tree_statement_list *unwind_protect_code = cmd.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
488
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
489 if (unwind_protect_code)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
490 unwind_protect_code->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
491
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
492 tree_statement_list *cleanup_code = cmd.cleanup ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
493
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
494 if (cleanup_code)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
495 cleanup_code->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
496 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
497
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
498 void tree_walker::visit_while_command (tree_while_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
499 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
500 tree_expression *expr = cmd.condition ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
501
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
502 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
503 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
504
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
505 tree_statement_list *list = cmd.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
506
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
507 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
508 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
509 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
510
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
511 void tree_walker::visit_do_until_command (tree_do_until_command& cmd)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
512 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
513 tree_statement_list *list = cmd.body ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
514
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
515 if (list)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
516 list->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
517
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
518 tree_expression *expr = cmd.condition ();
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
519
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
520 if (expr)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
521 expr->accept (*this);
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
522 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
523
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
524 void tree_walker::visit_superclass_ref (tree_superclass_ref&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
525 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
526 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
527 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
528
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
529 void tree_walker::visit_metaclass_query (tree_metaclass_query&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
530 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
531 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
532 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
533
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
534 void tree_walker::visit_classdef_attribute (tree_classdef_attribute&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
535 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
536 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
537 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
538
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
539 void tree_walker::visit_classdef_attribute_list (tree_classdef_attribute_list&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
540 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
541 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
542 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
543
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
544 void tree_walker::visit_classdef_superclass (tree_classdef_superclass&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
545 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
546 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
547 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
548
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
549 void tree_walker::visit_classdef_superclass_list (tree_classdef_superclass_list&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
550 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
551 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
552 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
553
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
554 void tree_walker::visit_classdef_property (tree_classdef_property&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
555 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
556 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
557 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
558
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
559 void tree_walker::visit_classdef_property_list (tree_classdef_property_list&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
560 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
561 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
562 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
563
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
564 void tree_walker::visit_classdef_properties_block (tree_classdef_properties_block&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
565 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
566 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
567 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
568
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
569 void tree_walker::visit_classdef_methods_list (tree_classdef_methods_list&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
570 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
571 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
572 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
573
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
574 void tree_walker::visit_classdef_methods_block (tree_classdef_methods_block&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
575 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
576 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
577 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
578
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
579 void tree_walker::visit_classdef_event (tree_classdef_event&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
580 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
581 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
582 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
583
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
584 void tree_walker::visit_classdef_events_list (tree_classdef_events_list&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
585 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
586 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
587 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
588
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
589 void tree_walker::visit_classdef_events_block (tree_classdef_events_block&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
590 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
591 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
592 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
593
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
594 void tree_walker::visit_classdef_enum (tree_classdef_enum&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
595 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
596 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
597 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
598
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
599 void tree_walker::visit_classdef_enum_list (tree_classdef_enum_list&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
600 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
601 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
602 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
603
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
604 void tree_walker::visit_classdef_enum_block (tree_classdef_enum_block&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
605 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
606 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
607 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
608
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
609 void tree_walker::visit_classdef_body (tree_classdef_body&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
610 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
611 // FIXME?
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
612 }
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
613
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
614 void tree_walker::visit_classdef (tree_classdef&)
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
615 {
6388a240de87 move some common actions into tree_walker base class
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
616 // FIXME?
23424
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
617 }
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
618 }