pt-unop.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_unop_h)
00024 #define octave_tree_unop_h 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 // Unary expressions.
00038 
00039 class
00040 tree_unary_expression : public tree_expression
00041 {
00042 public:
00043 
00044   tree_unary_expression (int l = -1, int c = -1,
00045                          octave_value::unary_op t
00046                            = octave_value::unknown_unary_op)
00047     : tree_expression (l, c), op (0), etype (t)  { }
00048 
00049   tree_unary_expression (tree_expression *e, int l = -1, int c = -1,
00050                          octave_value::unary_op t
00051                            = octave_value::unknown_unary_op)
00052     : tree_expression (l, c), op (e), etype (t) { }
00053 
00054   ~tree_unary_expression (void) { delete op; }
00055 
00056   bool is_unary_expression (void) const { return true; }
00057 
00058   bool has_magic_end (void) const { return (op && op->has_magic_end ()); }
00059 
00060   tree_expression *operand (void) { return op; }
00061 
00062   std::string oper (void) const;
00063 
00064   octave_value::unary_op op_type (void) const { return etype; }
00065 
00066 protected:
00067 
00068   // The operand for the expression.
00069   tree_expression *op;
00070 
00071   // The type of the expression.
00072   octave_value::unary_op etype;
00073 
00074 private:
00075 
00076   // No copying!
00077 
00078   tree_unary_expression (const tree_unary_expression&);
00079 
00080   tree_unary_expression& operator = (const tree_unary_expression&);
00081 };
00082 
00083 // Prefix expressions.
00084 
00085 class
00086 tree_prefix_expression : public tree_unary_expression
00087 {
00088 public:
00089 
00090   tree_prefix_expression (int l = -1, int c = -1)
00091     : tree_unary_expression (l, c, octave_value::unknown_unary_op) { }
00092 
00093   tree_prefix_expression (tree_expression *e, int l = -1, int c = -1,
00094                           octave_value::unary_op t
00095                             = octave_value::unknown_unary_op)
00096     : tree_unary_expression (e, l, c, t) { }
00097 
00098   ~tree_prefix_expression (void) { }
00099 
00100   bool rvalue_ok (void) const { return true; }
00101 
00102   octave_value rvalue1 (int nargout = 1);
00103 
00104   octave_value_list rvalue (int nargout);
00105 
00106   tree_expression *dup (symbol_table::scope_id scope,
00107                         symbol_table::context_id context) const;
00108 
00109   void accept (tree_walker& tw);
00110 
00111 private:
00112 
00113   // No copying!
00114 
00115   tree_prefix_expression (const tree_prefix_expression&);
00116 
00117   tree_prefix_expression& operator = (const tree_prefix_expression&);
00118 };
00119 
00120 // Postfix expressions.
00121 
00122 class
00123 tree_postfix_expression : public tree_unary_expression
00124 {
00125 public:
00126 
00127   tree_postfix_expression (int l = -1, int c = -1)
00128     : tree_unary_expression (l, c, octave_value::unknown_unary_op) { }
00129 
00130   tree_postfix_expression (tree_expression *e, int l = -1, int c = -1,
00131                            octave_value::unary_op t
00132                              = octave_value::unknown_unary_op)
00133     : tree_unary_expression (e, l, c, t) { }
00134 
00135   ~tree_postfix_expression (void) { }
00136 
00137   bool rvalue_ok (void) const { return true; }
00138 
00139   octave_value rvalue1 (int nargout = 1);
00140 
00141   octave_value_list rvalue (int nargout);
00142 
00143   tree_expression *dup (symbol_table::scope_id scope,
00144                         symbol_table::context_id context) const;
00145 
00146   void accept (tree_walker& tw);
00147 
00148 private:
00149 
00150   // No copying!
00151 
00152   tree_postfix_expression (const tree_postfix_expression&);
00153 
00154   tree_postfix_expression& operator = (const tree_postfix_expression&);
00155 };
00156 
00157 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines