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_colon_h)
00025 #define octave_tree_colon 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 "pt-exp.h"
00036 #include "symtab.h"
00037
00038
00039
00040 class
00041 tree_colon_expression : public tree_expression
00042 {
00043 public:
00044
00045 tree_colon_expression (int l = -1, int c = -1)
00046 : tree_expression (l, c), op_base (0), op_limit (0),
00047 op_increment (0), save_base (false) { }
00048
00049 tree_colon_expression (tree_expression *e, int l = -1, int c = -1)
00050 : tree_expression (l, c), op_base (e), op_limit (0),
00051 op_increment (0), save_base (false) { }
00052
00053 tree_colon_expression (tree_expression *bas, tree_expression *lim,
00054 tree_expression *inc, int l = -1, int c = -1)
00055 : tree_expression (l, c), op_base (bas), op_limit (lim),
00056 op_increment (inc), save_base (false) { }
00057
00058 ~tree_colon_expression (void)
00059 {
00060 if (! save_base)
00061 delete op_base;
00062
00063 delete op_limit;
00064 delete op_increment;
00065 }
00066
00067 bool has_magic_end (void) const
00068 {
00069 return ((op_base && op_base->has_magic_end ())
00070 || (op_limit && op_limit->has_magic_end ())
00071 || (op_increment && op_increment->has_magic_end ()));
00072 }
00073
00074 void preserve_base (void) { save_base = true; }
00075
00076 tree_colon_expression *append (tree_expression *t);
00077
00078 bool rvalue_ok (void) const { return true; }
00079
00080 octave_value rvalue1 (int nargout = 1);
00081
00082 octave_value_list rvalue (int nargout);
00083
00084 void eval_error (const std::string& s) const;
00085
00086 tree_expression *base (void) { return op_base; }
00087
00088 tree_expression *limit (void) { return op_limit; }
00089
00090 tree_expression *increment (void) { return op_increment; }
00091
00092 int line (void) const;
00093 int column (void) const;
00094
00095 tree_expression *dup (symbol_table::scope_id scope,
00096 symbol_table::context_id context) const;
00097
00098 void accept (tree_walker& tw);
00099
00100 private:
00101
00102
00103 tree_expression *op_base;
00104 tree_expression *op_limit;
00105 tree_expression *op_increment;
00106
00107 bool save_base;
00108
00109 octave_value
00110 make_range (const Matrix& m_base, const Matrix& m_limit,
00111 const Matrix& m_increment, bool result_is_str,
00112 bool dq_str) const;
00113
00114 octave_value
00115 make_range (const octave_value& ov_base, const octave_value& ov_limit,
00116 const octave_value& ov_increment) const;
00117
00118
00119
00120 tree_colon_expression (const tree_colon_expression&);
00121
00122 tree_colon_expression& operator = (const tree_colon_expression&);
00123 };
00124
00125 #endif
00126
00127
00128
00129
00130
00131