# HG changeset patch # User jwe # Date 1094501997 0 # Node ID c0d8e8afa82fb3e94e51571c6a76d363151c9134 # Parent 269c3d6c0569f4e1ad9903a9adf903c93efd92d7 [project @ 2004-09-06 20:19:57 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2004-09-06 John W. Eaton + + * version.h (OCTAVE_API_VERSION): Now api-v10. + + * OPERATORS/op-b-b.cc, OPERATORS/op-bm-bm.cc: Define and install + unary plus and unary minus operators. + + * OPERATORS/op-int.h, OPERATORS/op-cm-cm.cc, + OPERATORS/op-cs-cs.cc, OPERATORS/op-m-m.cc, OPERATORS/op-range.cc: + Define and install unary plus operator. + + * ov.cc (unary_op_as_string): Handle op_uplus too. + + * parse.y (prefix_expr): Build unary plus op here instead of + converting to no-op. + (make_prefix_op): Accept op_uplus. + 2004-09-03 John W. Eaton * OPERATORS/op-b-bm.cc (DEFCONV): Define bool scalar to bool diff --git a/src/OPERATORS/op-b-b.cc b/src/OPERATORS/op-b-b.cc --- a/src/OPERATORS/op-b-b.cc +++ b/src/OPERATORS/op-b-b.cc @@ -45,6 +45,19 @@ // scalar unary ops. DEFUNOP_OP (not, bool, !) + +UNOPDECL (uplus, a) +{ + CAST_UNOP_ARG (const octave_bool&); + return octave_value (v.double_value ()); +} + +UNOPDECL (uminus, a) +{ + CAST_UNOP_ARG (const octave_bool&); + return octave_value (- v.double_value ()); +} + DEFUNOP_OP (transpose, bool, /* no-op */) DEFUNOP_OP (hermitian, bool, /* no-op */) @@ -63,6 +76,8 @@ install_b_b_ops (void) { INSTALL_UNOP (op_not, octave_bool, not); + INSTALL_UNOP (op_uplus, octave_bool, uplus); + INSTALL_UNOP (op_uminus, octave_bool, uminus); INSTALL_UNOP (op_transpose, octave_bool, transpose); INSTALL_UNOP (op_hermitian, octave_bool, hermitian); diff --git a/src/OPERATORS/op-bm-bm.cc b/src/OPERATORS/op-bm-bm.cc --- a/src/OPERATORS/op-bm-bm.cc +++ b/src/OPERATORS/op-bm-bm.cc @@ -41,6 +41,8 @@ // unary bool matrix ops. DEFNDUNOP_OP (not, bool_matrix, bool_array, !) +DEFNDUNOP_OP (uplus, bool_matrix, array, +) +DEFNDUNOP_OP (uminus, bool_matrix, array, -) DEFUNOP (transpose, bool_matrix) { @@ -76,6 +78,8 @@ install_bm_bm_ops (void) { INSTALL_UNOP (op_not, octave_bool_matrix, not); + INSTALL_UNOP (op_uplus, octave_bool_matrix, uplus); + INSTALL_UNOP (op_uminus, octave_bool_matrix, uminus); INSTALL_UNOP (op_transpose, octave_bool_matrix, transpose); INSTALL_UNOP (op_hermitian, octave_bool_matrix, transpose); diff --git a/src/OPERATORS/op-cm-cm.cc b/src/OPERATORS/op-cm-cm.cc --- a/src/OPERATORS/op-cm-cm.cc +++ b/src/OPERATORS/op-cm-cm.cc @@ -40,6 +40,7 @@ // unary complex matrix ops. DEFNDUNOP_OP (not, complex_matrix, complex_array, !) +DEFNDUNOP_OP (uplus, complex_matrix, complex_array, /* no-op */) DEFNDUNOP_OP (uminus, complex_matrix, complex_array, -) DEFUNOP (transpose, complex_matrix) @@ -116,6 +117,7 @@ install_cm_cm_ops (void) { INSTALL_UNOP (op_not, octave_complex_matrix, not); + INSTALL_UNOP (op_uplus, octave_complex_matrix, uplus); INSTALL_UNOP (op_uminus, octave_complex_matrix, uminus); INSTALL_UNOP (op_transpose, octave_complex_matrix, transpose); INSTALL_UNOP (op_hermitian, octave_complex_matrix, hermitian); diff --git a/src/OPERATORS/op-cs-cs.cc b/src/OPERATORS/op-cs-cs.cc --- a/src/OPERATORS/op-cs-cs.cc +++ b/src/OPERATORS/op-cs-cs.cc @@ -47,6 +47,7 @@ return octave_value (v.complex_value () == 0.0); } +DEFUNOP_OP (uplus, complex, /* no-op */) DEFUNOP_OP (uminus, complex, -) DEFUNOP_OP (transpose, complex, /* no-op */) @@ -182,6 +183,7 @@ install_cs_cs_ops (void) { INSTALL_UNOP (op_not, octave_complex, not); + INSTALL_UNOP (op_uplus, octave_complex, uplus); INSTALL_UNOP (op_uminus, octave_complex, uminus); INSTALL_UNOP (op_transpose, octave_complex, transpose); INSTALL_UNOP (op_hermitian, octave_complex, hermitian); diff --git a/src/OPERATORS/op-int.h b/src/OPERATORS/op-int.h --- a/src/OPERATORS/op-int.h +++ b/src/OPERATORS/op-int.h @@ -38,6 +38,7 @@ /* scalar unary ops. */ \ \ DEFUNOP_OP (s_not, TYPE ## _scalar, !) \ + DEFUNOP_OP (s_uplus, TYPE ## _scalar, /* no-op */) \ DEFUNOP_OP (s_uminus, TYPE ## _scalar, -) \ DEFUNOP_OP (s_transpose, TYPE ## _scalar, /* no-op */) \ DEFUNOP_OP (s_hermitian, TYPE ## _scalar, /* no-op */) \ @@ -346,6 +347,7 @@ /* matrix unary ops. */ \ \ DEFNDUNOP_OP (m_not, TYPE ## _matrix, TYPE ## _array, !) \ + DEFNDUNOP_OP (m_uplus, TYPE ## _matrix, TYPE ## _array, /* no-op */) \ DEFNDUNOP_OP (m_uminus, TYPE ## _matrix, TYPE ## _array, -) \ \ DEFUNOP (m_transpose, TYPE ## _matrix) \ @@ -473,6 +475,7 @@ #define OCTAVE_INSTALL_S_INT_UNOPS(TYPE) \ INSTALL_UNOP (op_not, octave_ ## TYPE ## _scalar, s_not); \ + INSTALL_UNOP (op_uplus, octave_ ## TYPE ## _scalar, s_uplus); \ INSTALL_UNOP (op_uminus, octave_ ## TYPE ## _scalar, s_uminus); \ INSTALL_UNOP (op_transpose, octave_ ## TYPE ## _scalar, s_transpose); \ INSTALL_UNOP (op_hermitian, octave_ ## TYPE ## _scalar, s_hermitian); \ @@ -616,6 +619,7 @@ #define OCTAVE_INSTALL_M_INT_UNOPS(TYPE) \ INSTALL_UNOP (op_not, octave_ ## TYPE ## _matrix, m_not); \ + INSTALL_UNOP (op_uplus, octave_ ## TYPE ## _matrix, m_uplus); \ INSTALL_UNOP (op_uminus, octave_ ## TYPE ## _matrix, m_uminus); \ INSTALL_UNOP (op_transpose, octave_ ## TYPE ## _matrix, m_transpose); \ INSTALL_UNOP (op_hermitian, octave_ ## TYPE ## _matrix, m_transpose); \ diff --git a/src/OPERATORS/op-m-m.cc b/src/OPERATORS/op-m-m.cc --- a/src/OPERATORS/op-m-m.cc +++ b/src/OPERATORS/op-m-m.cc @@ -40,6 +40,7 @@ // matrix unary ops. DEFNDUNOP_OP (not, matrix, array, !) +DEFNDUNOP_OP (uplus, matrix, array, /* no-op */) DEFNDUNOP_OP (uminus, matrix, array, -) DEFUNOP (transpose, matrix) @@ -103,6 +104,7 @@ install_m_m_ops (void) { INSTALL_UNOP (op_not, octave_matrix, not); + INSTALL_UNOP (op_uplus, octave_matrix, uplus); INSTALL_UNOP (op_uminus, octave_matrix, uminus); INSTALL_UNOP (op_transpose, octave_matrix, transpose); INSTALL_UNOP (op_hermitian, octave_matrix, transpose); diff --git a/src/OPERATORS/op-range.cc b/src/OPERATORS/op-range.cc --- a/src/OPERATORS/op-range.cc +++ b/src/OPERATORS/op-range.cc @@ -51,6 +51,7 @@ return octave_value (! v.matrix_value()); } +DEFUNOP_OP (uplus, range, /* no-op */) DEFUNOP_OP (uminus, range, -) DEFUNOP (transpose, range) @@ -80,6 +81,7 @@ install_range_ops (void) { INSTALL_UNOP (op_not, octave_range, not); + INSTALL_UNOP (op_uplus, octave_range, uplus); INSTALL_UNOP (op_uminus, octave_range, uminus); INSTALL_UNOP (op_transpose, octave_range, transpose); INSTALL_UNOP (op_hermitian, octave_range, transpose); diff --git a/src/OPERATORS/op-s-s.cc b/src/OPERATORS/op-s-s.cc --- a/src/OPERATORS/op-s-s.cc +++ b/src/OPERATORS/op-s-s.cc @@ -41,6 +41,7 @@ // scalar unary ops. DEFUNOP_OP (not, scalar, !) +DEFUNOP_OP (uplus, scalar, /* no-op */) DEFUNOP_OP (uminus, scalar, -) DEFUNOP_OP (transpose, scalar, /* no-op */) DEFUNOP_OP (hermitian, scalar, /* no-op */) diff --git a/src/ov.cc b/src/ov.cc --- a/src/ov.cc +++ b/src/ov.cc @@ -134,6 +134,10 @@ retval = "!"; break; + case op_uplus: + retval = "+"; + break; + case op_uminus: retval = "-"; break; diff --git a/src/ov.h b/src/ov.h --- a/src/ov.h +++ b/src/ov.h @@ -100,6 +100,7 @@ enum unary_op { op_not, + op_uplus, op_uminus, op_transpose, op_hermitian, diff --git a/src/parse.y b/src/parse.y --- a/src/parse.y +++ b/src/parse.y @@ -804,7 +804,7 @@ | EXPR_NOT prefix_expr %prec UNARY { $$ = make_prefix_op (EXPR_NOT, $2, $1); } | '+' prefix_expr %prec UNARY - { $$ = $2; } + { $$ = make_prefix_op ('+', $2, $1); } | '-' prefix_expr %prec UNARY { $$ = make_prefix_op ('-', $2, $1); } ; @@ -2217,6 +2217,10 @@ t = octave_value::op_not; break; + case '+': + t = octave_value::op_uplus; + break; + case '-': t = octave_value::op_uminus; break; diff --git a/src/version.h b/src/version.h --- a/src/version.h +++ b/src/version.h @@ -25,7 +25,7 @@ #define OCTAVE_VERSION "2.1.58" -#define OCTAVE_API_VERSION "api-v9" +#define OCTAVE_API_VERSION "api-v10" #define OCTAVE_COPYRIGHT \ "Copyright (C) 2004 John W. Eaton."