changeset 4965:c0d8e8afa82f

[project @ 2004-09-06 20:19:57 by jwe]
author jwe
date Mon, 06 Sep 2004 20:19:57 +0000
parents 269c3d6c0569
children 91b61d27b9b4
files src/ChangeLog src/OPERATORS/op-b-b.cc src/OPERATORS/op-bm-bm.cc src/OPERATORS/op-cm-cm.cc src/OPERATORS/op-cs-cs.cc src/OPERATORS/op-int.h src/OPERATORS/op-m-m.cc src/OPERATORS/op-range.cc src/OPERATORS/op-s-s.cc src/ov.cc src/ov.h src/parse.y src/version.h
diffstat 13 files changed, 60 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/ChangeLog	Mon Sep 06 20:19:57 2004 +0000
@@ -1,3 +1,20 @@
+2004-09-06  John W. Eaton  <jwe@octave.org>
+
+	* 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  <jwe@octave.org>
 
 	* OPERATORS/op-b-bm.cc (DEFCONV): Define bool scalar to bool
--- a/src/OPERATORS/op-b-b.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-b-b.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -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);
 
--- a/src/OPERATORS/op-bm-bm.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-bm-bm.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -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);
 
--- a/src/OPERATORS/op-cm-cm.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-cm-cm.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -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);
--- a/src/OPERATORS/op-cs-cs.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-cs-cs.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -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);
--- a/src/OPERATORS/op-int.h	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-int.h	Mon Sep 06 20:19:57 2004 +0000
@@ -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); \
--- a/src/OPERATORS/op-m-m.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-m-m.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -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);
--- a/src/OPERATORS/op-range.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-range.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -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);
--- a/src/OPERATORS/op-s-s.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/OPERATORS/op-s-s.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -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 */)
--- a/src/ov.cc	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/ov.cc	Mon Sep 06 20:19:57 2004 +0000
@@ -134,6 +134,10 @@
       retval = "!";
       break;
 
+    case op_uplus:
+      retval = "+";
+      break;
+
     case op_uminus:
       retval = "-";
       break;
--- a/src/ov.h	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/ov.h	Mon Sep 06 20:19:57 2004 +0000
@@ -100,6 +100,7 @@
   enum unary_op
   {
     op_not,
+    op_uplus,
     op_uminus,
     op_transpose,
     op_hermitian,
--- a/src/parse.y	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/parse.y	Mon Sep 06 20:19:57 2004 +0000
@@ -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;
--- a/src/version.h	Sat Sep 04 01:16:28 2004 +0000
+++ b/src/version.h	Mon Sep 06 20:19:57 2004 +0000
@@ -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."