pt-colon.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_tree_colon_h)
00024 #define octave_tree_colon 1
00025 
00026 #include <string>
00027 
00028 class tree_walker;
00029 
00030 class octave_value;
00031 class octave_value_list;
00032 class octave_lvalue;
00033 
00034 #include "pt-exp.h"
00035 #include "symtab.h"
00036 
00037 // Colon expressions.
00038 
00039 class
00040 tree_colon_expression : public tree_expression
00041 {
00042 public:
00043 
00044   tree_colon_expression (int l = -1, int c = -1)
00045     : tree_expression (l, c), op_base (0), op_limit (0),
00046       op_increment (0), save_base (false) { }
00047 
00048   tree_colon_expression (tree_expression *e, int l = -1, int c = -1)
00049     : tree_expression (l, c), op_base (e), op_limit (0),
00050       op_increment (0), save_base (false) { }
00051 
00052   tree_colon_expression (tree_expression *bas, tree_expression *lim,
00053                          tree_expression *inc, int l = -1, int c = -1)
00054     : tree_expression (l, c), op_base (bas), op_limit (lim),
00055       op_increment (inc), save_base (false) { }
00056 
00057   ~tree_colon_expression (void)
00058     {
00059       if (! save_base)
00060         delete op_base;
00061 
00062       delete op_limit;
00063       delete op_increment;
00064     }
00065 
00066   bool has_magic_end (void) const
00067     {
00068       return ((op_base && op_base->has_magic_end ())
00069               || (op_limit && op_limit->has_magic_end ())
00070               || (op_increment && op_increment->has_magic_end ()));
00071     }
00072 
00073   void preserve_base (void) { save_base = true; }
00074 
00075   tree_colon_expression *append (tree_expression *t);
00076 
00077   bool rvalue_ok (void) const { return true; }
00078 
00079   octave_value rvalue1 (int nargout = 1);
00080 
00081   octave_value_list rvalue (int nargout);
00082 
00083   void eval_error (const std::string& s) const;
00084 
00085   tree_expression *base (void) { return op_base; }
00086 
00087   tree_expression *limit (void) { return op_limit; }
00088 
00089   tree_expression *increment (void) { return op_increment; }
00090 
00091   int line (void) const;
00092   int column (void) const;
00093 
00094   tree_expression *dup (symbol_table::scope_id scope,
00095                         symbol_table::context_id context) const;
00096 
00097   void accept (tree_walker& tw);
00098 
00099 private:
00100 
00101   // The components of the expression.
00102   tree_expression *op_base;
00103   tree_expression *op_limit;
00104   tree_expression *op_increment;
00105 
00106   bool save_base;
00107 
00108   octave_value
00109   make_range (const Matrix& m_base, const Matrix& m_limit,
00110               const Matrix& m_increment, bool result_is_str,
00111               bool dq_str) const;
00112 
00113   octave_value
00114   make_range (const octave_value& ov_base, const octave_value& ov_limit,
00115               const octave_value& ov_increment) const;
00116 
00117   // No copying!
00118 
00119   tree_colon_expression (const tree_colon_expression&);
00120 
00121   tree_colon_expression& operator = (const tree_colon_expression&);
00122 };
00123 
00124 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines