2980
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_binop_h) |
|
24 #define octave_tree_binop_h 1 |
|
25 |
|
26 #include <string> |
|
27 |
|
28 class tree_walker; |
|
29 |
|
30 class octave_value; |
|
31 class octave_value_list; |
|
32 class octave_lvalue; |
|
33 |
|
34 #include "ov.h" |
|
35 #include "pt-exp.h" |
|
36 |
|
37 // Binary expressions. |
|
38 |
|
39 class |
|
40 tree_binary_expression : public tree_expression |
|
41 { |
|
42 public: |
|
43 |
|
44 tree_binary_expression (int l = -1, int c = -1, |
|
45 octave_value::binary_op t |
|
46 = octave_value::unknown_binary_op) |
|
47 : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t) { } |
|
48 |
|
49 tree_binary_expression (tree_expression *a, tree_expression *b, |
|
50 int l = -1, int c = -1, |
|
51 octave_value::binary_op t |
|
52 = octave_value::unknown_binary_op) |
|
53 : tree_expression (l, c), op_lhs (a), op_rhs (b), etype (t) { } |
|
54 |
|
55 ~tree_binary_expression (void) |
|
56 { |
|
57 delete op_lhs; |
|
58 delete op_rhs; |
|
59 } |
|
60 |
4267
|
61 bool has_magic_end (void) const |
|
62 { |
|
63 return ((op_lhs && op_lhs->has_magic_end ()) |
|
64 || (op_rhs && op_rhs->has_magic_end ())); |
|
65 } |
|
66 |
4023
|
67 bool is_binary_expression (void) const { return true; } |
|
68 |
3933
|
69 bool rvalue_ok (void) const { return true; } |
2980
|
70 |
|
71 octave_value rvalue (void); |
|
72 |
3010
|
73 octave_value_list rvalue (int nargout); |
2980
|
74 |
|
75 void eval_error (void); |
|
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 |
|
84 void accept (tree_walker& tw); |
|
85 |
|
86 protected: |
|
87 |
|
88 // The operands for the expression. |
|
89 tree_expression *op_lhs; |
|
90 tree_expression *op_rhs; |
|
91 |
|
92 private: |
|
93 |
|
94 // The type of the expression. |
|
95 octave_value::binary_op etype; |
2988
|
96 |
|
97 // No copying! |
|
98 |
|
99 tree_binary_expression (const tree_binary_expression&); |
|
100 |
|
101 tree_binary_expression& operator = (const tree_binary_expression&); |
2980
|
102 }; |
|
103 |
|
104 // Boolean expressions. |
|
105 |
|
106 class |
|
107 tree_boolean_expression : public tree_binary_expression |
|
108 { |
|
109 public: |
|
110 |
|
111 enum type |
|
112 { |
|
113 unknown, |
|
114 bool_and, |
|
115 bool_or |
|
116 }; |
|
117 |
|
118 tree_boolean_expression (int l = -1, int c = -1, type t = unknown) |
|
119 : tree_binary_expression (l, c), etype (t) { } |
|
120 |
|
121 tree_boolean_expression (tree_expression *a, tree_expression *b, |
|
122 int l = -1, int c = -1, type t = unknown) |
|
123 : tree_binary_expression (a, b, l, c), etype (t) { } |
|
124 |
|
125 ~tree_boolean_expression (void) { } |
|
126 |
4023
|
127 bool is_boolean_expression (void) const { return true; } |
|
128 |
3933
|
129 bool rvalue_ok (void) const { return true; } |
2980
|
130 |
|
131 octave_value rvalue (void); |
|
132 |
|
133 octave_value_list rvalue (int nargout); |
|
134 |
3523
|
135 std::string oper (void) const; |
2980
|
136 |
4023
|
137 type op_type (void) const { return etype; } |
|
138 |
2980
|
139 private: |
|
140 |
|
141 // The type of the expression. |
|
142 type etype; |
2988
|
143 |
|
144 // No copying! |
|
145 |
|
146 tree_boolean_expression (const tree_boolean_expression&); |
|
147 |
|
148 tree_boolean_expression& operator = (const tree_boolean_expression&); |
2980
|
149 }; |
|
150 |
|
151 #endif |
|
152 |
|
153 /* |
|
154 ;;; Local Variables: *** |
|
155 ;;; mode: C++ *** |
|
156 ;;; End: *** |
|
157 */ |