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" |
|
37 |
|
38 // Binary expressions. |
|
39 |
|
40 class |
|
41 tree_binary_expression : public tree_expression |
|
42 { |
|
43 public: |
|
44 |
|
45 tree_binary_expression (int l = -1, int c = -1, |
|
46 octave_value::binary_op t |
|
47 = octave_value::unknown_binary_op) |
|
48 : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t) { } |
|
49 |
|
50 tree_binary_expression (tree_expression *a, tree_expression *b, |
|
51 int l = -1, int c = -1, |
|
52 octave_value::binary_op t |
|
53 = octave_value::unknown_binary_op) |
|
54 : tree_expression (l, c), op_lhs (a), op_rhs (b), etype (t) { } |
|
55 |
|
56 ~tree_binary_expression (void) |
|
57 { |
|
58 delete op_lhs; |
|
59 delete op_rhs; |
|
60 } |
|
61 |
4267
|
62 bool has_magic_end (void) const |
|
63 { |
|
64 return ((op_lhs && op_lhs->has_magic_end ()) |
|
65 || (op_rhs && op_rhs->has_magic_end ())); |
|
66 } |
|
67 |
4023
|
68 bool is_binary_expression (void) const { return true; } |
|
69 |
3933
|
70 bool rvalue_ok (void) const { return true; } |
2980
|
71 |
|
72 octave_value rvalue (void); |
|
73 |
3010
|
74 octave_value_list rvalue (int nargout); |
2980
|
75 |
|
76 void eval_error (void); |
|
77 |
3523
|
78 std::string oper (void) const; |
2980
|
79 |
4023
|
80 octave_value::binary_op op_type (void) const { return etype; } |
|
81 |
2980
|
82 tree_expression *lhs (void) { return op_lhs; } |
|
83 tree_expression *rhs (void) { return op_rhs; } |
|
84 |
5861
|
85 tree_expression *dup (symbol_table *sym_tab); |
|
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, |
|
125 int l = -1, int c = -1, type t = unknown) |
|
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 |
|
134 octave_value rvalue (void); |
|
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 |
5861
|
142 tree_expression *dup (symbol_table *sym_tab); |
|
143 |
2980
|
144 private: |
|
145 |
|
146 // The type of the expression. |
|
147 type etype; |
2988
|
148 |
|
149 // No copying! |
|
150 |
|
151 tree_boolean_expression (const tree_boolean_expression&); |
|
152 |
|
153 tree_boolean_expression& operator = (const tree_boolean_expression&); |
2980
|
154 }; |
|
155 |
|
156 #endif |
|
157 |
|
158 /* |
|
159 ;;; Local Variables: *** |
|
160 ;;; mode: C++ *** |
|
161 ;;; End: *** |
|
162 */ |