pt-idx.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_index_h)
00024 #define octave_tree_index_h 1
00025 
00026 #include <list>
00027 
00028 class tree_argument_list;
00029 
00030 class tree_walker;
00031 
00032 class octave_map;
00033 class octave_value;
00034 class octave_value_list;
00035 class octave_lvalue;
00036 
00037 #include "str-vec.h"
00038 
00039 #include "pt-exp.h"
00040 #include "symtab.h"
00041 
00042 // Index expressions.
00043 
00044 class
00045 tree_index_expression : public tree_expression
00046 {
00047 public:
00048 
00049   tree_index_expression (tree_expression *e = 0, tree_argument_list *lst = 0,
00050                          int l = -1, int c = -1, char t = '(');
00051 
00052   tree_index_expression (tree_expression *e, const std::string& n,
00053                          int l = -1, int c = -1);
00054 
00055   tree_index_expression (tree_expression *e, tree_expression* df,
00056                          int l = -1, int c = -1);
00057 
00058   ~tree_index_expression (void);
00059 
00060   bool has_magic_end (void) const;
00061 
00062   void append (tree_argument_list *lst = 0, char t = '(');
00063 
00064   void append (const std::string& n);
00065 
00066   void append (tree_expression *df);
00067 
00068   bool is_index_expression (void) const { return true; }
00069 
00070   std::string name (void) const;
00071 
00072   tree_expression *expression (void) { return expr; }
00073 
00074   std::list<tree_argument_list *> arg_lists (void) { return args; }
00075 
00076   std::string type_tags (void) { return type; }
00077 
00078   std::list<string_vector> arg_names (void) { return arg_nm; }
00079 
00080   bool lvalue_ok (void) const { return expr->lvalue_ok (); }
00081 
00082   bool rvalue_ok (void) const { return true; }
00083 
00084   octave_value rvalue1 (int nargout = 1);
00085 
00086   octave_value_list rvalue (int nargout);
00087 
00088   octave_value_list rvalue (int nargout, const std::list<octave_lvalue> *lvalue_list);
00089 
00090   octave_lvalue lvalue (void);
00091 
00092   tree_index_expression *dup (symbol_table::scope_id scope,
00093                               symbol_table::context_id context) const;
00094 
00095   void accept (tree_walker& tw);
00096 
00097 private:
00098 
00099   // The LHS of this index expression.
00100   tree_expression *expr;
00101 
00102   // The indices (only valid if type == paren || type == brace).
00103   std::list<tree_argument_list *> args;
00104 
00105   // The type of this index expression.
00106   std::string type;
00107 
00108   // The names of the arguments.  Used for constant struct element
00109   // references.
00110   std::list<string_vector> arg_nm;
00111 
00112   // The list of dynamic field names, if any.
00113   std::list<tree_expression *> dyn_field;
00114 
00115   tree_index_expression (int l, int c);
00116 
00117   octave_map make_arg_struct (void) const;
00118 
00119   std::string
00120   get_struct_index
00121     (std::list<string_vector>::const_iterator p_arg_nm,
00122      std::list<tree_expression *>::const_iterator p_dyn_field) const;
00123 
00124   // No copying!
00125 
00126   tree_index_expression (const tree_index_expression&);
00127 
00128   tree_index_expression& operator = (const tree_index_expression&);
00129 };
00130 
00131 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines