00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_tree_binop_h)
00025 #define octave_tree_binop_h 1
00026
00027 #include <string>
00028
00029 class tree_walker;
00030
00031 class octave_value;
00032 class octave_value_list;
00033 class octave_lvalue;
00034
00035 #include "ov.h"
00036 #include "pt-exp.h"
00037 #include "symtab.h"
00038
00039
00040
00041 class
00042 tree_binary_expression : public tree_expression
00043 {
00044 public:
00045
00046 tree_binary_expression (int l = -1, int c = -1,
00047 octave_value::binary_op t
00048 = octave_value::unknown_binary_op)
00049 : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t) { }
00050
00051 tree_binary_expression (tree_expression *a, tree_expression *b,
00052 int l = -1, int c = -1,
00053 octave_value::binary_op t
00054 = octave_value::unknown_binary_op)
00055 : tree_expression (l, c), op_lhs (a), op_rhs (b), etype (t) { }
00056
00057 ~tree_binary_expression (void)
00058 {
00059 delete op_lhs;
00060 delete op_rhs;
00061 }
00062
00063 bool has_magic_end (void) const
00064 {
00065 return ((op_lhs && op_lhs->has_magic_end ())
00066 || (op_rhs && op_rhs->has_magic_end ()));
00067 }
00068
00069 bool is_binary_expression (void) const { return true; }
00070
00071 bool rvalue_ok (void) const { return true; }
00072
00073 octave_value rvalue1 (int nargout = 1);
00074
00075 octave_value_list rvalue (int nargout);
00076
00077 std::string oper (void) const;
00078
00079 octave_value::binary_op op_type (void) const { return etype; }
00080
00081 tree_expression *lhs (void) { return op_lhs; }
00082 tree_expression *rhs (void) { return op_rhs; }
00083
00084 tree_expression *dup (symbol_table::scope_id scope,
00085 symbol_table::context_id context) const;
00086
00087 void accept (tree_walker& tw);
00088
00089 protected:
00090
00091
00092 tree_expression *op_lhs;
00093 tree_expression *op_rhs;
00094
00095 private:
00096
00097
00098 octave_value::binary_op etype;
00099
00100
00101
00102 tree_binary_expression (const tree_binary_expression&);
00103
00104 tree_binary_expression& operator = (const tree_binary_expression&);
00105 };
00106
00107
00108
00109 class
00110 tree_boolean_expression : public tree_binary_expression
00111 {
00112 public:
00113
00114 enum type
00115 {
00116 unknown,
00117 bool_and,
00118 bool_or
00119 };
00120
00121 tree_boolean_expression (int l = -1, int c = -1, type t = unknown)
00122 : tree_binary_expression (l, c), etype (t) { }
00123
00124 tree_boolean_expression (tree_expression *a, tree_expression *b,
00125 int l = -1, int c = -1, type t = unknown)
00126 : tree_binary_expression (a, b, l, c), etype (t) { }
00127
00128 ~tree_boolean_expression (void) { }
00129
00130 bool is_boolean_expression (void) const { return true; }
00131
00132 bool rvalue_ok (void) const { return true; }
00133
00134 octave_value rvalue1 (int nargout = 1);
00135
00136 octave_value_list rvalue (int nargout);
00137
00138 std::string oper (void) const;
00139
00140 type op_type (void) const { return etype; }
00141
00142 tree_expression *dup (symbol_table::scope_id scope,
00143 symbol_table::context_id context) const;
00144
00145 private:
00146
00147
00148 type etype;
00149
00150
00151
00152 tree_boolean_expression (const tree_boolean_expression&);
00153
00154 tree_boolean_expression& operator = (const tree_boolean_expression&);
00155 };
00156
00157 #endif
00158
00159
00160
00161
00162
00163