GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
pt-anon-scopes.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if !defined (octave_pt_anon_scopes_h)
27 #define octave_pt_anon_scopes_h 1
28 
29 #include <set>
30 #include <string>
31 
32 #include "pt-walk.h"
33 
35 
36 // In possibly nested definitions of anonymous functions, collect
37 // their scopes and the symbol records therein.
38 
39 class
41 {
42 public:
43 
44  tree_anon_scopes () = delete;
45 
47 
48  OCTAVE_DISABLE_COPY_MOVE (tree_anon_scopes)
49 
50  ~tree_anon_scopes () = default;
51 
52  std::set<std::string> fcn_parameters () const { return m_params; }
53 
54  std::set<std::string> free_variables () const { return m_vars; }
55 
56  // The following methods, though public, don't belong to the
57  // intended user interface of this class.
58 
59  void visit_anon_fcn_handle (tree_anon_fcn_handle&);
60 
61  void visit_identifier (tree_identifier&);
62 
63  void visit_parameter_list (tree_parameter_list&);
64 
65  void visit_statement (tree_statement&);
66 
67  void visit_statement_list (tree_statement_list&);
68 
69 private:
70 
71  // Variable names that are function parameters.
72  std::set<std::string> m_params;
73 
74  // Other variable names.
75  std::set<std::string> m_vars;
76 };
77 
78 OCTAVE_END_NAMESPACE(octave)
79 
80 #endif
std::set< std::string > free_variables() const
tree_anon_scopes()=delete
~tree_anon_scopes()=default
std::set< std::string > fcn_parameters() const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn