GNU Octave 7.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-2022 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
34namespace octave
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 (void) = delete;
45
47
48 // No copying!
49
51
52 tree_anon_scopes& operator = (const tree_anon_scopes&) = delete;
53
54 ~tree_anon_scopes (void) = default;
55
56 std::set<std::string> fcn_parameters (void) const { return m_params; }
57
58 std::set<std::string> free_variables (void) const { return m_vars; }
59
60 // The following methods, though public, don't belong to the
61 // intended user interface of this class.
62
63 void visit_anon_fcn_handle (tree_anon_fcn_handle&);
64
65 void visit_identifier (tree_identifier&);
66
67 void visit_parameter_list (tree_parameter_list&);
68
69 void visit_statement (tree_statement&);
70
71 void visit_statement_list (tree_statement_list&);
72
73 private:
74
75 // Variable names that are function parameters.
76 std::set<std::string> m_params;
77
78 // Other variable names.
79 std::set<std::string> m_vars;
80 };
81}
82
83#endif
std::set< std::string > free_variables(void) const
std::set< std::string > m_vars
~tree_anon_scopes(void)=default
std::set< std::string > fcn_parameters(void) const
tree_anon_scopes(void)=delete
std::set< std::string > m_params
tree_anon_scopes(const tree_anon_scopes &)=delete