annotate libinterp/parse-tree/pt-anon-scopes.h @ 25824:91e1ca0e3a9d

Save all scopes of nested anonymous functions (bug #45969). * libinterp/parse-tree/pt-anon-scopes.[h,cc]: New files with new class tree_anon_scopes derived from class tree_walker. Collects variables in all scopes of nested anonymous function definitions. * libinterp/octave-value/ov-fcn-handle.cc (octave_fcn_handle::save_ascii, ::save_binary, ::save_hdf5): Use tree_anon_scopes object to save variables of anonymous functions. * test/bug-45969/bug-45969.tst, test/bug-45969/module.mk: New testfiles.
author Olaf Till <i7tiol@t-online.de>
date Sat, 18 Aug 2018 23:05:41 +0200
parents
children 8b548f2f8086
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25824
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
1 /*
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
2
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
3 Copyright (C) 1996-2018 John W. Eaton
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
4 Copyright (C) 2015-2018 Olaf Till
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
5
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
6 This file is part of Octave.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
7
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
11 option) any later version.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
12
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
16 for more details.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
17
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
21
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
22 */
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
23
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
24 #if !defined (octave_pt_anon_scopes_h)
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
25 #define octave_pt_anon_scopes_h 1
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
26
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
27 #include "pt-walk.h"
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
28 #include "ov-usr-fcn.h"
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
29
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
30 namespace octave
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
31 {
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
32 // In possibly nested definitions of anonymous functions, collect
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
33 // their scopes and the symbol records therein.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
34
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
35 class
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
36 tree_anon_scopes : public tree_walker
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
37 {
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
38 public:
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
39
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
40 tree_anon_scopes (void) : scopes (), merged_tables () { }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
41
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
42 tree_anon_scopes (octave_user_function *);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
43
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
44 tree_anon_scopes& operator = (tree_anon_scopes&& tas)
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
45 {
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
46 scopes = std::move (tas.scopes);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
47 merged_tables = std::move (tas.merged_tables);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
48 return *this;
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
49 }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
50
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
51 typedef std::map<std::string, symbol_record> symrec_map;
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
52
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
53 symrec_map::const_iterator begin (void)
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
54 {
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
55 return merged_tables.cbegin ();
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
56 }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
57
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
58 symrec_map::const_iterator end (void)
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
59 {
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
60 return merged_tables.cend ();
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
61 }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
62
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
63 unsigned int symrec_map_size (void)
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
64 {
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
65 return merged_tables.size ();
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
66 }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
67
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
68 // No copying!
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
69
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
70 tree_anon_scopes (const tree_anon_scopes&) = delete;
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
71
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
72 tree_anon_scopes& operator = (const tree_anon_scopes&) = delete;
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
73
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
74 ~tree_anon_scopes (void) { }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
75
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
76 // The following methods, though public, don't belong to the
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
77 // intended user interface of this class.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
78
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
79 void visit_anon_fcn_handle (tree_anon_fcn_handle&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
80
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
81 void visit_argument_list (tree_argument_list&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
82
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
83 void visit_binary_expression (tree_binary_expression&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
84
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
85 void visit_break_command (tree_break_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
86
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
87 void visit_colon_expression (tree_colon_expression&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
88
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
89 void visit_continue_command(tree_continue_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
90
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
91 void visit_decl_command (tree_decl_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
92
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
93 void visit_decl_elt (tree_decl_elt&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
94
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
95 void visit_decl_init_list (tree_decl_init_list&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
96
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
97 void visit_simple_for_command (tree_simple_for_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
98
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
99 void visit_complex_for_command (tree_complex_for_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
100
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
101 void visit_octave_user_script (octave_user_script&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
102
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
103 void visit_octave_user_function (octave_user_function&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
104
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
105 void visit_function_def (tree_function_def&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
106
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
107 void visit_identifier (tree_identifier&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
108
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
109 void visit_if_clause (tree_if_clause&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
110
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
111 void visit_if_command (tree_if_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
112
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
113 void visit_if_command_list (tree_if_command_list&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
114
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
115 void visit_switch_case (tree_switch_case&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
116
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
117 void visit_switch_case_list (tree_switch_case_list&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
118
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
119 void visit_switch_command (tree_switch_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
120
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
121 void visit_index_expression (tree_index_expression&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
122
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
123 void visit_matrix (tree_matrix&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
124
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
125 void visit_cell (tree_cell&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
126
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
127 void visit_multi_assignment (tree_multi_assignment&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
128
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
129 void visit_no_op_command (tree_no_op_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
130
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
131 void visit_constant (tree_constant&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
132
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
133 void visit_fcn_handle (tree_fcn_handle&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
134
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
135 void visit_funcall (tree_funcall&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
136
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
137 void visit_parameter_list (tree_parameter_list&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
138
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
139 void visit_postfix_expression (tree_postfix_expression&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
140
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
141 void visit_prefix_expression (tree_prefix_expression&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
142
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
143 void visit_return_command (tree_return_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
144
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
145 void visit_return_list (tree_return_list&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
146
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
147 void visit_simple_assignment (tree_simple_assignment&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
148
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
149 void visit_statement (tree_statement&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
150
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
151 void visit_statement_list (tree_statement_list&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
152
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
153 void visit_try_catch_command (tree_try_catch_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
154
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
155 void visit_unwind_protect_command (tree_unwind_protect_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
156
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
157 void visit_while_command (tree_while_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
158
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
159 void visit_do_until_command (tree_do_until_command&);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
160
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
161 private:
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
162
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
163 void stash_scope_if_valid (const symbol_scope& sc)
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
164 {
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
165 if (sc)
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
166 scopes.push_back (sc);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
167 else
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
168 error ("internal error, invalid scope");
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
169 }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
170
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
171 // The scope of this anonymous function and the collected scopes
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
172 // of all anonymous functions whose definitions are nested in the
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
173 // current anonymous function definition.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
174
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
175 std::vector<symbol_scope> scopes;
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
176
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
177 // Symbol records of all collected scopes are merged over variable names.
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
178
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
179 typedef std::list<symbol_record> symrec_list;
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
180
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
181 void merge_tables (void);
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
182
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
183 symrec_map merged_tables;
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
184 };
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
185 }
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
186
91e1ca0e3a9d Save all scopes of nested anonymous functions (bug #45969).
Olaf Till <i7tiol@t-online.de>
parents:
diff changeset
187 #endif