annotate libinterp/parse-tree/pt-decl.h @ 23457:21baad6b35c4

maint: Use C++11 nullptr rather than 0 or NULL when possible. * FigureWindow.h, Logger.cc, Menu.cc, MouseModeActionGroup.h, Object.h, ObjectFactory.cc, ObjectProxy.h, color-picker.h, documentation-dock-widget.h, files-dock-widget.h, find-files-dialog.h, history-dock-widget.h, file-editor-tab.cc, file-editor.cc, file-editor.h, find-dialog.h, main-window.cc, main-window.h, octave-dock-widget.h, parser.cc, parser.h, webinfo.h, resource-manager.cc, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.h, workspace-view.h, __magick_read__.cc, call-stack.cc, call-stack.h, cdisplay.c, display.cc, dlmread.cc, dynamic-ld.cc, ft-text-renderer.cc, gl2ps-print.cc, graphics.cc, graphics.in.h, input.h, interpreter.cc, interpreter.h, ls-hdf5.cc, mex.cc, mxarray.in.h, oct-errno.in.cc, oct-fstrm.cc, oct-iostrm.h, oct-procbuf.cc, oct-stdstrm.h, oct-stream.cc, oct-stream.h, octave-link.cc, pager.cc, pr-output.cc, profiler.h, qz.cc, sighandlers.cc, strfns.cc, symtab.cc, symtab.h, typecast.cc, urlwrite.cc, variables.cc, __eigs__.cc, __init_fltk__.cc, __ode15__.cc, colamd.cc, ov-base-int.cc, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-builtin.cc, ov-class.cc, ov-classdef.cc, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-str-mat.cc, ov-struct.cc, ov-usr-fcn.h, octave.cc, octave.h, bp-table.cc, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, lex.h, pt-arg-list.cc, pt-arg-list.h, pt-array-list.h, pt-cell.h, pt-classdef.h, pt-colon.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.h, pt-idx.h, pt-jit.cc, pt-jit.h, pt-loop.h, pt-mat.h, pt-select.h, pt.h, CSparse.cc, dSparse.cc, DASPK.cc, DASRT.cc, DASSL.cc, oct-fftw.cc, oct-rand.cc, oct-spparms.cc, child-list.cc, file-ops.cc, mach-info.cc, oct-env.cc, oct-time.cc, cmd-edit.cc, cmd-hist.cc, oct-locbuf.cc, oct-shlib.cc, pathsearch.cc, singleton-cleanup.cc, unwind-prot.h, url-transfer.cc: Use C++11 nullptr rather than 0 or NULL when possible.
author Rik <rik@octave.org>
date Fri, 28 Apr 2017 13:19:12 -0700
parents cd4e1ee28716
children 2699c5974844
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
1 /*
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1996-2017 John W. Eaton
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
4
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
6
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
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
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
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
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
16
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6215
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6215
diff changeset
19 <http://www.gnu.org/licenses/>.
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
20
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
21 */
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
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
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
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
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
28 #include <string>
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
29
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4212
diff changeset
30 #include "base-list.h"
6215
516d3071b34c [project @ 2006-12-15 03:24:12 by jwe]
jwe
parents: 5861
diff changeset
31 #include "oct-lvalue.h"
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
32 #include "pt-cmd.h"
6215
516d3071b34c [project @ 2006-12-15 03:24:12 by jwe]
jwe
parents: 5861
diff changeset
33 #include "pt-id.h"
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
34 #include "pt-walk.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
35 #include "symtab.h"
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
36
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
37 namespace octave
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
38 {
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
39 class tree_evaluator;
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
40 class tree_expression;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
41 class tree_identifier;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
42
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
43 // List of expressions that make up a declaration statement.
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
44
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
45 class tree_decl_elt
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
46 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
47 public:
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
48
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23446
diff changeset
49 tree_decl_elt (tree_identifier *i = nullptr, tree_expression *e = nullptr)
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
50 : id (i), expr (e) { }
6215
516d3071b34c [project @ 2006-12-15 03:24:12 by jwe]
jwe
parents: 5861
diff changeset
51
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
52 // No copying!
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7017
diff changeset
53
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
54 tree_decl_elt (const tree_decl_elt&) = delete;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
55
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
56 tree_decl_elt& operator = (const tree_decl_elt&) = delete;
6215
516d3071b34c [project @ 2006-12-15 03:24:12 by jwe]
jwe
parents: 5861
diff changeset
57
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
58 ~tree_decl_elt (void);
6215
516d3071b34c [project @ 2006-12-15 03:24:12 by jwe]
jwe
parents: 5861
diff changeset
59
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
60 bool is_defined (void) { return id ? id->is_defined () : false; }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
61
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
62 bool is_variable (void) { return id ? id->is_variable () : false; }
6215
516d3071b34c [project @ 2006-12-15 03:24:12 by jwe]
jwe
parents: 5861
diff changeset
63
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
64 void mark_as_formal_parameter (void)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
65 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
66 if (id)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
67 id->mark_as_formal_parameter ();
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
68 }
6215
516d3071b34c [project @ 2006-12-15 03:24:12 by jwe]
jwe
parents: 5861
diff changeset
69
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
70 bool lvalue_ok (void) { return id ? id->lvalue_ok () : false; }
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8523
diff changeset
71
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
72 octave_lvalue lvalue (tree_evaluator *tw)
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
73 {
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
74 return id ? id->lvalue (tw) : octave_lvalue ();
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
75 }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
76
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
77 tree_identifier * ident (void) { return id; }
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5307
diff changeset
78
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
79 std::string name (void) { return id ? id->name () : ""; }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
80
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
81 tree_expression * expression (void) { return expr; }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
82
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
83 tree_decl_elt * dup (symbol_table::scope_id scope,
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
84 symbol_table::context_id context) const;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
85
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
86 void accept (tree_walker& tw)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
87 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
88 tw.visit_decl_elt (*this);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
89 }
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
90
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
91 private:
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
92
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
93 // An identifier to tag with the declared property.
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
94 tree_identifier *id;
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
95
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
96 // An initializer expression (may be zero);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
97 tree_expression *expr;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
98 };
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
99
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
100 class tree_decl_init_list : public octave::base_list<tree_decl_elt *>
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
101 {
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
102 public:
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
103
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
104 tree_decl_init_list (void) { }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
105
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
106 tree_decl_init_list (tree_decl_elt *t) { append (t); }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
107
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
108 // No copying!
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
109
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
110 tree_decl_init_list (const tree_decl_init_list&) = delete;
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
111
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
112 tree_decl_init_list& operator = (const tree_decl_init_list&) = delete;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
113
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
114 ~tree_decl_init_list (void)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
115 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
116 while (! empty ())
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
117 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
118 iterator p = begin ();
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
119 delete *p;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
120 erase (p);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
121 }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
122 }
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
123
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
124 tree_decl_init_list * dup (symbol_table::scope_id scope,
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
125 symbol_table::context_id context) const;
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
126
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
127 void accept (tree_walker& tw)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
128 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
129 tw.visit_decl_init_list (*this);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
130 }
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
131 };
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
132
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
133 // Base class for declaration commands -- global, static, etc.
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
134
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
135 class tree_decl_command : public tree_command
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
136 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
137 public:
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
138
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
139 tree_decl_command (const std::string& n, int l = -1, int c = -1)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
140 : tree_command (l, c), cmd_name (n), init_list (0) { }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
141
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
142 tree_decl_command (const std::string& n, tree_decl_init_list *t,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
143 int l = -1, int c = -1)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
144 : tree_command (l, c), cmd_name (n), init_list (t) { }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
145
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
146 // No copying!
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
147
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
148 tree_decl_command (const tree_decl_command&) = delete;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
149
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
150 tree_decl_command& operator = (const tree_decl_command&) = delete;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
151
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
152 ~tree_decl_command (void);
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
153
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
154 tree_decl_init_list * initializer_list (void) { return init_list; }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
155
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
156 std::string name (void) { return cmd_name; }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
157
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
158 protected:
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
159
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
160 // The name of this command -- global, static, etc.
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
161 std::string cmd_name;
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
162
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
163 // The list of variables or initializers in this declaration command.
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
164 tree_decl_init_list *init_list;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
165 };
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
166
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
167 // Global.
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
168
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
169 class tree_global_command : public tree_decl_command
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
170 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
171 public:
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
172
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
173 tree_global_command (int l = -1, int c = -1)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
174 : tree_decl_command ("global", l, c) { }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
175
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
176 tree_global_command (tree_decl_init_list *t, int l = -1, int c = -1)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
177 : tree_decl_command ("global", t, l, c) { }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
178
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
179 // No copying!
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
180
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
181 tree_global_command (const tree_global_command&) = delete;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
182
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
183 tree_global_command& operator = (const tree_global_command&) = delete;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
184
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
185 ~tree_global_command (void) = default;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
186
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
187 tree_command * dup (symbol_table::scope_id scope,
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
188 symbol_table::context_id context) const;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
189
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
190 void accept (tree_walker& tw)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
191 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
192 tw.visit_global_command (*this);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
193 }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
194
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
195 private:
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5307
diff changeset
196
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
197 static void do_init (tree_decl_elt& elt);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
198 };
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
199
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
200 // Persistent.
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8523
diff changeset
201
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
202 class tree_persistent_command : public tree_decl_command
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
203 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
204 public:
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
205
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
206 tree_persistent_command (int l = -1, int c = -1)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
207 : tree_decl_command ("persistent", l, c) { }
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
208
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
209 tree_persistent_command (tree_decl_init_list *t, int l = -1, int c = -1)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
210 : tree_decl_command ("persistent", t, l, c) { }
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
211
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
212 // No copying!
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
213
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
214 tree_persistent_command (const tree_persistent_command&) = delete;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
215
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
216 tree_persistent_command& operator = (const tree_persistent_command&) = delete;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
217
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
218 ~tree_persistent_command (void) = default;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
219
23446
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
220 tree_command * dup (symbol_table::scope_id scope,
cd4e1ee28716 maint: Use convention 'void * fcn ()' for functions which return pointers.
Rik <rik@octave.org>
parents: 23435
diff changeset
221 symbol_table::context_id context) const;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
222
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
223 void accept (tree_walker& tw)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
224 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
225 tw.visit_persistent_command (*this);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
226 }
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
227
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
228 private:
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
229
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
230 static void do_init (tree_decl_elt& elt);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
231 };
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
232 }
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
233
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
234 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5307
diff changeset
235
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
236 OCTAVE_DEPRECATED ("use 'octave::tree_decl_elt' instead")
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
237 typedef octave::tree_decl_elt tree_decl_elt;
8658
73c4516fae10 New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents: 8523
diff changeset
238
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
239 // tree_decl_init_list is derived from a template.
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
240
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
241 OCTAVE_DEPRECATED ("use 'octave::tree_decl_command' instead")
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
242 typedef octave::tree_decl_command tree_decl_command;
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
243
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
244 OCTAVE_DEPRECATED ("use 'octave::tree_global_command' instead")
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
245 typedef octave::tree_global_command tree_global_command;
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2982
diff changeset
246
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
247 OCTAVE_DEPRECATED ("use 'octave::tree_persistent_command' instead")
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
248 typedef octave::tree_persistent_command tree_persistent_command;
2982
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
249
20f5cec4f11c [project @ 1997-05-16 03:29:26 by jwe]
jwe
parents:
diff changeset
250 #endif
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22333
diff changeset
251
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
252 #endif