Mercurial > hg > octave-nkf
diff src/tc-rep.cc @ 506:0f388340e607
[project @ 1994-07-09 06:10:34 by jwe]
author | jwe |
---|---|
date | Sat, 09 Jul 1994 06:10:34 +0000 |
parents | be155b3d5a2f |
children | 7a3b6bb00c6e |
line wrap: on
line diff
--- a/src/tc-rep.cc +++ b/src/tc-rep.cc @@ -1316,7 +1316,7 @@ } tree_constant -tree_constant_rep::do_index (const Octave_object& args, int nargin) +tree_constant_rep::do_index (const Octave_object& args) { tree_constant retval; @@ -1333,15 +1333,15 @@ { case complex_scalar_constant: case scalar_constant: - retval = do_scalar_index (args, nargin); + retval = do_scalar_index (args); break; case complex_matrix_constant: case matrix_constant: - retval = do_matrix_index (args, nargin); + retval = do_matrix_index (args); break; case string_constant: gripe_string_invalid (); -// retval = do_string_index (args, nargin); +// retval = do_string_index (args); break; case magic_colon: case range_constant: @@ -1349,7 +1349,7 @@ // range indexing functions. force_numeric (); assert (type_tag != magic_colon && type_tag != range_constant); - retval = do_index (args, nargin); + retval = do_index (args); break; default: panic_impossible (); @@ -2656,8 +2656,7 @@ * hand off to other functions to do the real work. */ void -tree_constant_rep::assign (tree_constant& rhs, - const Octave_object& args, int nargs) +tree_constant_rep::assign (tree_constant& rhs, const Octave_object& args) { tree_constant rhs_tmp = rhs.make_numeric (); @@ -2674,11 +2673,11 @@ case complex_scalar_constant: case scalar_constant: case unknown_constant: - do_scalar_assignment (rhs_tmp, args, nargs); + do_scalar_assignment (rhs_tmp, args); break; case complex_matrix_constant: case matrix_constant: - do_matrix_assignment (rhs_tmp, args, nargs); + do_matrix_assignment (rhs_tmp, args); break; case string_constant: ::error ("invalid assignment to string type"); @@ -2697,14 +2696,16 @@ */ void tree_constant_rep::do_scalar_assignment (tree_constant& rhs, - const Octave_object& args, int nargs) + const Octave_object& args) { assert (type_tag == unknown_constant || type_tag == scalar_constant || type_tag == complex_scalar_constant); + int nargin = args.length (); + if ((rhs.is_scalar_type () || rhs.is_zero_by_zero ()) - && valid_scalar_indices (args, nargs)) + && valid_scalar_indices (args)) { if (rhs.is_zero_by_zero ()) { @@ -2773,7 +2774,7 @@ // destroy the current value. tree_constant_rep::eval(int) will take // care of converting single element matrices back to scalars. - do_matrix_assignment (rhs, args, nargs); + do_matrix_assignment (rhs, args); // I don't think there's any other way to revert back to unknown // constant types, so here it is. @@ -2788,7 +2789,7 @@ type_tag = unknown_constant; } } - else if (nargs > 3 || nargs < 2) + else if (nargin > 3 || nargin < 2) ::error ("invalid index expression for scalar type"); else ::error ("index invalid or out of range for scalar type"); @@ -2802,7 +2803,7 @@ */ void tree_constant_rep::do_matrix_assignment (tree_constant& rhs, - const Octave_object& args, int nargs) + const Octave_object& args) { assert (type_tag == unknown_constant || type_tag == matrix_constant @@ -2829,9 +2830,11 @@ } } + int nargin = args.length (); + // The do_matrix_assignment functions can't handle empty matrices, so // don't let any pass through here. - switch (nargs) + switch (nargin) { case 2: if (args.length () <= 0) @@ -5001,10 +5004,9 @@ } tree_constant -tree_constant_rep::do_scalar_index (const Octave_object& args, - int nargs) const +tree_constant_rep::do_scalar_index (const Octave_object& args) const { - if (valid_scalar_indices (args, nargs)) + if (valid_scalar_indices (args)) { if (type_tag == scalar_constant) return tree_constant (scalar); @@ -5018,7 +5020,9 @@ int rows = 0; int cols = 0; - switch (nargs) + int nargin = args.length (); + + switch (nargin) { case 3: { @@ -5110,11 +5114,12 @@ } tree_constant -tree_constant_rep::do_matrix_index (const Octave_object& args, - int nargin) const +tree_constant_rep::do_matrix_index (const Octave_object& args) const { tree_constant retval; + int nargin = args.length (); + switch (nargin) { case 2: