annotate libinterp/corefcn/syminfo.h @ 26088:2b92498c111e

move symbol_info and symbol_info_list classes to separate file * syminfo.h, syminfo.h: New files. Move symbol_info and symbol_info_list classes here from variables.cc and move them inside octave namespace. Change all uses. * libinterp/corefcn/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Thu, 15 Nov 2018 22:45:04 -0500
parents
children fb907736f335
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26088
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2018 John W. Eaton
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 (at your option) any later version.
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 GNU General Public License for more details.
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <https://www.gnu.org/licenses/>.
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #if ! defined (octave_syminfo_h)
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #define octave_syminfo_h 1
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #include "octave-config.h"
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <string>
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <iosfwd>
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "ov.h"
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 class octave_map;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 namespace octave
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 {
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 struct whos_parameter
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 {
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 char command;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 char modifier;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 int parameter_length;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 int first_parameter_length;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 int balance;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 std::string text;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 std::string line;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 };
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 class symbol_info
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 {
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 public:
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 symbol_info (const std::string& name, const octave_value& value,
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 bool is_automatic, bool is_complex, bool is_formal,
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 bool is_global, bool is_persistent)
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 : m_name (name), m_value (value), m_is_automatic (is_automatic),
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 m_is_complex (is_complex), m_is_formal (is_formal),
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 m_is_global (is_global), m_is_persistent (is_persistent)
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 { }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 std::string name (void) const { return m_name; }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 octave_value value (void) const { return m_value; }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 bool is_automatic (void) const { return m_is_automatic; }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 bool is_complex (void) const { return m_is_complex; }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 bool is_formal (void) const { return m_is_formal; }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 bool is_global (void) const { return m_is_global; }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 bool is_persistent (void) const { return m_is_persistent; }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 void display_line (std::ostream& os,
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 const std::list<whos_parameter>& params) const;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 private:
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 std::string m_name;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 octave_value m_value;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 bool m_is_automatic;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 bool m_is_complex;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 bool m_is_formal;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 bool m_is_global;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 bool m_is_persistent;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 };
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 class symbol_info_list
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 {
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 public:
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 symbol_info_list (void) = default;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 symbol_info_list (const symbol_info_list&) = default;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 symbol_info_list& operator = (const symbol_info_list&) = default;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97 ~symbol_info_list (void) = default;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 void append (const symbol_info& syminf)
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 {
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 m_lst.push_back (syminf);
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 size_t size (void) const { return m_lst.size (); }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 bool empty (void) const { return m_lst.empty (); }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 octave_map map_value (const std::string& caller_function_name,
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 int nesting_level) const;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 // Print a line of information for a given symbol.
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 void print_descriptor (std::ostream& os,
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 const std::list<whos_parameter> params) const;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 void display (std::ostream& os, const std::string& format);
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 // Parse FORMAT, and return a parameter list,
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 // containing all information needed to print the given
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 // attributes of the symbols.
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 std::list<whos_parameter>
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 parse_whos_line_format (const std::string& format);
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 private:
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 std::list<symbol_info> m_lst;
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 };
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 }
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128
2b92498c111e move symbol_info and symbol_info_list classes to separate file
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 #endif