annotate libinterp/parse-tree/pt-binop.h @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents 2219b0ed8754
children 91c6288781ba 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 28805
diff changeset
3 // Copyright (C) 1996-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_pt_binop_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17787
diff changeset
27 #define octave_pt_binop_h 1
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
30
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
31 #include <string>
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
32
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
33 class octave_value;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
34 class octave_value_list;
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
35
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
36 #include "ov.h"
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
37 #include "pt-exp.h"
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
38 #include "pt-walk.h"
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
39
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
40 namespace octave
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
41 {
24362
3fc24b792a24 avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24270
diff changeset
42 class symbol_scope;
3fc24b792a24 avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24270
diff changeset
43
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
44 // Binary expressions.
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
45
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
46 class tree_binary_expression : public tree_expression
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
47 {
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
48 public:
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
49
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
50 tree_binary_expression (int l = -1, int c = -1,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
51 octave_value::binary_op t
10313
f3b65e1ae355 untabify src header files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
52 = octave_value::unknown_binary_op)
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
53 : tree_expression (l, c), m_lhs (nullptr), m_rhs (nullptr), m_etype (t),
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
54 m_eligible_for_braindead_shortcircuit (false),
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
55 m_braindead_shortcircuit_warning_issued (false) { }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
56
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
57 tree_binary_expression (tree_expression *a, tree_expression *b,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
58 int l = -1, int c = -1,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
59 octave_value::binary_op t
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
60 = octave_value::unknown_binary_op)
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
61 : tree_expression (l, c), m_lhs (a), m_rhs (b), m_etype (t),
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
62 m_eligible_for_braindead_shortcircuit (false),
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
63 m_braindead_shortcircuit_warning_issued (false) { }
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22868
diff changeset
64
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
65 // No copying!
11091
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
66
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
67 tree_binary_expression (const tree_binary_expression&) = delete;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
68
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
69 tree_binary_expression& operator = (const tree_binary_expression&) = delete;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
70
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
71 ~tree_binary_expression (void)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
72 {
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
73 delete m_lhs;
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
74 delete m_rhs;
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
75 }
11091
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
76
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
77 void mark_braindead_shortcircuit (void)
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
78 {
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
79 if (m_etype == octave_value::op_el_and || m_etype == octave_value::op_el_or)
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
80 {
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
81 m_eligible_for_braindead_shortcircuit = true;
4267
7cd865a8c815 [project @ 2003-01-03 15:27:05 by jwe]
jwe
parents: 4192
diff changeset
82
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
83 m_lhs->mark_braindead_shortcircuit ();
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
84 m_rhs->mark_braindead_shortcircuit ();
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
85 }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
86 }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
87
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
88 bool is_binary_expression (void) const { return true; }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
89
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
90 bool rvalue_ok (void) const { return true; }
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5307
diff changeset
91
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
92 std::string oper (void) const;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
93
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
94 octave_value::binary_op op_type (void) const { return m_etype; }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
95
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
96 tree_expression * lhs (void) { return m_lhs; }
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
97 tree_expression * rhs (void) { return m_rhs; }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
98
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
99 bool is_eligible_for_braindead_shortcircuit (void) const
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
100 {
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
101 return m_eligible_for_braindead_shortcircuit;
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
102 }
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
103
24270
bc3819b7cca1 don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
104 tree_expression * dup (symbol_scope& scope) const;
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2980
diff changeset
105
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
106 octave_value evaluate (tree_evaluator&, int nargout = 1);
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
107
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
108 octave_value_list evaluate_n (tree_evaluator& tw, int nargout = 1)
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
109 {
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
110 return ovl (evaluate (tw, nargout));
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
111 }
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
112
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
113 void accept (tree_walker& tw)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
114 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
115 tw.visit_binary_expression (*this);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
116 }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
117
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
118 std::string profiler_name (void) const { return "binary " + oper (); }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
119
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
120 void matlab_style_short_circuit_warning (const char *op);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
121
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
122 protected:
11091
5677f3f7b5fa Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
123
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
124 // The operands for the expression.
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
125 tree_expression *m_lhs;
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
126 tree_expression *m_rhs;
18127
d76f790b4eec enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents: 17822
diff changeset
127
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
128 private:
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2980
diff changeset
129
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
130 // The type of the expression.
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
131 octave_value::binary_op m_etype;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
132
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
133 // TRUE if this is an | or & expression in the condition of an IF
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
134 // or WHILE statement.
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
135 bool m_eligible_for_braindead_shortcircuit;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
136
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
137 // TRUE if we have already issued a warning about short circuiting
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
138 // for this operator.
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
139 bool m_braindead_shortcircuit_warning_issued;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
140 };
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
141
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
142 // Boolean expressions.
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
143
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
144 class tree_boolean_expression : public tree_binary_expression
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
145 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
146 public:
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 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 enum type
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
149 {
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
150 unknown,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
151 bool_and,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
152 bool_or
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
153 };
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
154
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
155 tree_boolean_expression (int l = -1, int c = -1, type t = unknown)
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
156 : tree_binary_expression (l, c), m_etype (t) { }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 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 tree_boolean_expression (tree_expression *a, tree_expression *b,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
159 int l = -1, int c = -1, type t = unknown)
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
160 : tree_binary_expression (a, b, l, c), m_etype (t) { }
4023
ef3caf27cb9c [project @ 2002-08-07 06:54:41 by jwe]
jwe
parents: 3933
diff changeset
161
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
162 // No copying!
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
163
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
164 tree_boolean_expression (const tree_boolean_expression&) = delete;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
165
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
166 tree_boolean_expression& operator = (const tree_boolean_expression&) = delete;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
167
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
168 ~tree_boolean_expression (void) = default;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
169
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
170 bool is_boolean_expression (void) const { return true; }
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
171
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
172 bool rvalue_ok (void) const { return true; }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
173
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
174 std::string oper (void) const;
5861
2a6cb4ed8f1e [project @ 2006-06-16 05:09:41 by jwe]
jwe
parents: 5307
diff changeset
175
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
176 type op_type (void) const { return m_etype; }
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
177
24270
bc3819b7cca1 don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
178 tree_expression * dup (symbol_scope& scope) const;
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
179
27371
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
180 octave_value evaluate (tree_evaluator&, int nargout = 1);
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
181
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
182 octave_value_list evaluate_n (tree_evaluator& tw, int nargout = 1)
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
183 {
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
184 return ovl (evaluate (tw, nargout));
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
185 }
fcaecdbc8d8a don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents: 26377
diff changeset
186
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
187 void accept (tree_walker& tw)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
188 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
189 tw.visit_boolean_expression (*this);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
190 }
23424
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
191
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
192 private:
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2980
diff changeset
193
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
194 // The type of the expression.
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
195 type m_etype;
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
196 };
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22869
diff changeset
197 }
2988
daa1ed1f5462 [project @ 1997-05-16 07:23:15 by jwe]
jwe
parents: 2980
diff changeset
198
2980
cd5ad3fd8049 [project @ 1997-05-16 01:12:13 by jwe]
jwe
parents:
diff changeset
199 #endif