2980
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004, 2005, 2006, 2007 |
|
4 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, |
|
47 octave_value::binary_op t |
|
48 = octave_value::unknown_binary_op) |
|
49 : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t) { } |
|
50 |
|
51 tree_binary_expression (tree_expression *a, tree_expression *b, |
|
52 int l = -1, int c = -1, |
|
53 octave_value::binary_op t |
|
54 = octave_value::unknown_binary_op) |
|
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 ()) |
|
66 || (op_rhs && op_rhs->has_magic_end ())); |
|
67 } |
|
68 |
4023
|
69 bool is_binary_expression (void) const { return true; } |
|
70 |
3933
|
71 bool rvalue_ok (void) const { return true; } |
2980
|
72 |
|
73 octave_value rvalue (void); |
|
74 |
3010
|
75 octave_value_list rvalue (int nargout); |
2980
|
76 |
|
77 void eval_error (void); |
|
78 |
3523
|
79 std::string oper (void) const; |
2980
|
80 |
4023
|
81 octave_value::binary_op op_type (void) const { return etype; } |
|
82 |
2980
|
83 tree_expression *lhs (void) { return op_lhs; } |
|
84 tree_expression *rhs (void) { return op_rhs; } |
|
85 |
7336
|
86 tree_expression *dup (symbol_table::scope_id scope); |
5861
|
87 |
2980
|
88 void accept (tree_walker& tw); |
|
89 |
|
90 protected: |
|
91 |
|
92 // The operands for the expression. |
|
93 tree_expression *op_lhs; |
|
94 tree_expression *op_rhs; |
|
95 |
|
96 private: |
|
97 |
|
98 // The type of the expression. |
|
99 octave_value::binary_op etype; |
2988
|
100 |
|
101 // No copying! |
|
102 |
|
103 tree_binary_expression (const tree_binary_expression&); |
|
104 |
|
105 tree_binary_expression& operator = (const tree_binary_expression&); |
2980
|
106 }; |
|
107 |
|
108 // Boolean expressions. |
|
109 |
|
110 class |
|
111 tree_boolean_expression : public tree_binary_expression |
|
112 { |
|
113 public: |
|
114 |
|
115 enum type |
|
116 { |
|
117 unknown, |
|
118 bool_and, |
|
119 bool_or |
|
120 }; |
|
121 |
|
122 tree_boolean_expression (int l = -1, int c = -1, type t = unknown) |
|
123 : tree_binary_expression (l, c), etype (t) { } |
|
124 |
|
125 tree_boolean_expression (tree_expression *a, tree_expression *b, |
|
126 int l = -1, int c = -1, type t = unknown) |
|
127 : tree_binary_expression (a, b, l, c), etype (t) { } |
|
128 |
|
129 ~tree_boolean_expression (void) { } |
|
130 |
4023
|
131 bool is_boolean_expression (void) const { return true; } |
|
132 |
3933
|
133 bool rvalue_ok (void) const { return true; } |
2980
|
134 |
|
135 octave_value rvalue (void); |
|
136 |
|
137 octave_value_list rvalue (int nargout); |
|
138 |
3523
|
139 std::string oper (void) const; |
2980
|
140 |
4023
|
141 type op_type (void) const { return etype; } |
|
142 |
7336
|
143 tree_expression *dup (symbol_table::scope_id scope); |
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 |
|
158 |
|
159 /* |
|
160 ;;; Local Variables: *** |
|
161 ;;; mode: C++ *** |
|
162 ;;; End: *** |
|
163 */ |