Mercurial > octave
annotate libinterp/parse-tree/pt-decl.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 |
---|---|
2982 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
3 Copyright (C) 1996-2016 John W. Eaton |
2982 | 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. |
2982 | 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. |
2982 | 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/>. | |
2982 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_pt_decl_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_decl_h 1 |
2982 | 25 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21055
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21055
diff
changeset
|
27 |
2982 | 28 class tree_expression; |
29 class tree_identifier; | |
30 | |
31 class tree_walker; | |
32 | |
33 #include <string> | |
34 | |
4219 | 35 #include "base-list.h" |
6215 | 36 #include "oct-lvalue.h" |
2982 | 37 #include "pt-cmd.h" |
6215 | 38 #include "pt-id.h" |
7336 | 39 #include "symtab.h" |
2982 | 40 |
41 // List of expressions that make up a declaration statement. | |
42 | |
43 class | |
44 tree_decl_elt | |
45 { | |
46 public: | |
47 | |
48 tree_decl_elt (tree_identifier *i = 0, tree_expression *e = 0) | |
49 : id (i), expr (e) { } | |
50 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
51 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
52 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
53 tree_decl_elt (const tree_decl_elt&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
54 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
55 tree_decl_elt& operator = (const tree_decl_elt&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
56 |
2982 | 57 ~tree_decl_elt (void); |
58 | |
6215 | 59 bool eval (void); |
60 | |
61 bool is_defined (void) { return id ? id->is_defined () : false; } | |
62 | |
7336 | 63 bool is_variable (void) { return id ? id->is_variable () : false; } |
64 | |
6215 | 65 void mark_as_formal_parameter (void) |
66 { | |
67 if (id) | |
68 id->mark_as_formal_parameter (); | |
69 } | |
70 | |
71 bool lvalue_ok (void) { return id ? id->lvalue_ok () : false; } | |
72 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
73 // Do not allow functions to return null values. |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
74 octave_value rvalue1 (int nargout = 1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
75 { |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
76 return id ? id->rvalue1 (nargout).storable_value () : octave_value (); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
77 } |
6215 | 78 |
79 octave_value_list rvalue (int nargout) | |
80 { | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
81 octave_value_list retval; |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
82 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
83 if (nargout > 1) |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
84 error ("invalid number of output arguments in declaration list"); |
21055
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
85 |
5e00ed38a58b
maint: Replace if/error/else paradigm with just if/error.
Rik <rik@octave.org>
parents:
20791
diff
changeset
|
86 retval = rvalue1 (nargout); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
87 |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
88 return retval; |
6215 | 89 } |
90 | |
91 octave_lvalue lvalue (void) { return id ? id->lvalue () : octave_lvalue (); } | |
2982 | 92 |
93 tree_identifier *ident (void) { return id; } | |
94 | |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
95 std::string name (void) { return id ? id->name () : ""; } |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
96 |
2982 | 97 tree_expression *expression (void) { return expr; } |
98 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
99 tree_decl_elt *dup (symbol_table::scope_id scope, |
10313 | 100 symbol_table::context_id context) const; |
5861 | 101 |
2982 | 102 void accept (tree_walker& tw); |
103 | |
104 private: | |
105 | |
106 // An identifier to tag with the declared property. | |
107 tree_identifier *id; | |
108 | |
109 // An initializer expression (may be zero); | |
110 tree_expression *expr; | |
111 }; | |
112 | |
113 class | |
22333
2758af148ced
move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
114 tree_decl_init_list : public octave::base_list<tree_decl_elt *> |
2982 | 115 { |
116 public: | |
117 | |
4219 | 118 tree_decl_init_list (void) { } |
2982 | 119 |
4219 | 120 tree_decl_init_list (tree_decl_elt *t) { append (t); } |
2982 | 121 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
122 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
123 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
124 tree_decl_init_list (const tree_decl_init_list&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
125 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
126 tree_decl_init_list& operator = (const tree_decl_init_list&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
127 |
2982 | 128 ~tree_decl_init_list (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
130 while (! empty ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
131 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 iterator p = begin (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 delete *p; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 erase (p); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 } |
2982 | 137 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
138 tree_decl_init_list *dup (symbol_table::scope_id scope, |
10313 | 139 symbol_table::context_id context) const; |
5861 | 140 |
2982 | 141 void accept (tree_walker& tw); |
142 }; | |
143 | |
144 // Base class for declaration commands -- global, static, etc. | |
145 | |
146 class | |
147 tree_decl_command : public tree_command | |
148 { | |
149 public: | |
150 | |
3523 | 151 tree_decl_command (const std::string& n, int l = -1, int c = -1) |
7336 | 152 : tree_command (l, c), cmd_name (n), init_list (0) { } |
2982 | 153 |
3523 | 154 tree_decl_command (const std::string& n, tree_decl_init_list *t, |
10313 | 155 int l = -1, int c = -1) |
7336 | 156 : tree_command (l, c), cmd_name (n), init_list (t) { } |
2982 | 157 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
158 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
159 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
160 tree_decl_command (const tree_decl_command&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
161 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
162 tree_decl_command& operator = (const tree_decl_command&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
163 |
2982 | 164 ~tree_decl_command (void); |
165 | |
166 tree_decl_init_list *initializer_list (void) { return init_list; } | |
167 | |
3523 | 168 std::string name (void) { return cmd_name; } |
2982 | 169 |
170 protected: | |
171 | |
172 // The name of this command -- global, static, etc. | |
3523 | 173 std::string cmd_name; |
2982 | 174 |
175 // The list of variables or initializers in this declaration command. | |
176 tree_decl_init_list *init_list; | |
177 }; | |
178 | |
179 // Global. | |
180 | |
181 class | |
182 tree_global_command : public tree_decl_command | |
183 { | |
184 public: | |
185 | |
186 tree_global_command (int l = -1, int c = -1) | |
187 : tree_decl_command ("global", l, c) { } | |
188 | |
189 tree_global_command (tree_decl_init_list *t, int l = -1, int c = -1) | |
190 : tree_decl_command ("global", t, l, c) { } | |
191 | |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
192 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
193 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
194 tree_global_command (const tree_global_command&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
195 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
196 tree_global_command& operator = (const tree_global_command&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
197 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
198 ~tree_global_command (void) = default; |
2982 | 199 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
200 tree_command *dup (symbol_table::scope_id scope, |
10313 | 201 symbol_table::context_id context) const; |
5861 | 202 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
203 void accept (tree_walker& tw); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
204 |
2988 | 205 private: |
206 | |
2989 | 207 static void do_init (tree_decl_elt& elt); |
2982 | 208 }; |
209 | |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
210 // Persistent. |
2982 | 211 |
212 class | |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
213 tree_persistent_command : public tree_decl_command |
2982 | 214 { |
215 public: | |
216 | |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
217 tree_persistent_command (int l = -1, int c = -1) |
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
218 : tree_decl_command ("persistent", l, c) { } |
2982 | 219 |
14294
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
220 tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1) |
9e3983c8963c
deprecate the static keyword
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
221 : tree_decl_command ("persistent", t, l, c) { } |
2982 | 222 |
22869
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
223 // No copying! |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
224 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
225 tree_persistent_command (const tree_persistent_command&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
226 |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
227 tree_persistent_command& operator = (const tree_persistent_command&) = delete; |
f75d289645ec
make deleted functions public
John W. Eaton <jwe@octave.org>
parents:
22868
diff
changeset
|
228 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22865
diff
changeset
|
229 ~tree_persistent_command (void) = default; |
2982 | 230 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
231 tree_command *dup (symbol_table::scope_id scope, |
10313 | 232 symbol_table::context_id context) const; |
5861 | 233 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
234 void accept (tree_walker& tw); |
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8523
diff
changeset
|
235 |
2988 | 236 private: |
237 | |
2989 | 238 static void do_init (tree_decl_elt& elt); |
2982 | 239 }; |
240 | |
241 #endif | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22333
diff
changeset
|
242 |