Mercurial > octave
annotate libinterp/parse-tree/pt-unop.h @ 23219:3ac9f9ecfae5 stable
maint: Update copyright dates.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 22 Feb 2017 12:39:29 -0500 |
parents | e9a0469dedd9 |
children | 092078913d54 |
rev | line source |
---|---|
2980 | 1 /* |
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 |
2980 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2980 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
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/>. | |
2980 | 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_unop_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
24 #define octave_pt_unop_h 1 |
2980 | 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 |
2980 | 28 #include <string> |
29 | |
30 class tree_walker; | |
31 | |
32 class octave_value; | |
33 class octave_value_list; | |
34 class octave_lvalue; | |
35 | |
36 #include "pt-exp.h" | |
7336 | 37 #include "symtab.h" |
2980 | 38 |
39 // Unary expressions. | |
40 | |
41 class | |
42 tree_unary_expression : public tree_expression | |
43 { | |
44 public: | |
45 | |
3203 | 46 tree_unary_expression (int l = -1, int c = -1, |
10313 | 47 octave_value::unary_op t |
48 = octave_value::unknown_unary_op) | |
3203 | 49 : tree_expression (l, c), op (0), etype (t) { } |
2980 | 50 |
3203 | 51 tree_unary_expression (tree_expression *e, int l = -1, int c = -1, |
10313 | 52 octave_value::unary_op t |
53 = octave_value::unknown_unary_op) | |
3203 | 54 : tree_expression (l, c), op (e), etype (t) { } |
2980 | 55 |
56 ~tree_unary_expression (void) { delete op; } | |
57 | |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
58 bool is_unary_expression (void) const { return true; } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
59 |
4267 | 60 bool has_magic_end (void) const { return (op && op->has_magic_end ()); } |
61 | |
2980 | 62 tree_expression *operand (void) { return op; } |
63 | |
3523 | 64 std::string oper (void) const; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
65 |
7087 | 66 octave_value::unary_op op_type (void) const { return etype; } |
3203 | 67 |
2980 | 68 protected: |
69 | |
70 // The operand for the expression. | |
71 tree_expression *op; | |
2988 | 72 |
3203 | 73 // The type of the expression. |
74 octave_value::unary_op etype; | |
75 | |
76 private: | |
77 | |
2988 | 78 // No copying! |
79 | |
80 tree_unary_expression (const tree_unary_expression&); | |
81 | |
82 tree_unary_expression& operator = (const tree_unary_expression&); | |
2980 | 83 }; |
84 | |
85 // Prefix expressions. | |
86 | |
87 class | |
88 tree_prefix_expression : public tree_unary_expression | |
89 { | |
90 public: | |
91 | |
92 tree_prefix_expression (int l = -1, int c = -1) | |
3203 | 93 : tree_unary_expression (l, c, octave_value::unknown_unary_op) { } |
2980 | 94 |
3195 | 95 tree_prefix_expression (tree_expression *e, int l = -1, int c = -1, |
10313 | 96 octave_value::unary_op t |
97 = octave_value::unknown_unary_op) | |
3203 | 98 : tree_unary_expression (e, l, c, t) { } |
2980 | 99 |
100 ~tree_prefix_expression (void) { } | |
101 | |
3933 | 102 bool rvalue_ok (void) const { return true; } |
2980 | 103 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
104 octave_value rvalue1 (int nargout = 1); |
2980 | 105 |
3010 | 106 octave_value_list rvalue (int nargout); |
2980 | 107 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
108 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 109 symbol_table::context_id context) const; |
5861 | 110 |
2980 | 111 void accept (tree_walker& tw); |
112 | |
19327
91cd85a75705
Reduce profiling overhead using inlining and templates.
Julien Bect <julien.bect@supelec.fr>
parents:
17822
diff
changeset
|
113 std::string profiler_name (void) const { return "prefix " + oper (); } |
91cd85a75705
Reduce profiling overhead using inlining and templates.
Julien Bect <julien.bect@supelec.fr>
parents:
17822
diff
changeset
|
114 |
2980 | 115 private: |
116 | |
2988 | 117 // No copying! |
118 | |
119 tree_prefix_expression (const tree_prefix_expression&); | |
120 | |
121 tree_prefix_expression& operator = (const tree_prefix_expression&); | |
2980 | 122 }; |
123 | |
124 // Postfix expressions. | |
125 | |
126 class | |
127 tree_postfix_expression : public tree_unary_expression | |
128 { | |
129 public: | |
130 | |
131 tree_postfix_expression (int l = -1, int c = -1) | |
3203 | 132 : tree_unary_expression (l, c, octave_value::unknown_unary_op) { } |
2980 | 133 |
3195 | 134 tree_postfix_expression (tree_expression *e, int l = -1, int c = -1, |
10313 | 135 octave_value::unary_op t |
136 = octave_value::unknown_unary_op) | |
3203 | 137 : tree_unary_expression (e, l, c, t) { } |
2980 | 138 |
139 ~tree_postfix_expression (void) { } | |
140 | |
3933 | 141 bool rvalue_ok (void) const { return true; } |
2980 | 142 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
143 octave_value rvalue1 (int nargout = 1); |
2980 | 144 |
145 octave_value_list rvalue (int nargout); | |
146 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
147 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 148 symbol_table::context_id context) const; |
5861 | 149 |
2980 | 150 void accept (tree_walker& tw); |
151 | |
19327
91cd85a75705
Reduce profiling overhead using inlining and templates.
Julien Bect <julien.bect@supelec.fr>
parents:
17822
diff
changeset
|
152 std::string profiler_name (void) const { return "postfix " + oper (); } |
91cd85a75705
Reduce profiling overhead using inlining and templates.
Julien Bect <julien.bect@supelec.fr>
parents:
17822
diff
changeset
|
153 |
2980 | 154 private: |
155 | |
2988 | 156 // No copying! |
157 | |
158 tree_postfix_expression (const tree_postfix_expression&); | |
159 | |
160 tree_postfix_expression& operator = (const tree_postfix_expression&); | |
2980 | 161 }; |
162 | |
163 #endif |