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 |
|
30 class tree_argument_list; |
|
31 |
|
32 class tree_walker; |
|
33 |
3933
|
34 class Octave_map; |
2980
|
35 class octave_value; |
|
36 class octave_value_list; |
|
37 class octave_lvalue; |
|
38 |
3933
|
39 #include "SLList.h" |
2980
|
40 #include "str-vec.h" |
|
41 |
|
42 #include "pt-exp.h" |
|
43 |
|
44 // Index expressions. |
|
45 |
|
46 class |
|
47 tree_index_expression : public tree_expression |
|
48 { |
|
49 public: |
|
50 |
|
51 tree_index_expression (tree_expression *e = 0, tree_argument_list *lst = 0, |
3933
|
52 int l = -1, int c = -1, char t = '('); |
2980
|
53 |
3930
|
54 tree_index_expression (tree_expression *e, const std::string& n, |
|
55 int l = -1, int c = -1); |
|
56 |
4131
|
57 tree_index_expression (tree_expression *e, tree_expression* df, |
|
58 int l = -1, int c = -1); |
|
59 |
2980
|
60 ~tree_index_expression (void); |
|
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 |
3933
|
74 SLList<tree_argument_list *> arg_lists (void) { return args; } |
3930
|
75 |
3933
|
76 std::string type_tags (void) { return type; } |
2980
|
77 |
3933
|
78 SLList<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). |
|
100 SLList<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. |
3933
|
107 SLList<string_vector> arg_nm; |
|
108 |
4131
|
109 // The list of dynamic field names, if any. |
|
110 SLList<tree_expression *> dyn_field; |
|
111 |
|
112 Octave_map make_arg_struct (void) const; |
|
113 |
|
114 std::string get_struct_index (Pix p_arg_nm, Pix p_dyn_field) const; |
2988
|
115 |
|
116 // No copying! |
|
117 |
|
118 tree_index_expression (const tree_index_expression&); |
|
119 |
|
120 tree_index_expression& operator = (const tree_index_expression&); |
2980
|
121 }; |
|
122 |
|
123 #endif |
|
124 |
|
125 /* |
|
126 ;;; Local Variables: *** |
|
127 ;;; mode: C++ *** |
|
128 ;;; End: *** |
|
129 */ |