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