1739
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1739
|
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_mvr2_h) |
|
24 #define octave_tree_mvr2_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 class ostream; |
|
31 |
|
32 class tree_argument_list; |
|
33 class tree_identifier; |
|
34 class tree_index_expression; |
|
35 class tree_indirect_ref; |
|
36 class tree_return_list; |
|
37 |
2124
|
38 class tree_walker; |
|
39 |
1755
|
40 #include <string> |
|
41 |
2942
|
42 #include "str-vec.h" |
|
43 |
1739
|
44 #include "pt-mvr-base.h" |
|
45 #include "oct-obj.h" |
|
46 |
|
47 // Used internally. |
|
48 |
|
49 class |
|
50 tree_oct_obj : public tree_multi_val_ret |
|
51 { |
|
52 public: |
2124
|
53 |
1739
|
54 tree_oct_obj (int l = -1, int c = -1) : tree_multi_val_ret (l, c) { } |
|
55 |
2086
|
56 tree_oct_obj (const octave_value_list& v, int l = -1, int c = -1) |
1739
|
57 : tree_multi_val_ret (l, c), values (v) { } |
|
58 |
|
59 ~tree_oct_obj (void) { } |
|
60 |
2859
|
61 octave_value eval (bool print = false); |
1739
|
62 |
2942
|
63 octave_value_list |
|
64 eval (bool print, int nargout, const octave_value_list& args); |
1739
|
65 |
2124
|
66 void accept (tree_walker& tw); |
1739
|
67 |
|
68 private: |
2124
|
69 |
2111
|
70 const octave_value_list values; |
1739
|
71 }; |
|
72 |
|
73 // Index expressions. |
|
74 |
|
75 class |
|
76 tree_index_expression : public tree_multi_val_ret |
|
77 { |
|
78 public: |
2124
|
79 |
1739
|
80 tree_index_expression (int l = -1, int c = -1) |
|
81 : tree_multi_val_ret (l, c), id (0), list (0) { } |
|
82 |
|
83 tree_index_expression (tree_identifier *i, int l = -1, int c = -1); |
|
84 |
|
85 tree_index_expression (tree_identifier *i, tree_argument_list *lst, |
|
86 int l = -1, int c = -1); |
|
87 |
|
88 tree_index_expression (tree_indirect_ref *i, int l = -1, int c = -1) |
|
89 : tree_multi_val_ret (l, c), id (i), list (0) { } |
|
90 |
|
91 tree_index_expression (tree_indirect_ref *i, tree_argument_list *lst, |
|
92 int l = -1, int c = -1) |
|
93 : tree_multi_val_ret (l, c), id (i), list (lst) { } |
|
94 |
|
95 ~tree_index_expression (void); |
|
96 |
1827
|
97 bool is_index_expression (void) const |
|
98 { return true; } |
1739
|
99 |
|
100 tree_indirect_ref *ident (void) |
|
101 { return id; } |
|
102 |
2942
|
103 string name (void) const; |
1739
|
104 |
|
105 tree_argument_list *arg_list (void) |
|
106 { return list; } |
|
107 |
|
108 void mark_for_possible_ans_assign (void); |
|
109 |
2859
|
110 octave_value eval (bool print = false); |
1739
|
111 |
2942
|
112 octave_value_list |
|
113 eval (bool print, int nargout, const octave_value_list& args); |
1739
|
114 |
|
115 void eval_error (void); |
|
116 |
2124
|
117 void accept (tree_walker& tw); |
1739
|
118 |
2124
|
119 private: |
|
120 |
1739
|
121 tree_indirect_ref *id; |
2124
|
122 |
1739
|
123 tree_argument_list *list; |
2942
|
124 |
|
125 string_vector arg_nm; |
1739
|
126 }; |
|
127 |
|
128 // Multi-valued assignment expressions. |
|
129 |
|
130 class |
|
131 tree_multi_assignment_expression : public tree_multi_val_ret |
|
132 { |
2124
|
133 public: |
|
134 |
1827
|
135 tree_multi_assignment_expression (bool plhs = false, int l = -1, int c = -1) |
1739
|
136 : tree_multi_val_ret (l, c, tree_expression::multi_assignment), |
|
137 preserve (plhs), lhs (0), rhs (0) { } |
|
138 |
|
139 tree_multi_assignment_expression (tree_return_list *lst, |
|
140 tree_multi_val_ret *r, |
1827
|
141 bool plhs = false, |
1739
|
142 int l = -1, int c = -1) |
|
143 : tree_multi_val_ret (l, c, tree_expression::multi_assignment), |
|
144 preserve (plhs), lhs (lst), rhs (r) { } |
|
145 |
|
146 ~tree_multi_assignment_expression (void); |
|
147 |
2859
|
148 octave_value eval (bool print = false); |
1739
|
149 |
2942
|
150 octave_value_list |
|
151 eval (bool print, int nargout, const octave_value_list& args); |
1739
|
152 |
1827
|
153 bool is_assignment_expression (void) const |
|
154 { return true; } |
1739
|
155 |
|
156 void eval_error (void); |
|
157 |
2124
|
158 tree_return_list *left_hand_side (void) { return lhs; } |
|
159 |
|
160 tree_multi_val_ret *right_hand_side (void) { return rhs; } |
1739
|
161 |
2124
|
162 void accept (tree_walker& tw); |
|
163 |
|
164 private: |
|
165 |
1827
|
166 bool preserve; |
1739
|
167 tree_return_list *lhs; |
|
168 tree_multi_val_ret *rhs; |
|
169 }; |
|
170 |
|
171 #endif |
|
172 |
|
173 /* |
|
174 ;;; Local Variables: *** |
|
175 ;;; mode: C++ *** |
|
176 ;;; End: *** |
|
177 */ |