Mercurial > octave-nkf
comparison src/pt-mvr.cc @ 2086:bfb775fb6fe8
[project @ 1996-04-25 05:55:19 by jwe]
author | jwe |
---|---|
date | Thu, 25 Apr 1996 05:55:19 +0000 |
parents | 003570e69c7b |
children | 36903d507b0e |
comparison
equal
deleted
inserted
replaced
2085:7603b37325db | 2086:bfb775fb6fe8 |
---|---|
44 // But first, some extra functions used by the tree classes. | 44 // But first, some extra functions used by the tree classes. |
45 | 45 |
46 // Make sure that all arguments have values. | 46 // Make sure that all arguments have values. |
47 | 47 |
48 static bool | 48 static bool |
49 all_args_defined (const Octave_object& args) | 49 all_args_defined (const octave_value_list& args) |
50 { | 50 { |
51 int nargin = args.length (); | 51 int nargin = args.length (); |
52 | 52 |
53 for (int i = 0; i < nargin; i++) | 53 for (int i = 0; i < nargin; i++) |
54 if (args(i).is_undefined ()) | 54 if (args(i).is_undefined ()) |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
60 // Used internally. | 60 // Used internally. |
61 | 61 |
62 tree_constant | 62 octave_value |
63 tree_oct_obj::eval (bool /* print */) | 63 tree_oct_obj::eval (bool /* print */) |
64 { | 64 { |
65 return values(0); | 65 return values(0); |
66 } | 66 } |
67 | 67 |
68 Octave_object | 68 octave_value_list |
69 tree_oct_obj::eval (bool /* print */, int /* nargout */, | 69 tree_oct_obj::eval (bool /* print */, int /* nargout */, |
70 const Octave_object& /* args */) | 70 const octave_value_list& /* args */) |
71 { | 71 { |
72 return values; | 72 return values; |
73 } | 73 } |
74 | 74 |
75 // Index expressions. | 75 // Index expressions. |
107 { | 107 { |
108 if (id) | 108 if (id) |
109 id->mark_for_possible_ans_assign (); | 109 id->mark_for_possible_ans_assign (); |
110 } | 110 } |
111 | 111 |
112 tree_constant | 112 octave_value |
113 tree_index_expression::eval (bool print) | 113 tree_index_expression::eval (bool print) |
114 { | 114 { |
115 tree_constant retval; | 115 octave_value retval; |
116 | 116 |
117 if (error_state) | 117 if (error_state) |
118 return retval; | 118 return retval; |
119 | 119 |
120 if (list) | 120 if (list) |
121 { | 121 { |
122 // Extract the arguments into a simple vector. Don't pass null | 122 // Extract the arguments into a simple vector. Don't pass null |
123 // args. | 123 // args. |
124 | 124 |
125 Octave_object args = list->convert_to_const_vector (); | 125 octave_value_list args = list->convert_to_const_vector (); |
126 | 126 |
127 if (error_state) | 127 if (error_state) |
128 eval_error (); | 128 eval_error (); |
129 else | 129 else |
130 { | 130 { |
132 eval_error (); | 132 eval_error (); |
133 else | 133 else |
134 { | 134 { |
135 if (all_args_defined (args)) | 135 if (all_args_defined (args)) |
136 { | 136 { |
137 Octave_object tmp = id->eval (print, 1, args); | 137 octave_value_list tmp = id->eval (print, 1, args); |
138 | 138 |
139 if (error_state) | 139 if (error_state) |
140 eval_error (); | 140 eval_error (); |
141 else if (tmp.length () > 0) | 141 else if (tmp.length () > 0) |
142 retval = tmp(0); | 142 retval = tmp(0); |
158 } | 158 } |
159 | 159 |
160 return retval; | 160 return retval; |
161 } | 161 } |
162 | 162 |
163 Octave_object | 163 octave_value_list |
164 tree_index_expression::eval (bool print, int nargout, | 164 tree_index_expression::eval (bool print, int nargout, |
165 const Octave_object& /* args */) | 165 const octave_value_list& /* args */) |
166 { | 166 { |
167 Octave_object retval; | 167 octave_value_list retval; |
168 | 168 |
169 if (error_state) | 169 if (error_state) |
170 return retval; | 170 return retval; |
171 | 171 |
172 if (list) | 172 if (list) |
173 { | 173 { |
174 // Extract the arguments into a simple vector. Don't pass null | 174 // Extract the arguments into a simple vector. Don't pass null |
175 // args. | 175 // args. |
176 | 176 |
177 Octave_object tmp_args = list->convert_to_const_vector (); | 177 octave_value_list tmp_args = list->convert_to_const_vector (); |
178 | 178 |
179 if (error_state) | 179 if (error_state) |
180 eval_error (); | 180 eval_error (); |
181 else | 181 else |
182 { | 182 { |
199 } | 199 } |
200 } | 200 } |
201 } | 201 } |
202 else | 202 else |
203 { | 203 { |
204 Octave_object tmp_args; | 204 octave_value_list tmp_args; |
205 | 205 |
206 retval = id->eval (print, nargout, tmp_args); | 206 retval = id->eval (print, nargout, tmp_args); |
207 | 207 |
208 if (error_state) | 208 if (error_state) |
209 eval_error (); | 209 eval_error (); |
269 delete lhs; | 269 delete lhs; |
270 | 270 |
271 delete rhs; | 271 delete rhs; |
272 } | 272 } |
273 | 273 |
274 tree_constant | 274 octave_value |
275 tree_multi_assignment_expression::eval (bool print) | 275 tree_multi_assignment_expression::eval (bool print) |
276 { | 276 { |
277 tree_constant retval; | 277 octave_value retval; |
278 | 278 |
279 if (error_state) | 279 if (error_state) |
280 return retval; | 280 return retval; |
281 | 281 |
282 Octave_object tmp_args; | 282 octave_value_list tmp_args; |
283 Octave_object result = eval (print, 1, tmp_args); | 283 octave_value_list result = eval (print, 1, tmp_args); |
284 | 284 |
285 if (result.length () > 0) | 285 if (result.length () > 0) |
286 retval = result(0); | 286 retval = result(0); |
287 | 287 |
288 return retval; | 288 return retval; |
289 } | 289 } |
290 | 290 |
291 Octave_object | 291 octave_value_list |
292 tree_multi_assignment_expression::eval (bool print, int nargout, | 292 tree_multi_assignment_expression::eval (bool print, int nargout, |
293 const Octave_object& /* args */) | 293 const octave_value_list& /* args */) |
294 { | 294 { |
295 assert (etype == tree_expression::multi_assignment); | 295 assert (etype == tree_expression::multi_assignment); |
296 | 296 |
297 if (error_state || ! rhs) | 297 if (error_state || ! rhs) |
298 return Octave_object (); | 298 return octave_value_list (); |
299 | 299 |
300 nargout = lhs->length (); | 300 nargout = lhs->length (); |
301 Octave_object tmp_args; | 301 octave_value_list tmp_args; |
302 Octave_object results = rhs->eval (0, nargout, tmp_args); | 302 octave_value_list results = rhs->eval (0, nargout, tmp_args); |
303 | 303 |
304 if (error_state) | 304 if (error_state) |
305 eval_error (); | 305 eval_error (); |
306 | 306 |
307 int ma_line = line (); | 307 int ma_line = line (); |
321 { | 321 { |
322 // XXX FIXME? XXX -- this is apparently the way Matlab | 322 // XXX FIXME? XXX -- this is apparently the way Matlab |
323 // works, but maybe we should have the option of | 323 // works, but maybe we should have the option of |
324 // skipping the assignment instead. | 324 // skipping the assignment instead. |
325 | 325 |
326 tree_constant *tmp = 0; | 326 octave_value *tmp = 0; |
327 if (results(i).is_undefined ()) | 327 if (results(i).is_undefined ()) |
328 { | 328 { |
329 error ("element number %d undefined in return list", i+1); | 329 error ("element number %d undefined in return list", i+1); |
330 eval_error (); | 330 eval_error (); |
331 break; | 331 break; |
332 } | 332 } |
333 else | 333 else |
334 tmp = new tree_constant (results(i)); | 334 tmp = new octave_value (results(i)); |
335 | 335 |
336 tree_simple_assignment_expression tmp_expr | 336 tree_simple_assignment_expression tmp_expr |
337 (lhs_expr, tmp, 1, 0, ma_line, ma_column); | 337 (lhs_expr, tmp, 1, 0, ma_line, ma_column); |
338 | 338 |
339 results(i) = tmp_expr.eval (false); // May change | 339 results(i) = tmp_expr.eval (false); // May change |