Mercurial > hg > octave-avbm
comparison src/parse.y @ 3726:b7d997d593d9
[project @ 2000-10-27 17:51:21 by jwe]
author | jwe |
---|---|
date | Fri, 27 Oct 2000 17:51:27 +0000 |
parents | 7066a8065e7e |
children | e10451597802 |
comparison
equal
deleted
inserted
replaced
3725:7d2d642cbb53 | 3726:b7d997d593d9 |
---|---|
3251 print_usage ("source"); | 3251 print_usage ("source"); |
3252 | 3252 |
3253 return retval; | 3253 return retval; |
3254 } | 3254 } |
3255 | 3255 |
3256 // Evaluate an Octave function (built-in or interpreted) and return | |
3257 // the list of result values. the results. NAME is the name of the | |
3258 // function to call. ARGS are the arguments to the function. NARGOUT | |
3259 // is the number of output arguments expected. | |
3260 | |
3256 octave_value_list | 3261 octave_value_list |
3257 feval (const std::string& name, const octave_value_list& args, int nargout) | 3262 feval (const std::string& name, const octave_value_list& args, int nargout) |
3258 { | 3263 { |
3259 octave_value_list retval; | 3264 octave_value_list retval; |
3260 | 3265 |
3263 if (fcn) | 3268 if (fcn) |
3264 retval = fcn->do_multi_index_op (nargout, args); | 3269 retval = fcn->do_multi_index_op (nargout, args); |
3265 | 3270 |
3266 return retval; | 3271 return retval; |
3267 } | 3272 } |
3273 | |
3274 // Evaluate an Octave function (built-in or interpreted) and return | |
3275 // the list of result values. The first element of ARGS should be a | |
3276 // string containing the name of the function to call, then the rest | |
3277 // are the actual arguments to the function. NARGOUT is the number of | |
3278 // output arguments expected. | |
3268 | 3279 |
3269 octave_value_list | 3280 octave_value_list |
3270 feval (const octave_value_list& args, int nargout) | 3281 feval (const octave_value_list& args, int nargout) |
3271 { | 3282 { |
3272 octave_value_list retval; | 3283 octave_value_list retval; |
3286 | 3297 |
3287 string_vector arg_names = args.name_tags (); | 3298 string_vector arg_names = args.name_tags (); |
3288 | 3299 |
3289 if (! arg_names.empty ()) | 3300 if (! arg_names.empty ()) |
3290 { | 3301 { |
3291 assert (arg_names.length () == tmp_nargin + 1); | 3302 // tmp_nargin and arg_names.length () - 1 may differ if |
3292 | 3303 // we are passed all_va_args. |
3293 string_vector tmp_arg_names (tmp_nargin); | 3304 |
3294 | 3305 int n = arg_names.length () - 1; |
3295 for (int i = 0; i < tmp_nargin; i++) | 3306 |
3307 int len = n > tmp_nargin ? tmp_nargin : n; | |
3308 | |
3309 string_vector tmp_arg_names (len); | |
3310 | |
3311 for (int i = 0; i < len; i++) | |
3296 tmp_arg_names(i) = arg_names(i+1); | 3312 tmp_arg_names(i) = arg_names(i+1); |
3297 | 3313 |
3298 tmp_args.stash_name_tags (tmp_arg_names); | 3314 tmp_args.stash_name_tags (tmp_arg_names); |
3299 } | 3315 } |
3300 | 3316 |