2980
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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 2, or (at your option) any |
|
10 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, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_index_h) |
|
24 #define octave_tree_index_h 1 |
|
25 |
4219
|
26 #include <list> |
|
27 |
2980
|
28 class tree_argument_list; |
|
29 |
|
30 class tree_walker; |
|
31 |
3933
|
32 class Octave_map; |
2980
|
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 |
|
41 // Index expressions. |
|
42 |
|
43 class |
|
44 tree_index_expression : public tree_expression |
|
45 { |
|
46 public: |
|
47 |
|
48 tree_index_expression (tree_expression *e = 0, tree_argument_list *lst = 0, |
3933
|
49 int l = -1, int c = -1, char t = '('); |
2980
|
50 |
3930
|
51 tree_index_expression (tree_expression *e, const std::string& n, |
|
52 int l = -1, int c = -1); |
|
53 |
4131
|
54 tree_index_expression (tree_expression *e, tree_expression* df, |
|
55 int l = -1, int c = -1); |
|
56 |
2980
|
57 ~tree_index_expression (void); |
|
58 |
5099
|
59 bool has_magic_end (void) const; |
4267
|
60 |
3933
|
61 void append (tree_argument_list *lst = 0, char t = '('); |
3930
|
62 |
3933
|
63 void append (const std::string& n); |
|
64 |
4131
|
65 void append (tree_expression *df); |
|
66 |
3933
|
67 bool is_index_expression (void) const { return true; } |
2980
|
68 |
3523
|
69 std::string name (void) const; |
2991
|
70 |
3933
|
71 tree_expression *expression (void) { return expr; } |
3930
|
72 |
4219
|
73 std::list<tree_argument_list *> arg_lists (void) { return args; } |
3930
|
74 |
3933
|
75 std::string type_tags (void) { return type; } |
2980
|
76 |
4219
|
77 std::list<string_vector> arg_names (void) { return arg_nm; } |
2980
|
78 |
3933
|
79 bool lvalue_ok (void) const { return expr->lvalue_ok (); } |
3010
|
80 |
3933
|
81 bool rvalue_ok (void) const { return true; } |
2980
|
82 |
|
83 octave_value rvalue (void); |
|
84 |
|
85 octave_value_list rvalue (int nargout); |
|
86 |
|
87 octave_lvalue lvalue (void); |
|
88 |
4143
|
89 void eval_error (void) const; |
2980
|
90 |
|
91 void accept (tree_walker& tw); |
|
92 |
|
93 private: |
|
94 |
3930
|
95 // The LHS of this index expression. |
2980
|
96 tree_expression *expr; |
|
97 |
3933
|
98 // The indices (only valid if type == paren || type == brace). |
4219
|
99 std::list<tree_argument_list *> args; |
2980
|
100 |
3930
|
101 // The type of this index expression. |
3933
|
102 std::string type; |
3929
|
103 |
4131
|
104 // The names of the arguments. Used for constant struct element |
|
105 // references. |
4219
|
106 std::list<string_vector> arg_nm; |
3933
|
107 |
4131
|
108 // The list of dynamic field names, if any. |
4219
|
109 std::list<tree_expression *> dyn_field; |
4131
|
110 |
|
111 Octave_map make_arg_struct (void) const; |
|
112 |
4219
|
113 std::string |
|
114 get_struct_index |
|
115 (std::list<string_vector>::const_iterator p_arg_nm, |
|
116 std::list<tree_expression *>::const_iterator p_dyn_field) const; |
2988
|
117 |
|
118 // No copying! |
|
119 |
|
120 tree_index_expression (const tree_index_expression&); |
|
121 |
|
122 tree_index_expression& operator = (const tree_index_expression&); |
2980
|
123 }; |
|
124 |
|
125 #endif |
|
126 |
|
127 /* |
|
128 ;;; Local Variables: *** |
|
129 ;;; mode: C++ *** |
|
130 ;;; End: *** |
|
131 */ |