Mercurial > hg > octave-nkf
comparison src/pt-assign.cc @ 3977:95663a3a2682
[project @ 2002-07-05 17:43:37 by jwe]
author | jwe |
---|---|
date | Fri, 05 Jul 2002 17:43:38 +0000 |
parents | edd758a7ca8d |
children | b79da8779a0e |
comparison
equal
deleted
inserted
replaced
3976:4038f12b8eea | 3977:95663a3a2682 |
---|---|
206 if (error_state) | 206 if (error_state) |
207 return retval; | 207 return retval; |
208 | 208 |
209 if (rhs) | 209 if (rhs) |
210 { | 210 { |
211 int n_out = lhs->length (); | 211 int n_out = lhs->nargout_count (); |
212 | |
213 if (error_state) | |
214 return retval; | |
212 | 215 |
213 octave_value_list rhs_val = rhs->rvalue (n_out); | 216 octave_value_list rhs_val = rhs->rvalue (n_out); |
214 | 217 |
215 if (! error_state) | 218 if (error_state) |
219 return retval; | |
220 | |
221 if (rhs_val.empty ()) | |
216 { | 222 { |
217 if (rhs_val.empty ()) | 223 error ("value on right hand side of assignment is undefined"); |
224 eval_error (); | |
225 } | |
226 else | |
227 { | |
228 int k = 0; | |
229 | |
230 int n = rhs_val.length (); | |
231 | |
232 retval.resize (n, octave_value ()); | |
233 | |
234 for (Pix p = lhs->first (); p != 0; lhs->next (p)) | |
218 { | 235 { |
219 error ("value on right hand side of assignment is undefined"); | 236 tree_expression *lhs_elt = lhs->operator () (p); |
220 eval_error (); | 237 |
221 } | 238 if (lhs_elt) |
222 else | |
223 { | |
224 int k = 0; | |
225 | |
226 int n = rhs_val.length (); | |
227 | |
228 retval.resize (n, octave_value ()); | |
229 | |
230 for (Pix p = lhs->first (); p != 0; lhs->next (p)) | |
231 { | 239 { |
232 tree_expression *lhs_elt = lhs->operator () (p); | 240 octave_lvalue ult = lhs_elt->lvalue (); |
233 | 241 |
234 if (lhs_elt) | 242 if (error_state) |
243 eval_error (); | |
244 else if (k < n) | |
235 { | 245 { |
236 octave_lvalue ult = lhs_elt->lvalue (); | 246 ult.assign (etype, rhs_val(k)); |
237 | 247 |
238 if (error_state) | 248 if (! error_state) |
239 eval_error (); | |
240 else if (k < n) | |
241 { | 249 { |
242 ult.assign (etype, rhs_val(k)); | 250 if (etype == octave_value::op_asn_eq) |
243 | 251 retval(k) = rhs_val(k); |
244 if (! error_state) | |
245 { | |
246 if (etype == octave_value::op_asn_eq) | |
247 retval(k) = rhs_val(k); | |
248 else | |
249 retval(k) = ult.value (); | |
250 } | |
251 } | |
252 else | |
253 error ("element number %d undefined in return list", | |
254 k+1); | |
255 | |
256 if (error_state) | |
257 eval_error (); | |
258 else if (print_result ()) | |
259 { | |
260 if (Vprint_rhs_assign_val) | |
261 retval(k).print_with_name | |
262 (octave_stdout, lhs_elt->str_print_code ()); | |
263 else | 252 else |
264 { | 253 retval(k) = ult.value (); |
265 // We clear any index here so that we can | |
266 // get the new value of the referenced | |
267 // object below, instead of the indexed | |
268 // value (which should be the same as the | |
269 // right hand side value). | |
270 | |
271 ult.clear_index (); | |
272 | |
273 octave_value lhs_val = ult.value (); | |
274 | |
275 if (! error_state) | |
276 lhs_val.print_with_name (octave_stdout, | |
277 lhs_elt->name ()); | |
278 } | |
279 } | 254 } |
280 } | 255 } |
281 else | 256 else |
257 error ("element number %d undefined in return list", k+1); | |
258 | |
259 if (error_state) | |
282 eval_error (); | 260 eval_error (); |
283 | 261 else if (print_result ()) |
284 if (error_state) | 262 { |
285 break; | 263 if (Vprint_rhs_assign_val) |
286 | 264 retval(k).print_with_name |
287 k++; | 265 (octave_stdout, lhs_elt->str_print_code ()); |
266 else | |
267 { | |
268 // We clear any index here so that we can | |
269 // get the new value of the referenced | |
270 // object below, instead of the indexed | |
271 // value (which should be the same as the | |
272 // right hand side value). | |
273 | |
274 ult.clear_index (); | |
275 | |
276 octave_value lhs_val = ult.value (); | |
277 | |
278 if (! error_state) | |
279 lhs_val.print_with_name (octave_stdout, | |
280 lhs_elt->name ()); | |
281 } | |
282 } | |
288 } | 283 } |
284 else | |
285 eval_error (); | |
286 | |
287 if (error_state) | |
288 break; | |
289 | |
290 k++; | |
289 } | 291 } |
290 } | 292 } |
291 } | 293 } |
292 else | 294 else |
293 eval_error (); | 295 eval_error (); |