Mercurial > octave
annotate libinterp/corefcn/symscope.h @ 25438:cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
Using <iostream> brings with it a static initializer for the std::cin,
std::cout, and std::cerr streams. In most cases they are not needed
and should be avoided if possible.
Files affected:
build-aux/mk-opts.pl
libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp
libinterp/corefcn/__dsearchn__.cc
libinterp/corefcn/c-file-ptr-stream.cc
libinterp/corefcn/c-file-ptr-stream.h
libinterp/corefcn/daspk.cc
libinterp/corefcn/dasrt.cc
libinterp/corefcn/dassl.cc
libinterp/corefcn/defaults.cc
libinterp/corefcn/defun.cc
libinterp/corefcn/file-io.cc
libinterp/corefcn/ft-text-renderer.cc
libinterp/corefcn/gl-render.cc
libinterp/corefcn/help.cc
libinterp/corefcn/ls-ascii-helper.cc
libinterp/corefcn/ls-hdf5.cc
libinterp/corefcn/ls-hdf5.h
libinterp/corefcn/ls-mat-ascii.cc
libinterp/corefcn/ls-mat4.cc
libinterp/corefcn/ls-mat5.cc
libinterp/corefcn/ls-oct-binary.cc
libinterp/corefcn/ls-oct-text.cc
libinterp/corefcn/lsode.cc
libinterp/corefcn/oct-iostrm.cc
libinterp/corefcn/oct-procbuf.cc
libinterp/corefcn/oct-stdstrm.h
libinterp/corefcn/procstream.cc
libinterp/corefcn/procstream.h
libinterp/corefcn/quad.cc
libinterp/corefcn/symscope.h
libinterp/corefcn/symtab.h
libinterp/corefcn/toplev.cc
libinterp/corefcn/urlwrite.cc
libinterp/corefcn/utils.cc
libinterp/corefcn/zfstream.cc
libinterp/dldfcn/__ode15__.cc
libinterp/dldfcn/convhulln.cc
libinterp/octave-value/ov-base-diag.cc
libinterp/octave-value/ov-base-int.cc
libinterp/octave-value/ov-base-mat.cc
libinterp/octave-value/ov-base-scalar.cc
libinterp/octave-value/ov-base-sparse.cc
libinterp/octave-value/ov-base.cc
libinterp/octave-value/ov-bool-mat.cc
libinterp/octave-value/ov-bool-sparse.cc
libinterp/octave-value/ov-bool.cc
libinterp/octave-value/ov-cell.cc
libinterp/octave-value/ov-ch-mat.cc
libinterp/octave-value/ov-class.cc
libinterp/octave-value/ov-colon.cc
libinterp/octave-value/ov-complex.cc
libinterp/octave-value/ov-cs-list.cc
libinterp/octave-value/ov-cx-mat.cc
libinterp/octave-value/ov-cx-sparse.cc
libinterp/octave-value/ov-fcn-handle.cc
libinterp/octave-value/ov-fcn-inline.cc
libinterp/octave-value/ov-float.cc
libinterp/octave-value/ov-flt-complex.cc
libinterp/octave-value/ov-flt-cx-mat.cc
libinterp/octave-value/ov-flt-re-mat.cc
libinterp/octave-value/ov-int16.cc
libinterp/octave-value/ov-int32.cc
libinterp/octave-value/ov-int64.cc
libinterp/octave-value/ov-int8.cc
libinterp/octave-value/ov-java.cc
libinterp/octave-value/ov-range.cc
libinterp/octave-value/ov-re-mat.cc
libinterp/octave-value/ov-re-sparse.cc
libinterp/octave-value/ov-scalar.cc
libinterp/octave-value/ov-str-mat.cc
libinterp/octave-value/ov-struct.cc
libinterp/octave-value/ov-typeinfo.cc
libinterp/octave-value/ov-uint16.cc
libinterp/octave-value/ov-uint32.cc
libinterp/octave-value/ov-uint64.cc
libinterp/octave-value/ov-uint8.cc
libinterp/octave.cc
libinterp/parse-tree/bp-table.cc
libinterp/parse-tree/lex.h
libinterp/parse-tree/profiler.cc
libinterp/parse-tree/pt-arg-list.cc
libinterp/parse-tree/pt-array-list.cc
libinterp/parse-tree/pt-assign.cc
libinterp/parse-tree/pt-cell.cc
libinterp/parse-tree/pt-const.cc
libinterp/parse-tree/pt-eval.cc
libinterp/parse-tree/pt-exp.cc
libinterp/parse-tree/pt-fcn-handle.cc
libinterp/parse-tree/pt-jit.cc
libinterp/parse-tree/pt-pr-code.cc
libinterp/parse-tree/pt-tm-const.cc
libinterp/parse-tree/pt.cc
liboctave/array/Array.cc
liboctave/array/CColVector.cc
liboctave/array/CDiagMatrix.cc
liboctave/array/CMatrix.cc
liboctave/array/CNDArray.cc
liboctave/array/CRowVector.cc
liboctave/array/CSparse.cc
liboctave/array/DiagArray2.cc
liboctave/array/MArray.cc
liboctave/array/Range.cc
liboctave/array/Sparse.cc
liboctave/array/boolMatrix.cc
liboctave/array/boolSparse.cc
liboctave/array/chMatrix.cc
liboctave/array/dColVector.cc
liboctave/array/dDiagMatrix.cc
liboctave/array/dMatrix.cc
liboctave/array/dNDArray.cc
liboctave/array/dRowVector.cc
liboctave/array/dSparse.cc
liboctave/array/fCColVector.cc
liboctave/array/fCDiagMatrix.cc
liboctave/array/fCMatrix.cc
liboctave/array/fCNDArray.cc
liboctave/array/fCRowVector.cc
liboctave/array/fColVector.cc
liboctave/array/fDiagMatrix.cc
liboctave/array/fMatrix.cc
liboctave/array/fNDArray.cc
liboctave/array/fRowVector.cc
liboctave/array/idx-vector.cc
liboctave/numeric/CollocWt.cc
liboctave/numeric/eigs-base.cc
liboctave/system/file-ops.cc
liboctave/system/oct-time.cc
liboctave/util/cmd-hist.cc
liboctave/util/data-conv.cc
liboctave/util/data-conv.h
liboctave/util/file-info.cc
liboctave/util/lo-utils.cc
liboctave/util/lo-utils.h
liboctave/util/quit.cc
liboctave/util/str-vec.cc
liboctave/util/url-transfer.cc
liboctave/util/url-transfer.h
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Jun 2018 10:11:54 -0400 |
parents | 416856765a55 |
children | 0af4653e48a4 |
rev | line source |
---|---|
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
24982
diff
changeset
|
3 Copyright (C) 1993-2018 John W. Eaton |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 This file is part of Octave. |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24377
diff
changeset
|
8 Octave is free software: you can redistribute it and/or modify it |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24377
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 (at your option) any later version. |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 GNU General Public License for more details. |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24377
diff
changeset
|
20 <https://www.gnu.org/licenses/>. |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 */ |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 |
24269
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
24 #if ! defined (octave_symscope_h) |
f494b87d2a93
rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents:
24263
diff
changeset
|
25 #define octave_symscope_h 1 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include "octave-config.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include <deque> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include <list> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <map> |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
32 #include <memory> |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <set> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 #include <string> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "glob-match.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 #include "lo-regexp.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
38 #include "oct-refcount.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 class tree_argument_list; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 class octave_user_function; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 #include "ov.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 #include "ovl.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 #include "symrec.h" |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 namespace octave |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
48 { |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
49 class symbol_scope; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
50 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
51 class symbol_scope_rep |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
52 : public std::enable_shared_from_this<symbol_scope_rep> |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
53 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 public: |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 typedef std::map<std::string, symbol_record>::const_iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 table_const_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 typedef std::map<std::string, symbol_record>::iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 table_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 typedef std::map<std::string, octave_value>::const_iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 subfunctions_const_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 typedef std::map<std::string, octave_value>::iterator |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 subfunctions_iterator; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
66 symbol_scope_rep (const std::string& name = "") |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
67 : m_name (name), m_symbols (), m_subfunctions (), m_fcn (nullptr), |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
68 m_parent (), m_children (), m_is_nested (false), |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 m_is_static (false), m_context (0) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 { } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 // No copying! |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
74 symbol_scope_rep (const symbol_scope&) = delete; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
76 symbol_scope_rep& operator = (const symbol_scope&) = delete; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
78 ~symbol_scope_rep (void) = default; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
79 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 void insert_symbol_record (const symbol_record& sr) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
82 m_symbols[sr.name ()] = sr; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
85 bool is_nested (void) const { return m_is_nested; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
86 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 void mark_nested (void) { m_is_nested = true; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 bool is_static (void) const { return m_is_static; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
90 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 void mark_static (void) { m_is_static = true; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
93 std::shared_ptr<symbol_scope_rep> parent_scope_rep (void) const |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
94 { |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
95 return m_parent.lock (); |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
96 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
98 std::shared_ptr<symbol_scope_rep> dup (void) const |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 { |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
100 std::shared_ptr<symbol_scope_rep> new_sid |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
101 = std::shared_ptr<symbol_scope_rep> (new symbol_scope_rep (m_name)); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 for (const auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 new_sid->insert_symbol_record (nm_sr.second.dup (new_sid)); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 new_sid->m_parent = m_parent; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
107 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 return new_sid; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
111 void set_context (symbol_record::context_id context) |
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
112 { |
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
113 m_context = context; |
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
114 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
116 symbol_record::context_id current_context (void) const |
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
117 { |
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
118 return m_context; |
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
119 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
121 symbol_record find_symbol (const std::string& name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
123 auto p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 if (p == m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 return insert (name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 else |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
128 return p->second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
131 void inherit_internal |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
132 (const std::shared_ptr<symbol_scope_rep>& donor_scope_rep) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 for (auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 symbol_record& sr = nm_sr.second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 if (! (sr.is_automatic () || sr.is_formal ())) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
140 std::string nm = sr.name (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
141 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
142 if (nm != "__retval__") |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
143 { |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
144 octave_value val = donor_scope_rep->varval (nm); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 if (val.is_defined ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 { |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
148 sr.assign (val, m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
149 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 sr.mark_inherited (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
157 void inherit (const std::shared_ptr<symbol_scope_rep>& donor_scope_rep) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 { |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
159 std::shared_ptr<symbol_scope_rep> dsr = donor_scope_rep; |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
160 |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
161 while (dsr) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 { |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
163 inherit_internal (dsr); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
165 if (dsr->is_nested ()) |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
166 dsr = parent_scope_rep (); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 else |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 break; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
169 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
170 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
172 octave_value |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
173 find (const std::string& name, const octave_value_list& args, |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
174 bool skip_variables, bool local_funcs); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
176 symbol_record& |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 insert (const std::string& name, bool force_add = false); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 void rename (const std::string& old_name, const std::string& new_name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
181 auto p = m_symbols.find (old_name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 if (p != m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
184 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
185 symbol_record sr = p->second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 sr.rename (new_name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 m_symbols.erase (p); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 m_symbols[new_name] = sr; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
193 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
195 void assign (const std::string& name, const octave_value& value, |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 bool force_add) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
198 auto p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
199 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
200 if (p == m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
202 symbol_record& sr = insert (name, force_add); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
203 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
204 sr.assign (value, m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
206 else |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
207 p->second.assign (value, m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 void assign (const std::string& name, |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 const octave_value& value = octave_value ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 assign (name, value, false); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
214 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
215 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 void force_assign (const std::string& name, const octave_value& value) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
218 auto p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
220 if (p == m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
221 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
222 symbol_record& sr = insert (name, true); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
223 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
224 sr.assign (value, m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
225 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
226 else |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
227 p->second.assign (value, m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
228 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
229 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
230 octave_value varval (const std::string& name) const |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
231 { |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
232 table_const_iterator p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
233 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
234 return (p != m_symbols.end () |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
235 ? p->second.varval (m_context) : octave_value ()); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
236 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
237 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
238 bool is_variable (const std::string& name) const |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
239 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
240 bool retval = false; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
241 |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
242 table_const_iterator p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 if (p != m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 const symbol_record& sr = p->second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
247 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
248 retval = sr.is_variable (m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
249 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
250 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
251 return retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
252 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 void push_context (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 for (auto& nm_sr : m_symbols) |
24348
64691264dd21
eliminate some uses of decl_scope in symbol_record class
John W. Eaton <jwe@octave.org>
parents:
24325
diff
changeset
|
257 nm_sr.second.push_context (); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 void pop_context (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
261 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
262 auto tbl_it = m_symbols.begin (); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
263 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
264 while (tbl_it != m_symbols.end ()) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
265 { |
24348
64691264dd21
eliminate some uses of decl_scope in symbol_record class
John W. Eaton <jwe@octave.org>
parents:
24325
diff
changeset
|
266 if (tbl_it->second.pop_context () == 0) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
267 m_symbols.erase (tbl_it++); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
268 else |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
269 tbl_it++; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
270 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
271 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
272 |
24325
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
273 void refresh (void) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
274 { |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
275 for (auto& nm_sr : m_symbols) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
276 { |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
277 symbol_record& sr = nm_sr.second; |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
278 |
25203
72ea868ca63a
allow function parameters to be global (bug #53579)
John W. Eaton <jwe@octave.org>
parents:
25201
diff
changeset
|
279 if (sr.is_global ()) |
72ea868ca63a
allow function parameters to be global (bug #53579)
John W. Eaton <jwe@octave.org>
parents:
25201
diff
changeset
|
280 sr.unbind_global_rep (); |
72ea868ca63a
allow function parameters to be global (bug #53579)
John W. Eaton <jwe@octave.org>
parents:
25201
diff
changeset
|
281 else if (! (sr.is_persistent () || sr.is_forwarded ())) |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
282 sr.clear (m_context); |
24325
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
283 } |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
284 } |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
24324
diff
changeset
|
285 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
286 void clear_variables (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
287 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
288 for (auto& nm_sr : m_symbols) |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
289 nm_sr.second.clear (m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
290 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
291 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
292 void clear_objects (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
293 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
294 for (auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
295 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
296 symbol_record& sr = nm_sr.second; |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
297 octave_value val = sr.varval (m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
298 if (val.isobject ()) |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
299 nm_sr.second.clear (m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
300 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
301 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
302 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
303 void clear_variable (const std::string& name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
304 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25203
diff
changeset
|
305 auto p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
306 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
307 if (p != m_symbols.end ()) |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
308 p->second.clear (m_context); |
24982
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
309 else if (m_is_nested) |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
310 { |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
311 std::shared_ptr<symbol_scope_rep> psr = parent_scope_rep (); |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
312 |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
313 if (psr) |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
314 psr->clear_variable (name); |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
315 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
316 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
317 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
318 void clear_variable_pattern (const std::string& pat) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
319 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
320 glob_match pattern (pat); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
321 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
322 for (auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
323 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
324 symbol_record& sr = nm_sr.second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
325 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
326 if (sr.is_defined (m_context) || sr.is_global ()) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
327 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
328 if (pattern.match (sr.name ())) |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
329 sr.clear (m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
330 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
331 } |
24982
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
332 |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
333 if (m_is_nested) |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
334 { |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
335 std::shared_ptr<symbol_scope_rep> psr = parent_scope_rep (); |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
336 |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
337 if (psr) |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
338 psr->clear_variable_pattern (pat); |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
339 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
340 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
341 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
342 void clear_variable_regexp (const std::string& pat) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
343 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
344 octave::regexp pattern (pat); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
345 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
346 for (auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
347 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
348 symbol_record& sr = nm_sr.second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
349 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
350 if (sr.is_defined (m_context) || sr.is_global ()) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
351 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
352 if (pattern.is_match (sr.name ())) |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
353 sr.clear (m_context); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
354 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
355 } |
24982
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
356 |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
357 if (m_is_nested) |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
358 { |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
359 std::shared_ptr<symbol_scope_rep> psr = parent_scope_rep (); |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
360 |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
361 if (psr) |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
362 psr->clear_variable_regexp (pat); |
c16ad80274c9
improve previous fix for clear in nested scopes (bug #53027)
John W. Eaton <jwe@octave.org>
parents:
24977
diff
changeset
|
363 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
364 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
365 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
366 void mark_automatic (const std::string& name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
367 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
368 insert (name).mark_automatic (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
369 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
370 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
371 void mark_hidden (const std::string& name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
372 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
373 insert (name).mark_hidden (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
374 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
375 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
376 void mark_global (const std::string& name) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
377 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
378 insert (name).mark_global (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
379 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
380 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
381 std::list<symbol_record> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
382 all_variables (bool defined_only = true, |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
383 unsigned int exclude = symbol_record::hidden) const |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
384 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
385 std::list<symbol_record> retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
386 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
387 for (const auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
388 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
389 const symbol_record& sr = nm_sr.second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
390 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
391 if ((defined_only && ! sr.is_defined (m_context)) |
24272
dd810f9d26e7
use m_ prefix for symbol_record class data members
John W. Eaton <jwe@octave.org>
parents:
24269
diff
changeset
|
392 || (sr.storage_class () & exclude)) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
393 continue; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
394 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
395 retval.push_back (sr); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
396 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
397 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
398 return retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
399 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
400 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
401 std::list<symbol_record> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
402 glob (const std::string& pattern, bool vars_only = false) const |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
403 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
404 std::list<symbol_record> retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
405 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
406 glob_match pat (pattern); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
407 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
408 for (const auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
409 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
410 if (pat.match (nm_sr.first)) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
411 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
412 const symbol_record& sr = nm_sr.second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
413 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
414 if (vars_only && ! sr.is_variable (m_context)) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
415 continue; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
416 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
417 retval.push_back (sr); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
418 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
419 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
420 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
421 return retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
422 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
423 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
424 std::list<symbol_record> |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
425 regexp (const std::string& pattern, bool vars_only = false) const |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
426 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
427 std::list<symbol_record> retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
428 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
429 octave::regexp pat (pattern); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
430 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
431 for (const auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
432 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
433 if (pat.is_match (nm_sr.first)) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
434 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
435 const symbol_record& sr = nm_sr.second; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
436 |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
437 if (vars_only && ! sr.is_variable (m_context)) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
438 continue; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
439 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
440 retval.push_back (sr); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
441 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
442 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
443 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
444 return retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
445 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
446 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
447 std::list<std::string> variable_names (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
448 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
449 std::list<std::string> retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
450 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
451 for (const auto& nm_sr : m_symbols) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
452 { |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
453 if (nm_sr.second.is_variable (m_context)) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
454 retval.push_back (nm_sr.first); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
455 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
456 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
457 retval.sort (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
458 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
459 return retval; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
460 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
461 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
462 bool is_local_variable (const std::string& name) const |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
463 { |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
464 table_const_iterator p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
465 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
466 return (p != m_symbols.end () |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
467 && ! p->second.is_global () |
24356
8b14ba8296af
refactor symbol_record object
John W. Eaton <jwe@octave.org>
parents:
24354
diff
changeset
|
468 && p->second.is_defined (m_context)); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
469 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
470 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
471 bool is_global (const std::string& name) const |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
472 { |
25342
416856765a55
be more careful with using auto in place of explicit const iterator decls
John W. Eaton <jwe@octave.org>
parents:
25337
diff
changeset
|
473 table_const_iterator p = m_symbols.find (name); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
474 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
475 return p != m_symbols.end () && p->second.is_global (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
476 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
477 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
478 void install_subfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
479 const octave_value& fval) |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
480 { |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
481 m_subfunctions[name] = fval; |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
482 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
483 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
484 void install_nestfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
485 const octave_value& fval, |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
486 const symbol_scope& fcn_scope) |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
487 { |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
488 m_subfunctions[name] = fval; |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
489 |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
490 m_children.push_back (fcn_scope); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
491 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
492 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
493 octave_value find_subfunction (const std::string& name) const; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
494 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
495 void lock_subfunctions (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
496 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
497 for (auto& nm_sf : m_subfunctions) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
498 nm_sf.second.lock (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
499 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
500 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
501 void unlock_subfunctions (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
502 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
503 for (auto& nm_sf : m_subfunctions) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
504 nm_sf.second.unlock (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
505 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
506 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
507 std::map<std::string, octave_value> subfunctions (void) const |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
508 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
509 return m_subfunctions; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
510 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
511 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
512 void erase_subfunctions (void) |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
513 { |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
514 m_subfunctions.clear (); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
515 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
516 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
517 void mark_subfunctions_in_scope_as_private (const std::string& class_name); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
518 |
24285
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
519 bool has_subfunctions (void) const |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
520 { |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
521 return ! m_subfunction_names.empty (); |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
522 } |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
523 |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
524 void stash_subfunction_names (const std::list<std::string>& names) |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
525 { |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
526 m_subfunction_names = names; |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
527 } |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
528 |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
529 std::list<std::string> subfunction_names (void) const |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
530 { |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
531 return m_subfunction_names; |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
532 } |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
533 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
534 octave_value dump (void) const; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
535 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
536 std::string name (void) const { return m_name; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
537 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
538 void cache_name (const std::string& name) { m_name = name; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
539 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
540 octave_user_function *function (void) { return m_fcn; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
541 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
542 void set_function (octave_user_function *fcn) { m_fcn = fcn; } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
543 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
544 void set_parent (const std::shared_ptr<symbol_scope_rep>& parent); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
545 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
546 void update_nest (void); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
547 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
548 bool look_nonlocal (const std::string& name, symbol_record& result); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
549 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
550 void bind_script_symbols (const std::shared_ptr<symbol_scope_rep>& curr_scope); |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
551 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
552 void unbind_script_symbols (void); |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
553 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
554 octave_value dump_symbols_map (void) const; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
555 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
556 private: |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
557 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
558 //! Name for this scope (usually the corresponding filename of the |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
559 //! function corresponding to the scope). |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
560 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
561 std::string m_name; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
562 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
563 //! Map from symbol names to symbol info. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
564 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
565 std::map<std::string, symbol_record> m_symbols; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
566 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
567 //! Map from symbol names to subfunctions. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
568 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
569 std::map<std::string, octave_value> m_subfunctions; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
570 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
571 //! The list of subfunctions (if any) in the order they appear in |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
572 //! the function file. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
573 |
24285
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
574 std::list<std::string> m_subfunction_names; |
d22d2936f580
store subfunction names in scope instead of function object
John W. Eaton <jwe@octave.org>
parents:
24272
diff
changeset
|
575 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
576 //! The associated user code (may be null). |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
577 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
578 octave_user_function *m_fcn; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
579 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
580 //! Parent of nested function (may be null). |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
581 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
582 std::weak_ptr<symbol_scope_rep> m_parent; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
583 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
584 //! Child nested functions. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
585 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
586 std::vector<symbol_scope> m_children; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
587 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
588 //! If true, then this scope belongs to a nested function. |
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
589 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
590 bool m_is_nested; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
591 |
24940
7edf1fb1d4b2
doc: Add Doxygen documentation.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
24706
diff
changeset
|
592 //! If true then no variables can be added. |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
593 |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
594 bool m_is_static; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
595 |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
596 symbol_record::context_id m_context; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
597 }; |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
598 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
599 class symbol_scope |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
600 { |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
601 public: |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
602 |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
603 // Create a valid but possibly unnamed scope. |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
604 symbol_scope (const std::string& name) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
605 : m_rep (new symbol_scope_rep (name)) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
606 { } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
607 |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
608 // NEW_REP must be dynamically allocated or nullptr. If it is |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
609 // nullptr, the scope is invalid. |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
610 symbol_scope (const std::shared_ptr<symbol_scope_rep> new_rep = nullptr) |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
611 : m_rep (new_rep) |
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
612 { } |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
613 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
614 symbol_scope (const symbol_scope&) = default; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
615 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
616 symbol_scope& operator = (const symbol_scope&) = default; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
617 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
618 ~symbol_scope (void) = default; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
619 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
620 bool is_valid (void) const { return bool (m_rep); } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
621 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
622 explicit operator bool () const { return bool (m_rep); } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
623 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
624 void insert_symbol_record (const symbol_record& sr) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
625 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
626 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
627 m_rep->insert_symbol_record (sr); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
628 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
629 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
630 bool is_nested (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
631 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
632 return m_rep ? m_rep->is_nested () : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
633 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
634 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
635 void mark_nested (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
636 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
637 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
638 m_rep->mark_nested (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
639 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
640 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
641 bool is_static (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
642 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
643 return m_rep ? m_rep->is_static () : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
644 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
645 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
646 void mark_static (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
647 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
648 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
649 m_rep->mark_static (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
650 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
651 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
652 std::shared_ptr<symbol_scope_rep> parent_scope (void) const |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
653 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
654 return m_rep ? m_rep->parent_scope_rep () : nullptr; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
655 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
656 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
657 symbol_scope dup (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
658 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
659 return symbol_scope (m_rep ? m_rep->dup () : nullptr); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
660 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
661 |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
662 void set_context (symbol_record::context_id context) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
663 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
664 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
665 m_rep->set_context (context); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
666 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
667 |
24362
3fc24b792a24
avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24361
diff
changeset
|
668 symbol_record::context_id current_context (void) const |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
669 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
670 return m_rep ? m_rep->current_context () : 0; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
671 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
672 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
673 symbol_record find_symbol (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
674 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
675 return m_rep ? m_rep->find_symbol (name) : symbol_record (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
676 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
677 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
678 void inherit (const symbol_scope& donor_scope) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
679 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
680 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
681 m_rep->inherit (donor_scope.get_rep ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
682 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
683 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
684 octave_value |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
685 find (const std::string& name, const octave_value_list& args, |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
686 bool skip_variables, bool local_funcs) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
687 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
688 return (m_rep |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
689 ? m_rep->find (name, args, skip_variables, local_funcs) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
690 : octave_value ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
691 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
692 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
693 symbol_record& |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
694 insert (const std::string& name, bool force_add = false) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
695 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
696 static symbol_record dummy_symrec; |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
697 return m_rep ? m_rep->insert (name, force_add) : dummy_symrec; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
698 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
699 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
700 void rename (const std::string& old_name, const std::string& new_name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
701 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
702 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
703 m_rep->rename (old_name, new_name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
704 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
705 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
706 void assign (const std::string& name, const octave_value& value, |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
707 bool force_add) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
708 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
709 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
710 m_rep->assign (name, value, force_add); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
711 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
712 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
713 void assign (const std::string& name, |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
714 const octave_value& value = octave_value ()) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
715 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
716 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
717 m_rep->assign (name, value); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
718 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
719 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
720 void force_assign (const std::string& name, const octave_value& value) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
721 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
722 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
723 m_rep->force_assign (name, value); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
724 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
725 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
726 octave_value varval (const std::string& name) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
727 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
728 return m_rep ? m_rep->varval (name) : octave_value (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
729 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
730 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
731 bool is_variable (const std::string& name) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
732 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
733 return m_rep ? m_rep->is_variable (name) : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
734 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
735 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
736 void push_context (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
737 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
738 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
739 m_rep->push_context (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
740 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
741 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
742 void pop_context (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
743 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
744 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
745 m_rep->pop_context (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
746 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
747 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
748 void refresh (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
749 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
750 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
751 m_rep->refresh (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
752 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
753 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
754 void clear_variables (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
755 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
756 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
757 m_rep->clear_variables (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
758 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
759 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
760 void clear_objects (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
761 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
762 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
763 m_rep->clear_objects (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
764 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
765 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
766 void clear_variable (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
767 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
768 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
769 m_rep->clear_variable (name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
770 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
771 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
772 void clear_variable_pattern (const std::string& pat) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
773 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
774 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
775 m_rep->clear_variable_pattern (pat); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
776 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
777 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
778 void clear_variable_regexp (const std::string& pat) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
779 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
780 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
781 m_rep->clear_variable_regexp (pat); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
782 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
783 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
784 void mark_automatic (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
785 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
786 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
787 m_rep->mark_automatic (name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
788 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
789 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
790 void mark_hidden (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
791 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
792 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
793 m_rep->mark_hidden (name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
794 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
795 |
25201
c80323fe4938
improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
796 // This function should only be called for the global |
c80323fe4938
improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
797 // symbol_scope, and that should only happen when it is added to |
c80323fe4938
improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
798 // the global symbol_scope. |
c80323fe4938
improve handling of global symbols (bug #53599)
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
799 |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
800 void mark_global (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
801 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
802 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
803 m_rep->mark_global (name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
804 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
805 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
806 std::list<symbol_record> |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
807 all_variables (bool defined_only = true, |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
808 unsigned int exclude = symbol_record::hidden) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
809 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
810 return (m_rep |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
811 ? m_rep->all_variables (defined_only, exclude) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
812 : std::list<symbol_record> ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
813 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
814 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
815 std::list<symbol_record> |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
816 glob (const std::string& pattern, bool vars_only = false) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
817 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
818 return (m_rep |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
819 ? m_rep->glob (pattern, vars_only) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
820 : std::list<symbol_record> ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
821 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
822 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
823 std::list<symbol_record> |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
824 regexp (const std::string& pattern, bool vars_only = false) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
825 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
826 return (m_rep |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
827 ? m_rep->regexp (pattern, vars_only) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
828 : std::list<symbol_record> ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
829 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
830 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
831 std::list<std::string> variable_names (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
832 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
833 return m_rep ? m_rep->variable_names () : std::list<std::string> (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
834 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
835 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
836 bool is_local_variable (const std::string& name) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
837 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
838 return m_rep ? m_rep->is_local_variable (name) : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
839 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
840 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
841 bool is_global (const std::string& name) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
842 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
843 return m_rep ? m_rep->is_global (name) : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
844 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
845 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
846 void install_subfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
847 const octave_value& fval) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
848 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
849 if (m_rep) |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
850 m_rep->install_subfunction (name, fval); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
851 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
852 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
853 void install_nestfunction (const std::string& name, |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
854 const octave_value& fval, |
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
855 const symbol_scope& fcn_scope) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
856 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
857 if (m_rep) |
24705
8b346a19108e
mark objects as nested or subfunctions when parsing
John W. Eaton <jwe@octave.org>
parents:
24645
diff
changeset
|
858 m_rep->install_nestfunction (name, fval, fcn_scope); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
859 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
860 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
861 octave_value find_subfunction (const std::string& name) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
862 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
863 return m_rep ? m_rep->find_subfunction (name) : octave_value (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
864 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
865 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
866 void lock_subfunctions (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
867 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
868 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
869 m_rep->lock_subfunctions (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
870 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
871 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
872 void unlock_subfunctions (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
873 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
874 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
875 m_rep->unlock_subfunctions (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
876 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
877 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
878 std::map<std::string, octave_value> subfunctions (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
879 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
880 return (m_rep |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
881 ? m_rep->subfunctions () |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
882 : std::map<std::string, octave_value> ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
883 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
884 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
885 void erase_subfunctions (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
886 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
887 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
888 m_rep->erase_subfunctions (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
889 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
890 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
891 void mark_subfunctions_in_scope_as_private (const std::string& class_name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
892 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
893 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
894 m_rep->mark_subfunctions_in_scope_as_private (class_name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
895 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
896 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
897 bool has_subfunctions (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
898 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
899 return m_rep ? m_rep->has_subfunctions () : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
900 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
901 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
902 void stash_subfunction_names (const std::list<std::string>& names) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
903 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
904 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
905 m_rep->stash_subfunction_names (names); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
906 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
907 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
908 std::list<std::string> subfunction_names (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
909 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
910 return m_rep ? m_rep->subfunction_names () : std::list<std::string> (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
911 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
912 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
913 octave_value dump (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
914 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
915 return m_rep ? m_rep->dump () : octave_value (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
916 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
917 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
918 std::string name (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
919 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
920 return m_rep ? m_rep->name () : ""; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
921 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
922 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
923 void cache_name (const std::string& name) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
924 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
925 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
926 m_rep->cache_name (name); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
927 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
928 |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
929 octave_user_function * function (void) |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
930 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
931 return m_rep ? m_rep->function () : nullptr; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
932 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
933 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
934 void set_function (octave_user_function *fcn) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
935 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
936 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
937 m_rep->set_function (fcn); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
938 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
939 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
940 void set_parent (const symbol_scope& p) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
941 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
942 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
943 m_rep->set_parent (p.get_rep ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
944 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
945 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
946 void update_nest (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
947 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
948 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
949 m_rep->update_nest (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
950 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
951 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
952 bool look_nonlocal (const std::string& name, symbol_record& result) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
953 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
954 return m_rep ? m_rep->look_nonlocal (name, result) : false; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
955 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
956 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
957 void bind_script_symbols (const symbol_scope& curr_scope) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
958 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
959 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
960 m_rep->bind_script_symbols (curr_scope.get_rep ()); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
961 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
962 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
963 void unbind_script_symbols (void) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
964 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
965 if (m_rep) |
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
966 m_rep->unbind_script_symbols (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
967 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
968 |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
969 std::shared_ptr<symbol_scope_rep> get_rep (void) const |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
970 { |
24706
30e1d0bf7ade
use weak_ptr for symbol_scope_rep and symbol_record_rep pointers (bug #53092)
John W. Eaton <jwe@octave.org>
parents:
24705
diff
changeset
|
971 return m_rep; |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
972 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
973 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
974 friend bool operator == (const symbol_scope& a, const symbol_scope& b) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
975 { |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
976 return a.m_rep == b.m_rep; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
977 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
978 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
979 friend bool operator != (const symbol_scope& a, const symbol_scope& b) |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
980 { |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
981 return a.m_rep != b.m_rep; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
982 } |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
983 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
984 private: |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
985 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
986 std::shared_ptr<symbol_scope_rep> m_rep; |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
987 |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
988 octave_value dump_symbols_map (void) const |
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
989 { |
24377
ea3458c1d884
improve handling of invalid symbol_scope objects (bug #52607)
John W. Eaton <jwe@octave.org>
parents:
24362
diff
changeset
|
990 return m_rep ? m_rep->dump_symbols_map () : octave_value (); |
24361
8bcfddad15ec
use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents:
24356
diff
changeset
|
991 } |
24263
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
992 }; |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
993 } |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
994 |
3b302b2890d7
disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
995 #endif |