Mercurial > hg > octave-nkf
annotate src/pt-binop.h @ 10843:229675bb7647 ss-3-3-52
version is now 3.3.52
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 01 Aug 2010 11:49:45 -0400 |
parents | f3b65e1ae355 |
children | 5677f3f7b5fa |
rev | line source |
---|---|
2980 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004, 2005, 2006, 2007, |
4 2008, 2009 John W. Eaton | |
2980 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2980 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2980 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_binop_h) | |
25 #define octave_tree_binop_h 1 | |
26 | |
27 #include <string> | |
28 | |
29 class tree_walker; | |
30 | |
31 class octave_value; | |
32 class octave_value_list; | |
33 class octave_lvalue; | |
34 | |
35 #include "ov.h" | |
36 #include "pt-exp.h" | |
7336 | 37 #include "symtab.h" |
2980 | 38 |
39 // Binary expressions. | |
40 | |
41 class | |
42 tree_binary_expression : public tree_expression | |
43 { | |
44 public: | |
45 | |
46 tree_binary_expression (int l = -1, int c = -1, | |
10313 | 47 octave_value::binary_op t |
48 = octave_value::unknown_binary_op) | |
2980 | 49 : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t) { } |
50 | |
51 tree_binary_expression (tree_expression *a, tree_expression *b, | |
10313 | 52 int l = -1, int c = -1, |
53 octave_value::binary_op t | |
54 = octave_value::unknown_binary_op) | |
2980 | 55 : tree_expression (l, c), op_lhs (a), op_rhs (b), etype (t) { } |
56 | |
57 ~tree_binary_expression (void) | |
58 { | |
59 delete op_lhs; | |
60 delete op_rhs; | |
61 } | |
62 | |
4267 | 63 bool has_magic_end (void) const |
64 { | |
65 return ((op_lhs && op_lhs->has_magic_end ()) | |
10313 | 66 || (op_rhs && op_rhs->has_magic_end ())); |
4267 | 67 } |
68 | |
4023 | 69 bool is_binary_expression (void) const { return true; } |
70 | |
3933 | 71 bool rvalue_ok (void) const { return true; } |
2980 | 72 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
73 octave_value rvalue1 (int nargout = 1); |
2980 | 74 |
3010 | 75 octave_value_list rvalue (int nargout); |
2980 | 76 |
3523 | 77 std::string oper (void) const; |
2980 | 78 |
4023 | 79 octave_value::binary_op op_type (void) const { return etype; } |
80 | |
2980 | 81 tree_expression *lhs (void) { return op_lhs; } |
82 tree_expression *rhs (void) { return op_rhs; } | |
83 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
84 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 85 symbol_table::context_id context) const; |
5861 | 86 |
2980 | 87 void accept (tree_walker& tw); |
88 | |
89 protected: | |
90 | |
91 // The operands for the expression. | |
92 tree_expression *op_lhs; | |
93 tree_expression *op_rhs; | |
94 | |
95 private: | |
96 | |
97 // The type of the expression. | |
98 octave_value::binary_op etype; | |
2988 | 99 |
100 // No copying! | |
101 | |
102 tree_binary_expression (const tree_binary_expression&); | |
103 | |
104 tree_binary_expression& operator = (const tree_binary_expression&); | |
2980 | 105 }; |
106 | |
107 // Boolean expressions. | |
108 | |
109 class | |
110 tree_boolean_expression : public tree_binary_expression | |
111 { | |
112 public: | |
113 | |
114 enum type | |
115 { | |
116 unknown, | |
117 bool_and, | |
118 bool_or | |
119 }; | |
120 | |
121 tree_boolean_expression (int l = -1, int c = -1, type t = unknown) | |
122 : tree_binary_expression (l, c), etype (t) { } | |
123 | |
124 tree_boolean_expression (tree_expression *a, tree_expression *b, | |
10313 | 125 int l = -1, int c = -1, type t = unknown) |
2980 | 126 : tree_binary_expression (a, b, l, c), etype (t) { } |
127 | |
128 ~tree_boolean_expression (void) { } | |
129 | |
4023 | 130 bool is_boolean_expression (void) const { return true; } |
131 | |
3933 | 132 bool rvalue_ok (void) const { return true; } |
2980 | 133 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
134 octave_value rvalue1 (int nargout = 1); |
2980 | 135 |
136 octave_value_list rvalue (int nargout); | |
137 | |
3523 | 138 std::string oper (void) const; |
2980 | 139 |
4023 | 140 type op_type (void) const { return etype; } |
141 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
142 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 143 symbol_table::context_id context) const; |
5861 | 144 |
2980 | 145 private: |
146 | |
147 // The type of the expression. | |
148 type etype; | |
2988 | 149 |
150 // No copying! | |
151 | |
152 tree_boolean_expression (const tree_boolean_expression&); | |
153 | |
154 tree_boolean_expression& operator = (const tree_boolean_expression&); | |
2980 | 155 }; |
156 | |
157 #endif |