Mercurial > octave
annotate libinterp/parse-tree/pt-id.h @ 22869:f75d289645ec
make deleted functions public
* octave-gui.h, resource-manager.h, shortcut-manager.h,
base-text-renderer.h, c-file-ptr-stream.h, dynamic-ld.cc,
dynamic-ld.h, event-queue.h, ft-text-renderer.cc, gl-render.cc,
gl-render.h, graphics.cc, graphics.in.h, interpreter.h, mex.cc,
mxarray.in.h, oct-fstrm.h, oct-iostrm.h, oct-prcstrm.h,
oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.h, octave-link.h, pager.h, profiler.h, sighandlers.cc,
symtab.h, text-renderer.h, zfstream.h, __init_fltk__.cc,
ov-builtin.h, ov-dld-fcn.h, ov-fcn.h, ov-mex-fcn.h, ov-typeinfo.h,
ov-usr-fcn.h, octave.h, lex.h, parse.h, pt-arg-list.h,
pt-array-list.h, pt-assign.h, pt-binop.h, pt-bp.h, pt-cell.h,
pt-check.h, pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h,
pt-decl.h, pt-eval.h, pt-except.h, pt-exp.h, pt-fcn-handle.h,
pt-funcall.h, pt-id.h, pt-idx.h, pt-jump.h, pt-loop.h, pt-mat.h,
pt-misc.h, pt-pr-code.h, pt-select.h, pt-stmt.h, pt-unop.h,
pt-walk.h, pt.h, token.h, Array.cc, idx-vector.h, oct-fftw.h,
sparse-chol.cc, sparse-qr.cc, file-ops.h, mach-info.h, oct-env.h,
action-container.h, cmd-edit.cc, cmd-edit.h, cmd-hist.h,
oct-locbuf.h, oct-mutex.h, oct-shlib.cc, oct-sort.h, pathsearch.h,
singleton-cleanup.h, unwind-prot.h, url-transfer.cc, url-transfer.h:
Declare deleted copy constructors and assignment operators public.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Dec 2016 12:40:45 -0500 |
parents | 87e3163f6c87 |
children | 4e3d47dc7e25 |
rev | line source |
---|---|
2887 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21333
diff
changeset
|
3 Copyright (C) 1996-2016 John W. Eaton |
2887 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
2887 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
2887 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2887 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20542
diff
changeset
|
23 #if ! defined (octave_pt_id_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
24 #define octave_pt_id_h 1 |
2887 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
27 |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
28 #include <iosfwd> |
2887 | 29 #include <string> |
30 | |
2943 | 31 class octave_value; |
32 class octave_value_list; | |
2887 | 33 class octave_function; |
34 | |
35 class tree_walker; | |
36 | |
15037
56b8eb7c9c04
improvements in parsing classdef
John W. Eaton <jwe@octave.org>
parents:
14982
diff
changeset
|
37 #include "oct-lvalue.h" |
7677
db02cc0ba8f2
handle breakpoints in tree_identifier::do_lookup
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
38 #include "pt-bp.h" |
2980 | 39 #include "pt-exp.h" |
7336 | 40 #include "symtab.h" |
2887 | 41 |
42 // Symbols from the symbol table. | |
43 | |
44 class | |
2971 | 45 tree_identifier : public tree_expression |
2887 | 46 { |
47 friend class tree_index_expression; | |
48 | |
49 public: | |
50 | |
51 tree_identifier (int l = -1, int c = -1) | |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
52 : tree_expression (l, c) { } |
2887 | 53 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
54 tree_identifier (const symbol_table::symbol_record& s, |
10313 | 55 int l = -1, int c = -1, |
56 symbol_table::scope_id sc = symbol_table::current_scope ()) | |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
57 : tree_expression (l, c), sym (s, sc) { } |
2887 | 58 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
59 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
60 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
61 tree_identifier (const tree_identifier&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
62 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
63 tree_identifier& operator = (const tree_identifier&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
64 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
65 ~tree_identifier (void) = default; |
2887 | 66 |
17355
f0edd6c752e9
don't convert "end" token to "__end__" for indexing
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
67 bool has_magic_end (void) const { return (name () == "end"); } |
4267 | 68 |
3933 | 69 bool is_identifier (void) const { return true; } |
2887 | 70 |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
71 // The name doesn't change with scope, so use sym instead of |
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7677
diff
changeset
|
72 // accessing it through sym so that this function may remain const. |
7336 | 73 std::string name (void) const { return sym.name (); } |
2887 | 74 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
75 bool is_defined (void) { return sym->is_defined (); } |
7336 | 76 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20428
diff
changeset
|
77 virtual bool is_variable (void) const { return sym->is_variable (); } |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
78 |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
79 virtual bool is_black_hole (void) { return false; } |
2887 | 80 |
7336 | 81 // Try to find a definition for an identifier. Here's how: |
82 // | |
83 // * If the identifier is already defined and is a function defined | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
84 // in an function file that has been modified since the last time |
7336 | 85 // we parsed it, parse it again. |
86 // | |
87 // * If the identifier is not defined, try to find a builtin | |
88 // variable or an already compiled function with the same name. | |
89 // | |
90 // * If the identifier is still undefined, try looking for an | |
91 // function file to parse. | |
92 // | |
93 // * On systems that support dynamic linking, we prefer .oct files, | |
94 // then .mex files, then .m files. | |
2971 | 95 |
96 octave_value | |
9445
c5f03874ea2a
simplify symbol_table::find and associated functions
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
97 do_lookup (const octave_value_list& args = octave_value_list ()) |
7336 | 98 { |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
99 return sym->find (args); |
7336 | 100 } |
2887 | 101 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
102 void mark_global (void) { sym->mark_global (); } |
7336 | 103 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
104 void mark_as_static (void) { sym->init_persistent (); } |
7336 | 105 |
14912
3d3c002ccc60
Add symbol_table::symbol_record_ref
Max Brister <max@2bass.com>
parents:
14544
diff
changeset
|
106 void mark_as_formal_parameter (void) { sym->mark_formal (); } |
2887 | 107 |
3010 | 108 // We really need to know whether this symbol referst to a variable |
109 // or a function, but we may not know that yet. | |
110 | |
3933 | 111 bool lvalue_ok (void) const { return true; } |
3010 | 112 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
113 octave_value rvalue1 (int nargout = 1); |
2887 | 114 |
16091
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15236
diff
changeset
|
115 octave_value_list rvalue (int nargout) |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15236
diff
changeset
|
116 { |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15236
diff
changeset
|
117 return rvalue (nargout, 0); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15236
diff
changeset
|
118 } |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15236
diff
changeset
|
119 |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15236
diff
changeset
|
120 octave_value_list rvalue (int nargout, |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15236
diff
changeset
|
121 const std::list<octave_lvalue> *lvalue_list); |
2887 | 122 |
2979 | 123 octave_lvalue lvalue (void); |
2887 | 124 |
125 void eval_undefined_error (void); | |
126 | |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
127 void static_workspace_error (void) |
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
128 { |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
129 error ("can not add variable \"%s\" to a static workspace", |
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
130 name ().c_str ()); |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
131 } |
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
132 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7753
diff
changeset
|
133 tree_identifier *dup (symbol_table::scope_id scope, |
10313 | 134 symbol_table::context_id context) const; |
5861 | 135 |
2887 | 136 void accept (tree_walker& tw); |
137 | |
14930
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
138 symbol_table::symbol_reference symbol (void) const |
14913
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
139 { |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
140 return sym; |
c7071907a641
Use symbol_record_ref instead of names in JIT
Max Brister <max@2bass.com>
parents:
14912
diff
changeset
|
141 } |
2887 | 142 private: |
143 | |
144 // The symbol record that this identifier references. | |
14930
7d44ed216b98
Rename symbol_table::symbol_record_ref to symbol_table::symbol_reference
Max Brister <max@2bass.com>
parents:
14913
diff
changeset
|
145 symbol_table::symbol_reference sym; |
2887 | 146 }; |
147 | |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
148 class tree_black_hole : public tree_identifier |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
149 { |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
150 public: |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
151 |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
152 tree_black_hole (int l = -1, int c = -1) |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
153 : tree_identifier (l, c) { } |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
154 |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
155 std::string name (void) const { return "~"; } |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
156 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20428
diff
changeset
|
157 bool is_variable (void) const { return false; } |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
158 |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
159 bool is_black_hole (void) { return true; } |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
160 |
21333
c4690d9ff566
avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
161 tree_black_hole *dup (symbol_table::scope_id, |
c4690d9ff566
avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
162 symbol_table::context_id) const |
c4690d9ff566
avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
163 { |
c4690d9ff566
avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
164 return new tree_black_hole; |
c4690d9ff566
avoid warnings about overloading virtual functions from a base class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
165 } |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
166 |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
167 octave_lvalue lvalue (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
168 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
169 return octave_lvalue (); // black hole lvalue |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
170 } |
10206
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
171 }; |
37a08e0ce2dc
support Matlab-style empty output/input arguments
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
172 |
2887 | 173 #endif |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
174 |