Mercurial > hg > octave-lyh
changeset 504:be155b3d5a2f
[project @ 1994-07-08 23:45:33 by jwe]
author | jwe |
---|---|
date | Fri, 08 Jul 1994 23:52:12 +0000 |
parents | dbb8a47acc3a |
children | f264c1454c2b |
files | src/oct-obj.h src/parse.y src/pt-const.h src/pt-exp-base.cc src/pt-exp-base.h src/tc-rep.cc |
diffstat | 6 files changed, 38 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oct-obj.h +++ b/src/oct-obj.h @@ -21,12 +21,17 @@ */ +#if !defined (octave_oct_obj_h) +#define octave_oct_obj_h 1 + #include "Array.h" class tree_constant; typedef Array<tree_constant> Octave_object; +#endif + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/src/parse.y +++ b/src/parse.y @@ -1042,6 +1042,13 @@ quote_is_transpose = 0; $$ = (tree_parameter_list *) NULL; } + | '(' ELLIPSIS ')' + { + quote_is_transpose = 0; + tree_parameter_list *tmp = new tree_parameter_list (); + tmp->mark_varargs_only (); + $$ = tmp; + } | param_list1 ')' { quote_is_transpose = 0; @@ -1057,6 +1064,7 @@ tmp->mark_varargs (); $$ = tmp; } + ; param_list1 : '(' identifier { $$ = new tree_parameter_list ($2); } @@ -1077,8 +1085,11 @@ ; identifier : NAME - { $$ = new tree_identifier - ($1->sym_rec (), $1->line (), $1->column ()); } + { + $$ = new tree_identifier + ($1->sym_rec (), $1->line (), $1->column ()); + } + ; arg_list : arg_list1 { $$ = $1->reverse (); }
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -30,7 +30,6 @@ #include <stdlib.h> -#include "Array.h" #include "mx-base.h" #include "Range.h"
--- a/src/pt-exp-base.cc +++ b/src/pt-exp-base.cc @@ -1151,6 +1151,7 @@ { int nargout = maybe_do_ans_assign ? 0 : 1; +// int nargin = (ans->is_constant ()) ? 0 : 1; Octave_object tmp_args; Octave_object tmp = ans->eval (0, nargout, tmp_args, 0); @@ -1512,7 +1513,8 @@ unwind_protect_int (num_named_args); unwind_protect_int (curr_arg_number); - if (param_list != (tree_parameter_list *) NULL) + if (param_list != (tree_parameter_list *) NULL + && ! param_list->varargs_only ()) { param_list->define_from_arg_vector (args, nargin); if (error_state) @@ -2841,6 +2843,18 @@ return marked_for_varargs; } +void +tree_parameter_list::mark_varargs_only (void) +{ + marked_for_varargs = -1; +} + +int +tree_parameter_list::varargs_only (void) +{ + return (marked_for_varargs < 0); +} + tree_identifier * tree_parameter_list::define (tree_constant *t) {
--- a/src/pt-exp-base.h +++ b/src/pt-exp-base.h @@ -30,8 +30,6 @@ #include <stdio.h> -#include "Array.h" - #include "builtins.h" #include "error.h" #include "oct-obj.h" @@ -582,6 +580,9 @@ void mark_varargs (void); int takes_varargs (void) const; + void mark_varargs_only (void); + int varargs_only (void); + tree_identifier *define (tree_constant *t); void define_from_arg_vector (const Octave_object& args, int nargin);
--- a/src/tc-rep.cc +++ b/src/tc-rep.cc @@ -38,6 +38,7 @@ #include "mx-base.h" #include "Range.h" +#include "arith-ops.h" #include "variables.h" #include "error.h" #include "gripes.h" @@ -5098,7 +5099,7 @@ } break; default: - ::error ("illegal number of arguments for scalar type"); + ::error ("invalid number of arguments for scalar type"); return tree_constant (); break; }