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