GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-idx.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2013 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_pt_idx_h)
24 #define octave_pt_idx_h 1
25 
26 #include <list>
27 
28 class tree_argument_list;
29 
30 class tree_walker;
31 
32 class octave_map;
33 class octave_value;
34 class octave_value_list;
35 class octave_lvalue;
36 
37 #include "str-vec.h"
38 
39 #include "pt-exp.h"
40 #include "symtab.h"
41 
42 // Index expressions.
43 
44 class
46 {
47 public:
48 
50  int l = -1, int c = -1, char t = '(');
51 
52  tree_index_expression (tree_expression *e, const std::string& n,
53  int l = -1, int c = -1);
54 
56  int l = -1, int c = -1);
57 
58  ~tree_index_expression (void);
59 
60  bool has_magic_end (void) const;
61 
62  void append (tree_argument_list *lst = 0, char t = '(');
63 
64  void append (const std::string& n);
65 
66  void append (tree_expression *df);
67 
68  bool is_index_expression (void) const { return true; }
69 
70  std::string name (void) const;
71 
72  tree_expression *expression (void) { return expr; }
73 
74  std::list<tree_argument_list *> arg_lists (void) { return args; }
75 
76  std::string type_tags (void) { return type; }
77 
78  std::list<string_vector> arg_names (void) { return arg_nm; }
79 
80  bool lvalue_ok (void) const { return expr->lvalue_ok (); }
81 
82  bool rvalue_ok (void) const { return true; }
83 
84  octave_value rvalue1 (int nargout = 1);
85 
86  octave_value_list rvalue (int nargout);
87 
88  octave_value_list rvalue (int nargout,
89  const std::list<octave_lvalue> *lvalue_list);
90 
91  octave_lvalue lvalue (void);
92 
95 
96  void accept (tree_walker& tw);
97 
98 private:
99 
100  // The LHS of this index expression.
102 
103  // The indices (only valid if type == paren || type == brace).
104  std::list<tree_argument_list *> args;
105 
106  // The type of this index expression.
107  std::string type;
108 
109  // The names of the arguments. Used for constant struct element
110  // references.
111  std::list<string_vector> arg_nm;
112 
113  // The list of dynamic field names, if any.
114  std::list<tree_expression *> dyn_field;
115 
116  tree_index_expression (int l, int c);
117 
118  octave_map make_arg_struct (void) const;
119 
120  std::string
121  get_struct_index
122  (std::list<string_vector>::const_iterator p_arg_nm,
123  std::list<tree_expression *>::const_iterator p_dyn_field) const;
124 
125  // No copying!
126 
128 
130 };
131 
132 #endif