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 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class tree_argument_list; |
|
31 |
|
32 class tree_walker; |
|
33 |
|
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 |
3929
|
49 enum type |
|
50 { |
|
51 unknown, |
|
52 paren, |
3930
|
53 brace, |
|
54 dot |
3929
|
55 }; |
|
56 |
2980
|
57 tree_index_expression (tree_expression *e = 0, tree_argument_list *lst = 0, |
3929
|
58 int l = -1, int c = -1, type t = paren); |
2980
|
59 |
3930
|
60 tree_index_expression (tree_expression *e, const std::string& n, |
|
61 int l = -1, int c = -1); |
|
62 |
2980
|
63 ~tree_index_expression (void); |
|
64 |
|
65 bool is_index_expression (void) const |
3930
|
66 { return (itype == paren || itype == brace); } |
|
67 |
|
68 bool is_indirect_ref (void) const |
|
69 { return (itype == dot); } |
2980
|
70 |
3523
|
71 std::string name (void) const; |
2991
|
72 |
3930
|
73 std::string struct_elt_name (void) const |
|
74 { return itype == dot ? arg_nm(0) : "<unknown>"; } |
|
75 |
|
76 type expr_type (void) { return itype; } |
|
77 |
2980
|
78 tree_expression *expression (void) |
|
79 { return expr; } |
|
80 |
|
81 tree_argument_list *arg_list (void) |
|
82 { return list; } |
|
83 |
3010
|
84 bool lvalue_ok (void) const |
3930
|
85 { return (itype == dot || expr->lvalue_ok ()); } |
3010
|
86 |
2980
|
87 bool rvalue_ok (void) const |
|
88 { return true; } |
|
89 |
|
90 octave_value rvalue (void); |
|
91 |
|
92 octave_value_list rvalue (int nargout); |
|
93 |
|
94 octave_lvalue lvalue (void); |
|
95 |
|
96 void eval_error (void); |
|
97 |
|
98 void accept (tree_walker& tw); |
|
99 |
|
100 private: |
|
101 |
3930
|
102 // The LHS of this index expression. |
2980
|
103 tree_expression *expr; |
|
104 |
3930
|
105 // The indices (only valid if itype == paren || itype == brace). |
2980
|
106 tree_argument_list *list; |
|
107 |
3930
|
108 // The type of this index expression. |
3929
|
109 type itype; |
|
110 |
3930
|
111 // The names of the arguments. |
2980
|
112 string_vector arg_nm; |
2988
|
113 |
|
114 // No copying! |
|
115 |
|
116 tree_index_expression (const tree_index_expression&); |
|
117 |
|
118 tree_index_expression& operator = (const tree_index_expression&); |
2980
|
119 }; |
|
120 |
|
121 #endif |
|
122 |
|
123 /* |
|
124 ;;; Local Variables: *** |
|
125 ;;; mode: C++ *** |
|
126 ;;; End: *** |
|
127 */ |