Mercurial > hg > octave-lyh
changeset 777:a2f9d3fd720c
[project @ 1994-10-07 14:01:53 by jwe]
author | jwe |
---|---|
date | Fri, 07 Oct 1994 14:13:44 +0000 |
parents | f19fb97286c6 |
children | 8b6b3e613ce1 |
files | src/arith-ops.cc src/data.cc src/find.cc src/gripes.cc src/gripes.h src/lex.l src/load-save.cc src/minmax.cc src/oct-hist.cc src/octave.cc src/pager.cc src/parse.y src/pt-const.cc src/pt-const.h src/pt-exp-base.cc src/pt-exp-base.h src/pt-plot.cc src/rand.cc src/sort.cc src/tc-rep-ass.cc src/tc-rep-idx.cc src/tc-rep.cc src/tc-rep.h src/unwind-prot.cc |
diffstat | 24 files changed, 816 insertions(+), 201 deletions(-) [+] |
line wrap: on
line diff
--- a/src/arith-ops.cc +++ b/src/arith-ops.cc @@ -235,27 +235,35 @@ case Matrix_LT: t.elem (i,j) = s < a.elem (i,j); break; + case Matrix_LE: t.elem (i,j) = s <= a.elem (i,j); break; + case Matrix_EQ: t.elem (i,j) = s == a.elem (i,j); break; + case Matrix_GE: t.elem (i,j) = s >= a.elem (i,j); break; + case Matrix_GT: t.elem (i,j) = s > a.elem (i,j); break; + case Matrix_NE: t.elem (i,j) = s != a.elem (i,j); break; + case Matrix_AND: t.elem (i,j) = s && a.elem (i,j); break; + case Matrix_OR: t.elem (i,j) = s || a.elem (i,j); break; + default: panic_impossible (); break; @@ -290,27 +298,35 @@ case Matrix_LT: t.elem (i,j) = s < real (a.elem (i,j)); break; + case Matrix_LE: t.elem (i,j) = s <= real (a.elem (i,j)); break; + case Matrix_EQ: t.elem (i,j) = s == a.elem (i,j); break; + case Matrix_GE: t.elem (i,j) = s >= real (a.elem (i,j)); break; + case Matrix_GT: t.elem (i,j) = s > real (a.elem (i,j)); break; + case Matrix_NE: t.elem (i,j) = s != a.elem (i,j); break; + case Matrix_AND: t.elem (i,j) = s && (a.elem (i,j) != 0.0); break; + case Matrix_OR: t.elem (i,j) = s || (a.elem (i,j) != 0.0); break; + default: panic_impossible (); break; @@ -345,27 +361,35 @@ case Matrix_LT: t.elem (i,j) = a.elem (i,j) < s; break; + case Matrix_LE: t.elem (i,j) = a.elem (i,j) <= s; break; + case Matrix_EQ: t.elem (i,j) = a.elem (i,j) == s; break; + case Matrix_GE: t.elem (i,j) = a.elem (i,j) >= s; break; + case Matrix_GT: t.elem (i,j) = a.elem (i,j) > s; break; + case Matrix_NE: t.elem (i,j) = a.elem (i,j) != s; break; + case Matrix_AND: t.elem (i,j) = a.elem (i,j) && s; break; + case Matrix_OR: t.elem (i,j) = a.elem (i,j) || s; break; + default: panic_impossible (); break; @@ -400,27 +424,35 @@ case Matrix_LT: t.elem (i,j) = a.elem (i,j) < real (s); break; + case Matrix_LE: t.elem (i,j) = a.elem (i,j) <= real (s); break; + case Matrix_EQ: t.elem (i,j) = a.elem (i,j) == s; break; + case Matrix_GE: t.elem (i,j) = a.elem (i,j) >= real (s); break; + case Matrix_GT: t.elem (i,j) = a.elem (i,j) > real (s); break; + case Matrix_NE: t.elem (i,j) = a.elem (i,j) != s; break; + case Matrix_AND: t.elem (i,j) = a.elem (i,j) && (s != 0.0); break; + case Matrix_OR: t.elem (i,j) = a.elem (i,j) || (s != 0.0); break; + default: panic_impossible (); break; @@ -458,27 +490,35 @@ case Matrix_LT: c.elem (i, j) = a.elem (i, j) < b.elem (i, j); break; + case Matrix_LE: c.elem (i, j) = a.elem (i, j) <= b.elem (i, j); break; + case Matrix_EQ: c.elem (i, j) = a.elem (i, j) == b.elem (i, j); break; + case Matrix_GE: c.elem (i, j) = a.elem (i, j) >= b.elem (i, j); break; + case Matrix_GT: c.elem (i, j) = a.elem (i, j) > b.elem (i, j); break; + case Matrix_NE: c.elem (i, j) = a.elem (i, j) != b.elem (i, j); break; + case Matrix_AND: c.elem (i, j) = a.elem (i, j) && b.elem (i, j); break; + case Matrix_OR: c.elem (i, j) = a.elem (i, j) || b.elem (i, j); break; + default: panic_impossible (); break; @@ -516,27 +556,35 @@ case Matrix_LT: c.elem (i, j) = a.elem (i, j) < real (b.elem (i, j)); break; + case Matrix_LE: c.elem (i, j) = a.elem (i, j) <= real (b.elem (i, j)); break; + case Matrix_EQ: c.elem (i, j) = a.elem (i, j) == b.elem (i, j); break; + case Matrix_GE: c.elem (i, j) = a.elem (i, j) >= real (b.elem (i, j)); break; + case Matrix_GT: c.elem (i, j) = a.elem (i, j) > real (b.elem (i, j)); break; + case Matrix_NE: c.elem (i, j) = a.elem (i, j) != b.elem (i, j); break; + case Matrix_AND: c.elem (i, j) = a.elem (i, j) && (b.elem (i, j) != 0.0); break; + case Matrix_OR: c.elem (i, j) = a.elem (i, j) || (b.elem (i, j) != 0.0); break; + default: panic_impossible (); break; @@ -570,27 +618,35 @@ case Matrix_LT: t.elem (i,j) = real (s) < a.elem (i,j); break; + case Matrix_LE: t.elem (i,j) = real (s) <= a.elem (i,j); break; + case Matrix_EQ: t.elem (i,j) = s == a.elem (i,j); break; + case Matrix_GE: t.elem (i,j) = real (s) >= a.elem (i,j); break; + case Matrix_GT: t.elem (i,j) = real (s) > a.elem (i,j); break; + case Matrix_NE: t.elem (i,j) = s != a.elem (i,j); break; + case Matrix_AND: t.elem (i,j) = (s != 0.0) && a.elem (i,j); break; + case Matrix_OR: t.elem (i,j) = (s != 0.0) || a.elem (i,j); break; + default: panic_impossible (); break; @@ -625,27 +681,35 @@ case Matrix_LT: t.elem (i,j) = real (s) < real (a.elem (i,j)); break; + case Matrix_LE: t.elem (i,j) = real (s) <= real (a.elem (i,j)); break; + case Matrix_EQ: t.elem (i,j) = s == a.elem (i,j); break; + case Matrix_GE: t.elem (i,j) = real (s) >= real (a.elem (i,j)); break; + case Matrix_GT: t.elem (i,j) = real (s) > real (a.elem (i,j)); break; + case Matrix_NE: t.elem (i,j) = s != a.elem (i,j); break; + case Matrix_AND: t.elem (i,j) = (s != 0.0) && (a.elem (i,j) != 0.0); break; + case Matrix_OR: t.elem (i,j) = (s != 0.0) || (a.elem (i,j) != 0.0); break; + default: panic_impossible (); break; @@ -680,27 +744,35 @@ case Matrix_LT: t.elem (i,j) = real (a.elem (i,j)) < s; break; + case Matrix_LE: t.elem (i,j) = real (a.elem (i,j)) <= s; break; + case Matrix_EQ: t.elem (i,j) = a.elem (i,j) == s; break; + case Matrix_GE: t.elem (i,j) = real (a.elem (i,j)) >= s; break; + case Matrix_GT: t.elem (i,j) = real (a.elem (i,j)) > s; break; + case Matrix_NE: t.elem (i,j) = a.elem (i,j) != s; break; + case Matrix_AND: t.elem (i,j) = (a.elem (i,j) != 0.0) && s; break; + case Matrix_OR: t.elem (i,j) = (a.elem (i,j) != 0.0) || s; break; + default: panic_impossible (); break; @@ -735,27 +807,35 @@ case Matrix_LT: t.elem (i,j) = real (a.elem (i,j)) < real (s); break; + case Matrix_LE: t.elem (i,j) = real (a.elem (i,j)) <= real (s); break; + case Matrix_EQ: t.elem (i,j) = a.elem (i,j) == s; break; + case Matrix_GE: t.elem (i,j) = real (a.elem (i,j)) >= real (s); break; + case Matrix_GT: t.elem (i,j) = real (a.elem (i,j)) > real (s); break; + case Matrix_NE: t.elem (i,j) = a.elem (i,j) != s; break; + case Matrix_AND: t.elem (i,j) = (a.elem (i,j) != 0.0) && (s != 0.0); break; + case Matrix_OR: t.elem (i,j) = (a.elem (i,j) != 0.0) || (s != 0.0); break; + default: panic_impossible (); break; @@ -793,27 +873,35 @@ case Matrix_LT: c.elem (i, j) = real (a.elem (i, j)) < b.elem (i, j); break; + case Matrix_LE: c.elem (i, j) = real (a.elem (i, j)) <= b.elem (i, j); break; + case Matrix_EQ: c.elem (i, j) = a.elem (i, j) == b.elem (i, j); break; + case Matrix_GE: c.elem (i, j) = real (a.elem (i, j)) >= b.elem (i, j); break; + case Matrix_GT: c.elem (i, j) = real (a.elem (i, j)) > b.elem (i, j); break; + case Matrix_NE: c.elem (i, j) = a.elem (i, j) != b.elem (i, j); break; + case Matrix_AND: c.elem (i, j) = (a.elem (i, j) != 0.0) && b.elem (i, j); break; + case Matrix_OR: c.elem (i, j) = (a.elem (i, j) != 0.0) || b.elem (i, j); break; + default: panic_impossible (); break; @@ -851,27 +939,35 @@ case Matrix_LT: c.elem (i, j) = real (a.elem (i, j)) < real (b.elem (i, j)); break; + case Matrix_LE: c.elem (i, j) = real (a.elem (i, j)) <= real (b.elem (i, j)); break; + case Matrix_EQ: c.elem (i, j) = a.elem (i, j) == b.elem (i, j); break; + case Matrix_GE: c.elem (i, j) = real (a.elem (i, j)) >= real (b.elem (i, j)); break; + case Matrix_GT: c.elem (i, j) = real (a.elem (i, j)) > real (b.elem (i, j)); break; + case Matrix_NE: c.elem (i, j) = a.elem (i, j) != b.elem (i, j); break; + case Matrix_AND: c.elem (i, j) = (a.elem (i, j) != 0.0) && (b.elem (i, j) != 0.0); break; + case Matrix_OR: c.elem (i, j) = (a.elem (i, j) != 0.0) || (b.elem (i, j) != 0.0); break; + default: panic_impossible (); break; @@ -898,13 +994,16 @@ case tree_expression::not: result = (! d); break; + case tree_expression::uminus: result = -d; break; + case tree_expression::hermitian: case tree_expression::transpose: result = d; break; + default: panic_impossible (); break; @@ -923,13 +1022,16 @@ case tree_expression::not: result = (! a); break; + case tree_expression::uminus: result = -a; break; + case tree_expression::hermitian: case tree_expression::transpose: result = a.transpose (); break; + default: panic_impossible (); break; @@ -948,15 +1050,19 @@ case tree_expression::not: result = (c == 0.0); break; + case tree_expression::uminus: result = -c; break; + case tree_expression::hermitian: result = conj (c); break; + case tree_expression::transpose: result = c; break; + default: panic_impossible (); break; @@ -975,15 +1081,19 @@ case tree_expression::not: result = (! a); break; + case tree_expression::uminus: result = -a; break; + case tree_expression::hermitian: result = a.hermitian (); break; + case tree_expression::transpose: result = a.transpose (); break; + default: panic_impossible (); break; @@ -1017,53 +1127,67 @@ case tree_expression::add: result = a + b; break; + case tree_expression::subtract: result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: if (b == 0.0) DIVIDE_BY_ZERO_ERROR; result = a / b; break; + case tree_expression::leftdiv: case tree_expression::el_leftdiv: if (a == 0.0) DIVIDE_BY_ZERO_ERROR; result = b / a; break; + case tree_expression::power: case tree_expression::elem_pow: return xpow (a, b); break; + case tree_expression::cmp_lt: result = a < b; break; + case tree_expression::cmp_le: result = a <= b; break; + case tree_expression::cmp_eq: result = a == b; break; + case tree_expression::cmp_ge: result = a >= b; break; + case tree_expression::cmp_gt: result = a > b; break; + case tree_expression::cmp_ne: result = a != b; break; + case tree_expression::and: result = (a && b); break; + case tree_expression::or: result = (a || b); break; + default: panic_impossible (); break; @@ -1086,55 +1210,71 @@ case tree_expression::add: result = a + b; break; + case tree_expression::subtract: result = a - b; break; + case tree_expression::el_leftdiv: case tree_expression::leftdiv: if (a == 0.0) DIVIDE_BY_ZERO_ERROR; a = 1.0 / a; // fall through... + case tree_expression::multiply: case tree_expression::el_mul: result = a * b; break; + case tree_expression::el_div: return x_el_div (a, b); break; + case tree_expression::divide: gripe_nonconformant (1, 1, b.rows (), b.columns ()); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -1162,15 +1302,18 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: result_type = RT_complex; @@ -1178,6 +1321,7 @@ DIVIDE_BY_ZERO_ERROR; complex_result = a / b; break; + case tree_expression::leftdiv: case tree_expression::el_leftdiv: result_type = RT_complex; @@ -1185,42 +1329,52 @@ DIVIDE_BY_ZERO_ERROR; complex_result = b / a; break; + case tree_expression::power: case tree_expression::elem_pow: return xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = a < real (b); break; + case tree_expression::cmp_le: result_type = RT_real; result = a <= real (b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = a == b; break; + case tree_expression::cmp_ge: result_type = RT_real; result = a >= real (b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = a > real (b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = a != b; break; + case tree_expression::and: result_type = RT_real; result = (a && (b != 0.0)); break; + case tree_expression::or: result_type = RT_real; result = (a || (b != 0.0)); break; + default: panic_impossible (); break; @@ -1253,65 +1407,81 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::el_leftdiv: case tree_expression::leftdiv: if (a == 0.0) DIVIDE_BY_ZERO_ERROR; a = 1.0 / a; // fall through... + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::el_div: return x_el_div (a, b); break; + case tree_expression::divide: gripe_nonconformant (1, 1, b.rows (), b.columns ()); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -1339,53 +1509,69 @@ case tree_expression::add: result = a + b; break; + case tree_expression::subtract: result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: result = a / b; break; + case tree_expression::el_leftdiv: return x_el_div (b, a); break; + case tree_expression::leftdiv: gripe_nonconformant (a.rows (), a.columns (), 1, 1); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -1409,71 +1595,89 @@ if (m_add_conform (a, b, 1)) result = a + b; break; + case tree_expression::subtract: if (m_add_conform (a, b, 1)) result = a - b; break; + case tree_expression::el_mul: if (m_add_conform (a, b, 1)) result = product (a, b); break; + case tree_expression::multiply: if (m_mul_conform (a, b, 1)) result = a * b; break; + case tree_expression::el_div: if (m_add_conform (a, b, 1)) result = quotient (a, b); break; + case tree_expression::el_leftdiv: if (m_add_conform (a, b, 1)) result = quotient (b, a); break; + case tree_expression::leftdiv: return xleftdiv (a, b); break; + case tree_expression::divide: return xdiv (a, b); break; + case tree_expression::power: error ("can't do A ^ B for A and B both matrices"); break; + case tree_expression::elem_pow: if (m_add_conform (a, b, 1)) return elem_xpow (a, b); break; + case tree_expression::cmp_lt: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -1501,64 +1705,80 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: result_type = RT_complex; complex_result = a / b; break; + case tree_expression::el_leftdiv: return x_el_div (b, a); break; + case tree_expression::leftdiv: gripe_nonconformant (a.rows (), a.columns (), 1, 1); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -1592,84 +1812,102 @@ if (m_add_conform (a, b, 1)) complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = a - b; break; + case tree_expression::el_mul: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = product (a, b); break; + case tree_expression::multiply: result_type = RT_complex; if (m_mul_conform (a, b, 1)) complex_result = a * b; break; + case tree_expression::el_div: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = quotient (a, b); break; + case tree_expression::el_leftdiv: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = quotient (b, a); break; + case tree_expression::leftdiv: return xleftdiv (a, b); break; + case tree_expression::divide: return xdiv (a, b); break; + case tree_expression::power: error ("can't do A ^ B for A and B both matrices"); break; + case tree_expression::elem_pow: if (m_add_conform (a, b, 1)) return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -1702,15 +1940,18 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: result_type = RT_complex; @@ -1718,6 +1959,7 @@ DIVIDE_BY_ZERO_ERROR; complex_result = a / b; break; + case tree_expression::leftdiv: case tree_expression::el_leftdiv: result_type = RT_complex; @@ -1725,42 +1967,52 @@ DIVIDE_BY_ZERO_ERROR; complex_result = b / a; break; + case tree_expression::power: case tree_expression::elem_pow: return xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = real (a) < b; break; + case tree_expression::cmp_le: result_type = RT_real; result = real (a) <= b; break; + case tree_expression::cmp_eq: result_type = RT_real; result = a == b; break; + case tree_expression::cmp_ge: result_type = RT_real; result = real (a) >= b; break; + case tree_expression::cmp_gt: result_type = RT_real; result = real (a) > b; break; + case tree_expression::cmp_ne: result_type = RT_real; result = a != b; break; + case tree_expression::and: result_type = RT_real; result = ((a != 0.0) && b); break; + case tree_expression::or: result_type = RT_real; result = ((a != 0.0) || b); break; + default: panic_impossible (); break; @@ -1793,10 +2045,12 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::el_leftdiv: case tree_expression::leftdiv: if (a == 0.0) @@ -1804,55 +2058,69 @@ result_type = RT_complex; complex_result = b / a; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::el_div: return x_el_div (a, b); break; + case tree_expression::divide: gripe_nonconformant (1, 1, b.rows (), b.columns ()); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -1885,15 +2153,18 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: result_type = RT_complex; @@ -1901,6 +2172,7 @@ DIVIDE_BY_ZERO_ERROR; complex_result = a / b; break; + case tree_expression::leftdiv: case tree_expression::el_leftdiv: result_type = RT_complex; @@ -1908,42 +2180,52 @@ DIVIDE_BY_ZERO_ERROR; complex_result = b / a; break; + case tree_expression::power: case tree_expression::elem_pow: return xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = real (a) < real (b); break; + case tree_expression::cmp_le: result_type = RT_real; result = real (a) <= real (b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = a == b; break; + case tree_expression::cmp_ge: result_type = RT_real; result = real (a) >= real (b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = real (a) > real (b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = a != b; break; + case tree_expression::and: result_type = RT_real; result = ((a != 0.0) && (b != 0.0)); break; + case tree_expression::or: result_type = RT_real; result = ((a != 0.0) || (b != 0.0)); break; + default: panic_impossible (); break; @@ -1977,10 +2259,12 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::el_leftdiv: case tree_expression::leftdiv: if (a == 0.0) @@ -1988,55 +2272,69 @@ result_type = RT_complex; complex_result = b / a; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::el_div: return x_el_div (a, b); break; + case tree_expression::divide: gripe_nonconformant (1, 1, b.rows (), b.columns ()); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -2069,64 +2367,80 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: result_type = RT_complex; complex_result = a / b; break; + case tree_expression::el_leftdiv: return x_el_div (b, a); break; + case tree_expression::leftdiv: gripe_nonconformant (a.rows (), a.columns (), 1, 1); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -2160,84 +2474,102 @@ if (m_add_conform (a, b, 1)) complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = a - b; break; + case tree_expression::el_mul: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = product (a, b); break; + case tree_expression::multiply: result_type = RT_complex; if (m_mul_conform (a, b, 1)) complex_result = a * b; break; + case tree_expression::el_div: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = quotient (a, b); break; + case tree_expression::el_leftdiv: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = quotient (b, a); break; + case tree_expression::leftdiv: return xleftdiv (a, b); break; + case tree_expression::divide: return xdiv (a, b); break; + case tree_expression::power: error ("can't do A ^ B for A and B both matrices"); break; + case tree_expression::elem_pow: if (m_add_conform (a, b, 1)) return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -2271,64 +2603,80 @@ result_type = RT_complex; complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; complex_result = a - b; break; + case tree_expression::multiply: case tree_expression::el_mul: result_type = RT_complex; complex_result = a * b; break; + case tree_expression::divide: case tree_expression::el_div: result_type = RT_complex; complex_result = a / b; break; + case tree_expression::el_leftdiv: return x_el_div (b, a); break; + case tree_expression::leftdiv: gripe_nonconformant (a.rows (), a.columns (), 1, 1); break; + case tree_expression::power: return xpow (a, b); break; + case tree_expression::elem_pow: return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break; @@ -2363,84 +2711,102 @@ if (m_add_conform (a, b, 1)) complex_result = a + b; break; + case tree_expression::subtract: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = a - b; break; + case tree_expression::el_mul: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = product (a, b); break; + case tree_expression::multiply: result_type = RT_complex; if (m_mul_conform (a, b, 1)) complex_result = a * b; break; + case tree_expression::el_div: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = quotient (a, b); break; + case tree_expression::el_leftdiv: result_type = RT_complex; if (m_add_conform (a, b, 1)) complex_result = quotient (b, a); break; + case tree_expression::leftdiv: return xleftdiv (a, b); break; + case tree_expression::divide: return xdiv (a, b); break; + case tree_expression::power: error ("can't do A ^ B for A and B both matrices"); break; + case tree_expression::elem_pow: if (m_add_conform (a, b, 1)) return elem_xpow (a, b); break; + case tree_expression::cmp_lt: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LT, a, b); break; + case tree_expression::cmp_le: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_LE, a, b); break; + case tree_expression::cmp_eq: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_EQ, a, b); break; + case tree_expression::cmp_ge: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GE, a, b); break; + case tree_expression::cmp_gt: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_GT, a, b); break; + case tree_expression::cmp_ne: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_NE, a, b); break; + case tree_expression::and: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_AND, a, b); break; + case tree_expression::or: result_type = RT_real; if (m_add_conform (a, b, 1)) result = mx_stupid_bool_op (Matrix_OR, a, b); break; + default: panic_impossible (); break;
--- a/src/data.cc +++ b/src/data.cc @@ -38,6 +38,7 @@ #include "help.h" #include "utils.h" #include "error.h" +#include "gripes.h" #include "defun.h" #ifndef MIN @@ -828,12 +829,15 @@ case 0: retval = 1.0; break; + case 1: retval = fill_matrix (args(0), 1.0, "ones"); break; + case 2: retval = fill_matrix (args(0), args(1), 1.0, "ones"); break; + default: print_usage ("ones"); break; @@ -854,12 +858,15 @@ case 0: retval = 0.0; break; + case 1: retval = fill_matrix (args(0), 0.0, "zeros"); break; + case 2: retval = fill_matrix (args(0), args(1), 0.0, "zeros"); break; + default: print_usage ("zeros"); break; @@ -922,12 +929,15 @@ case 0: retval = 1.0; break; + case 1: retval = identity_matrix (args(0)); break; + case 2: retval = identity_matrix (args(0), args(1)); break; + default: print_usage ("eye"); break;
--- a/src/find.cc +++ b/src/find.cc @@ -27,6 +27,7 @@ #include "tree-const.h" #include "error.h" +$include "gripes.h" #include "help.h" #include "defun-dld.h"
--- a/src/gripes.cc +++ b/src/gripes.cc @@ -25,6 +25,7 @@ #include "config.h" #endif +#include "tree-const.h" #include "gripes.h" #include "error.h" @@ -86,6 +87,48 @@ error ("invalid conversion from %s to %s", from, to); } +void +gripe_2_or_3_dim_plot (void) +{ + error ("plot: can only plot in 2 or 3 dimensions"); +} + +void +gripe_unrecognized_float_fmt (void) +{ + error ("unrecognized floating point format requested"); +} + +void +gripe_unrecognized_data_fmt (const char *warn_for) +{ + error ("%s: unrecognized data format requested", warn_for); +} + +void +gripe_data_conversion (const char *from, const char *to) +{ + error ("unable to convert from %s to %s format", from, to); +} + +void +gripe_wrong_type_arg (const char *name, const tree_constant& tc) +{ + error ("%s: wrong type argument `%s'", name, tc.type_as_string ()); +} + +void +gripe_wrong_type_arg_for_unary_op (const tree_constant& op) +{ + error ("invalid operand `%s' for unary operator", op.type_as_string ()); +} + +void +gripe_wrong_type_arg_for_binary_op (const tree_constant& op) +{ + error ("invalid operand `%s' for binary operator", op.type_as_string ()); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/src/gripes.h +++ b/src/gripes.h @@ -35,6 +35,13 @@ extern void gripe_user_supplied_eval (const char *name); extern void gripe_user_returned_invalid (const char *name); extern void gripe_invalid_conversion (const char *from, const char *to); +extern void gripe_2_or_3_dim_plot (void); +extern void gripe_unrecognized_float_fmt (void); +extern void gripe_unrecognized_data_fmt (const char *warn_for); +extern void gripe_data_conversion (const char *from, const char *to); +extern void gripe_wrong_type_arg (const char *name, const tree_constant& tc); +extern void gripe_wrong_type_arg_for_unary_op (const tree_constant& op); +extern void gripe_wrong_type_arg_for_binary_op (const tree_constant& op); #endif
--- a/src/lex.l +++ b/src/lex.l @@ -726,36 +726,46 @@ case 'a': *p1 = '\a'; break; + case 'b': // backspace *p1 = '\b'; break; + case 'f': // formfeed *p1 = '\f'; break; + case 'n': // newline *p1 = '\n'; break; + case 'r': // carriage return *p1 = '\r'; break; + case 't': // horizontal tab *p1 = '\t'; break; + case 'v': // vertical tab *p1 = '\v'; break; + case '\\': // backslash *p1 = '\\'; break; + case '\'': // quote *p1 = '\''; break; + case '"': // double quote *p1 = '"'; break; + default: - warning ("unrecognized escape sequence `\\%c' -- converting to `%c'", - *p2, *p2); + warning ("unrecognized escape sequence `\\%c' --\ + converting to `%c'", *p2, *p2); *p1 = *p2; break; } @@ -1137,9 +1147,12 @@ case '%': case '#': in_comment = 1; + break; + case ' ': case '\t': break; + default: goto done; } @@ -1235,8 +1248,12 @@ switch (c0) { - case '+': case '-': case '/': - case ':': case '\\': case '^': + case '+': + case '-': + case '/': + case ':': + case '\\': + case '^': spc_next = (c1 == ' ' || c1 == '\t'); break; @@ -1275,7 +1292,9 @@ spc_next = (c1 == ' ' || c1 == '\t'); break; - case '~': case '!': case '=': + case '~': + case '!': + case '=': if (c1 == '=') spc_next = next_char_is_space (); else @@ -1492,14 +1511,17 @@ case ';': case ',': break; + case '\n': if (in_comment) in_comment = 0; break; + case '%': case '#': in_comment = 1; break; + default: if (in_comment) break;
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -42,6 +42,7 @@ #include "symtab.h" #include "pager.h" #include "error.h" +#include "gripes.h" #include "defun.h" #include "utils.h" #include "help.h"
--- a/src/minmax.cc +++ b/src/minmax.cc @@ -29,6 +29,7 @@ #include "tree-const.h" #include "error.h" +#include "gripes.h" #include "help.h" #include "defun-dld.h" @@ -164,9 +165,11 @@ case 2: arg2 = args(1); // Fall through... + case 1: arg1 = args(0); break; + default: panic_impossible (); break; @@ -339,9 +342,11 @@ case 2: arg2 = args(1); // Fall through... + case 1: arg1 = args(0); break; + default: panic_impossible (); break;
--- a/src/oct-hist.cc +++ b/src/oct-hist.cc @@ -208,12 +208,15 @@ } } break; + case 'w': // Write entire history. result = write_history (file); break; + case 'r': // Read entire file. result = read_history (file); break; + case 'n': // Read `new' history from file. // Read all of the lines in the file that we haven't already read. using_history ();
--- a/src/octave.cc +++ b/src/octave.cc @@ -455,33 +455,42 @@ case 'd': yydebug++; break; + case 'f': read_init_files = 0; break; + case 'h': case '?': verbose_usage (); break; + case 'i': forced_interactive = 1; break; + case 'p': if (optarg) load_path = strsave (optarg); break; + case 'q': inhibit_startup_message = 1; break; + case 'x': echo_input = 1; break; + case 'v': print_version_and_exit (); break; + case INFO_FILE_OPTION: if (optarg) info_file = strsave (optarg); break; + default: usage (); break;
--- a/src/pager.cc +++ b/src/pager.cc @@ -219,6 +219,7 @@ } } break; + default: print_usage ("diary"); break;
--- a/src/parse.y +++ b/src/parse.y @@ -1207,18 +1207,23 @@ case token::simple_end: error (fmt, type, "end", l, c); break; + case token::for_end: error (fmt, type, "endfor", l, c); break; + case token::function_end: error (fmt, type, "endfunction", l, c); break; + case token::if_end: error (fmt, type, "endif", l, c); break; + case token::while_end: error (fmt, type, "endwhile", l, c); break; + default: panic_impossible (); break; @@ -1243,15 +1248,19 @@ case token::for_end: end_error ("for", ettype, l, c); break; + case token::function_end: end_error ("function", ettype, l, c); break; + case token::if_end: end_error ("if", ettype, l, c); break; + case token::while_end: end_error ("while", ettype, l, c); break; + default: panic_impossible (); break; @@ -1328,63 +1337,83 @@ case POW: t = tree_expression::power; break; + case EPOW: t = tree_expression::elem_pow; break; + case '+': t = tree_expression::add; break; + case '-': t = tree_expression::subtract; break; + case '*': t = tree_expression::multiply; break; + case '/': t = tree_expression::divide; break; + case EMUL: t = tree_expression::el_mul; break; + case EDIV: t = tree_expression::el_div; break; + case LEFTDIV: t = tree_expression::leftdiv; break; + case ELEFTDIV: t = tree_expression::el_leftdiv; break; + case EXPR_LT: t = tree_expression::cmp_lt; break; + case EXPR_LE: t = tree_expression::cmp_le; break; + case EXPR_EQ: t = tree_expression::cmp_eq; break; + case EXPR_GE: t = tree_expression::cmp_ge; break; + case EXPR_GT: t = tree_expression::cmp_gt; break; + case EXPR_NE: t = tree_expression::cmp_ne; break; + case EXPR_AND_AND: t = tree_expression::and_and; break; + case EXPR_OR_OR: t = tree_expression::or_or; break; + case EXPR_AND: t = tree_expression::and; break; + case EXPR_OR: t = tree_expression::or; break; + default: panic_impossible (); break; @@ -1407,9 +1436,11 @@ case PLUS_PLUS: t = tree_expression::increment; break; + case MINUS_MINUS: t = tree_expression::decrement; break; + default: panic_impossible (); break; @@ -1432,9 +1463,11 @@ case PLUS_PLUS: t = tree_expression::increment; break; + case MINUS_MINUS: t = tree_expression::decrement; break; + default: panic_impossible (); break; @@ -1457,15 +1490,19 @@ case QUOTE: t = tree_expression::hermitian; break; + case TRANSPOSE: t = tree_expression::transpose; break; + case EXPR_NOT: t = tree_expression::not; break; + case '-': t = tree_expression::uminus; break; + default: panic_impossible (); break;
--- a/src/pt-const.cc +++ b/src/pt-const.cc @@ -232,12 +232,6 @@ os << ")"; } -void -gripe_wrong_type_arg (const char *name, const tree_constant& tc) -{ - error ("%s: wrong type argument `%s'", name, tc.type_as_string ()); -} - // Construct return vector of empty matrices. Return empty matrices // and/or gripe when appropriate.
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -342,10 +342,6 @@ void print_code (ostream& os); -// Complain about unknown types used as args. - - friend void gripe_wrong_type_arg (const char *name, const tree_constant& tc); - char *type_as_string (void) const { return rep->type_as_string (); }
--- a/src/pt-exp-base.cc +++ b/src/pt-exp-base.cc @@ -46,6 +46,7 @@ #include "dynamic-ld.h" #include "help.h" #include "error.h" +#include "gripes.h" #include "pager.h" #include "tree-base.h" #include "tree-expr.h" @@ -456,6 +457,7 @@ } } break; + case md_down: { if (cols_this_row != col_total) @@ -469,6 +471,7 @@ cols_this_row = nc; } break; + default: panic_impossible (); break; @@ -519,10 +522,12 @@ case md_right: put_col += prev_nc; break; + case md_down: put_row += prev_nr; put_col = 0; break; + default: panic_impossible (); break; @@ -617,9 +622,11 @@ case md_right: os << ", "; break; + case md_down: os << "; "; break; + default: break; } @@ -644,7 +651,7 @@ // A base class for objects that can be evaluated with argument lists. tree_constant -tree_fvc::assign (tree_constant& t, const Octave_object& args) +tree_fvc::assign (const tree_constant& t, const Octave_object& args) { panic_impossible (); return tree_constant (); @@ -687,7 +694,7 @@ } tree_constant -tree_identifier::assign (tree_constant& rhs) +tree_identifier::assign (const tree_constant& rhs) { tree_constant retval; @@ -718,7 +725,7 @@ } tree_constant -tree_identifier::assign (tree_constant& rhs, const Octave_object& args) +tree_identifier::assign (const tree_constant& rhs, const Octave_object& args) { tree_constant retval; @@ -765,7 +772,7 @@ } tree_constant -tree_identifier::assign (SLList<char*> list, tree_constant& rhs) +tree_identifier::assign (SLList<char*> list, const tree_constant& rhs) { tree_constant retval; @@ -797,7 +804,7 @@ } tree_constant -tree_identifier::assign (SLList<char*> list, tree_constant& rhs, +tree_identifier::assign (SLList<char*> list, const tree_constant& rhs, const Octave_object& args) { tree_constant retval; @@ -1092,7 +1099,7 @@ } tree_constant -tree_indirect_ref::assign (tree_constant& t) +tree_indirect_ref::assign (const tree_constant& t) { tree_constant retval; @@ -1105,7 +1112,7 @@ } tree_constant -tree_indirect_ref::assign (tree_constant& t, const Octave_object& args) +tree_indirect_ref::assign (const tree_constant& t, const Octave_object& args) { tree_constant retval; @@ -1379,9 +1386,17 @@ static char *op; switch (etype) { - case tree_expression::increment: op = "++"; break; - case tree_expression::decrement: op = "--"; break; - default: op = "<unknown>"; break; + case tree_expression::increment: + op = "++"; + break; + + case tree_expression::decrement: + op = "--"; + break; + + default: + op = "<unknown>"; + break; } return op; } @@ -1445,9 +1460,17 @@ static char *op; switch (etype) { - case tree_expression::increment: op = "++"; break; - case tree_expression::decrement: op = "--"; break; - default: op = "<unknown>"; break; + case tree_expression::increment: + op = "++"; + break; + + case tree_expression::decrement: + op = "--"; + break; + + default: + op = "<unknown>"; + break; } return op; } @@ -1514,6 +1537,7 @@ } } break; + default: ::error ("unary operator %d not implemented", etype); break; @@ -1528,11 +1552,25 @@ static char *op; switch (etype) { - case tree_expression::not: op = "!"; break; - case tree_expression::uminus: op = "-"; break; - case tree_expression::hermitian: op = "'"; break; - case tree_expression::transpose: op = ".'"; break; - default: op = "<unknown>"; break; + case tree_expression::not: + op = "!"; + break; + + case tree_expression::uminus: + op = "-"; + break; + + case tree_expression::hermitian: + op = "'"; + break; + + case tree_expression::transpose: + op = ".'"; + break; + + default: + op = "<unknown>"; + break; } return op; } @@ -1565,12 +1603,14 @@ if (op) op->print_code (os); break; + case tree_expression::hermitian: case tree_expression::transpose: if (op) op->print_code (os); os << oper (); break; + default: os << oper (); if (op) @@ -1635,6 +1675,7 @@ } } break; + case tree_expression::and_and: case tree_expression::or_or: { @@ -1693,6 +1734,7 @@ retval = tree_constant ((double) result); } break; + default: ::error ("binary operator %d not implemented", etype); break; @@ -1707,27 +1749,89 @@ static char *op; switch (etype) { - case tree_expression::add: op = "+"; break; - case tree_expression::subtract: op = "-"; break; - case tree_expression::multiply: op = "*"; break; - case tree_expression::el_mul: op = ".*"; break; - case tree_expression::divide: op = "/"; break; - case tree_expression::el_div: op = "./"; break; - case tree_expression::leftdiv: op = "\\"; break; - case tree_expression::el_leftdiv: op = ".\\"; break; - case tree_expression::power: op = "^"; break; - case tree_expression::elem_pow: op = ".^"; break; - case tree_expression::cmp_lt: op = "<"; break; - case tree_expression::cmp_le: op = "<="; break; - case tree_expression::cmp_eq: op = "=="; break; - case tree_expression::cmp_ge: op = ">="; break; - case tree_expression::cmp_gt: op = ">"; break; - case tree_expression::cmp_ne: op = "!="; break; - case tree_expression::and_and: op = "&&"; break; - case tree_expression::or_or: op = "||"; break; - case tree_expression::and: op = "&"; break; - case tree_expression::or: op = "|"; break; - default: op = "<unknown>"; break; + case tree_expression::add: + op = "+"; + break; + + case tree_expression::subtract: + op = "-"; + break; + + case tree_expression::multiply: + op = "*"; + break; + + case tree_expression::el_mul: + op = ".*"; + break; + + case tree_expression::divide: + op = "/"; + break; + + case tree_expression::el_div: + op = "./"; + break; + + case tree_expression::leftdiv: + op = "\\"; + break; + + case tree_expression::el_leftdiv: + op = ".\\"; + break; + + case tree_expression::power: + op = "^"; + break; + + case tree_expression::elem_pow: + op = ".^"; + break; + + case tree_expression::cmp_lt: + op = "<"; + break; + + case tree_expression::cmp_le: + op = "<="; + break; + + case tree_expression::cmp_eq: + op = "=="; + break; + + case tree_expression::cmp_ge: + op = ">="; + break; + + case tree_expression::cmp_gt: + op = ">"; + break; + + case tree_expression::cmp_ne: + op = "!="; + break; + + case tree_expression::and_and: + op = "&&"; + break; + + case tree_expression::or_or: + op = "||"; + break; + + case tree_expression::and: + op = "&"; + break; + + case tree_expression::or: + op = "|"; + break; + + default: + op = "<unknown>"; + break; } return op; }
--- a/src/pt-exp-base.h +++ b/src/pt-exp-base.h @@ -220,7 +220,8 @@ virtual int is_constant (void) const { return 0; } - virtual tree_constant assign (tree_constant& t, const Octave_object& args); + virtual tree_constant assign (const tree_constant& t, + const Octave_object& args); virtual char *name (void) const { panic_impossible (); return 0; } @@ -279,11 +280,11 @@ void document (char *s); - tree_constant assign (tree_constant& t); - tree_constant assign (tree_constant& t, const Octave_object& args); + tree_constant assign (const tree_constant& t); + tree_constant assign (const tree_constant& t, const Octave_object& args); - tree_constant assign (SLList<char*> list, tree_constant& t); - tree_constant assign (SLList<char*> list, tree_constant& t, + tree_constant assign (SLList<char*> list, const tree_constant& t); + tree_constant assign (SLList<char*> list, const tree_constant& t, const Octave_object& args); int is_defined (void); @@ -349,8 +350,8 @@ char *name (void); - tree_constant assign (tree_constant& t); - tree_constant assign (tree_constant& t, const Octave_object& args); + tree_constant assign (const tree_constant& t); + tree_constant assign (const tree_constant& t, const Octave_object& args); void mark_for_possible_ans_assign (void) { id->mark_for_possible_ans_assign (); }
--- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -50,6 +50,7 @@ #include "load-save.h" #include "help.h" #include "error.h" +#include "gripes.h" #include "utils.h" #include "defun.h" @@ -209,6 +210,7 @@ else plot_buf << "replot"; break; + case 2: if (clear_before_plotting || plot_line_count == 0) { @@ -218,12 +220,14 @@ else plot_buf << "replot"; break; + case 3: { plot_line_count = 0; plot_buf << "splot"; } break; + default: gripe_2_or_3_dim_plot (); return; @@ -282,12 +286,15 @@ case 1: os << "replot"; break; + case 2: os << "gplot"; break; + case 3: os << "gsplot"; break; + default: os << "<unkown plot command>"; break; @@ -687,9 +694,11 @@ case 2: file = save_in_tmp_file (data, ndim); break; + case 3: file = save_in_tmp_file (data, ndim, parametric_plot); break; + default: gripe_2_or_3_dim_plot (); break; @@ -817,9 +826,11 @@ case 2: save_ascii_data (file, t); break; + case 3: save_three_d (file, t, parametric); break; + default: gripe_2_or_3_dim_plot (); break; @@ -884,6 +895,7 @@ case 1: clear_before_plotting = ! clear_before_plotting; break; + case 2: if (strcasecmp (argv[1], "on") == 0) clear_before_plotting = 0; @@ -892,6 +904,7 @@ else print_usage ("hold"); break; + default: print_usage ("hold"); break;
--- a/src/rand.cc +++ b/src/rand.cc @@ -30,6 +30,7 @@ #include "tree-const.h" #include "f77-uscore.h" #include "error.h" +#include "gripes.h" #include "utils.h" #include "help.h" #include "defun-dld.h" @@ -249,10 +250,12 @@ F77_FCN (dgenunf) (&d_zero, &d_one, &val); rand_mat.elem (i, j) = val; break; + case normal: F77_FCN (dgennor) (&d_zero, &d_one, &val); rand_mat.elem (i, j) = val; break; + default: panic_impossible (); break;
--- a/src/sort.cc +++ b/src/sort.cc @@ -26,6 +26,8 @@ #endif #include "tree-const.h" +#include "error.h" +#include "gripes.h" #include "help.h" #include "defun-dld.h"
--- a/src/tc-rep-ass.cc +++ b/src/tc-rep-ass.cc @@ -49,7 +49,7 @@ #include "tc-inlines.h" -// Top-level tree-constant function that handle assignments. Only +// Top-level tree-constant function that handles assignments. Only // decide if the left-hand side is currently a scalar or a matrix and // hand off to other functions to do the real work. @@ -63,9 +63,12 @@ // vector since it will normally destroy the equally-spaced property // of the range elements. - if (type_tag == string_constant || type_tag == range_constant) + if (! is_numeric_type ()) force_numeric (); + if (error_state) + return; + switch (type_tag) { case complex_scalar_constant: @@ -79,14 +82,8 @@ do_matrix_assignment (rhs_tmp, args); break; - case string_constant: - ::error ("invalid assignment to string type"); - break; - - case range_constant: - case magic_colon: default: - panic_impossible (); + ::error ("invalid assignment to %s", type_as_string ()); break; } } @@ -665,6 +662,7 @@ do_matrix_assignment (rhs, magic_colon, magic_colon); } break; + default: panic_impossible (); break; @@ -1189,6 +1187,7 @@ do_matrix_assignment (rhs, i, magic_colon); } break; + default: panic_impossible (); break; @@ -1325,6 +1324,7 @@ do_matrix_assignment (rhs, iv, magic_colon); } break; + default: panic_impossible (); break; @@ -1466,6 +1466,7 @@ do_matrix_assignment (rhs, ri, magic_colon); } break; + default: panic_impossible (); break;
--- a/src/tc-rep-idx.cc +++ b/src/tc-rep-idx.cc @@ -51,6 +51,8 @@ // Indexing functions. +// This is the top-level indexing function. + tree_constant TC_REP::do_index (const Octave_object& args) { @@ -97,17 +99,16 @@ // retval = do_string_index (args); break; - case magic_colon: - case range_constant: + default: + // This isn\'t great, but it\'s easier than implementing a lot of -// range indexing functions. +// other special indexing functions. + force_numeric (); - assert (type_tag != magic_colon && type_tag != range_constant); - retval = do_index (args); - break; - default: - panic_impossible (); + if (! error_state && is_numeric_type ()) + retval = do_index (args); + break; } @@ -1424,8 +1425,8 @@ case scalar_constant: retval = scalar; break; + case complex_matrix_constant: - retval = *complex_matrix; break;
--- a/src/tc-rep.cc +++ b/src/tc-rep.cc @@ -292,16 +292,7 @@ { range = new Range (b, l, i); int nel = range->nelem (); - if (nel < 0) - { - delete range; - type_tag = unknown_constant; - if (nel == -1) - ::error ("number of elements in range exceeds INT_MAX"); - else - ::error ("invalid range"); - } - else if (nel > 1) + if (nel > 1) type_tag = range_constant; else { @@ -317,30 +308,43 @@ type_tag = matrix_constant; } else - panic_impossible (); + { + type_tag = unknown_constant; + if (nel == -1) + ::error ("number of elements in range exceeds INT_MAX"); + else + ::error ("invalid range"); + } } orig_text = 0; } TC_REP::tree_constant_rep (const Range& r) { - if (r.nelem () > 1) + int nel = r.nelem (); + if (nel > 1) { range = new Range (r); type_tag = range_constant; } - else if (r.nelem () == 1) + else if (nel == 1) { scalar = r.base (); type_tag = scalar_constant; } - else if (r.nelem () == 0) + else if (nel == 0) { matrix = new Matrix (); type_tag = matrix_constant; } else - panic_impossible (); + { + type_tag = unknown_constant; + if (nel == -1) + ::error ("number of elements in range exceeds INT_MAX"); + else + ::error ("invalid range"); + } orig_text = 0; } @@ -398,10 +402,6 @@ case magic_colon: break; - - default: - panic_impossible (); - break; } orig_text = strsave (t.orig_text); @@ -435,7 +435,9 @@ delete a_map; break; - default: + case unknown_constant: + case scalar_constant: + case magic_colon: break; } @@ -488,14 +490,9 @@ ::error ("invalid use of colon operator"); break; - case unknown_constant: - case map_constant: + default: retval = -1; break; - - default: - panic_impossible (); - break; } return retval; @@ -533,14 +530,9 @@ ::error ("invalid use of colon operator"); break; - case unknown_constant: - case map_constant: + default: retval = -1; break; - - default: - panic_impossible (); - break; } return retval; @@ -549,14 +541,17 @@ tree_constant TC_REP::all (void) const { - if (type_tag == string_constant || type_tag == range_constant) + tree_constant retval; + + if (error_state) + return retval; + + if (! is_numeric_type ()) { tree_constant tmp = make_numeric (); return tmp.all (); } - tree_constant retval; - switch (type_tag) { case scalar_constant: @@ -587,11 +582,8 @@ } break; - case string_constant: - case range_constant: - case magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg ("all", *this); break; } @@ -601,14 +593,17 @@ tree_constant TC_REP::any (void) const { - if (type_tag == string_constant || type_tag == range_constant) + tree_constant retval; + + if (error_state) + return retval; + + if (! is_numeric_type ()) { tree_constant tmp = make_numeric (); return tmp.any (); } - tree_constant retval; - switch (type_tag) { case scalar_constant: @@ -639,11 +634,8 @@ } break; - case string_constant: - case range_constant: - case magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg ("any", *this); break; } @@ -662,14 +654,17 @@ int TC_REP::is_true (void) const { - if (type_tag == string_constant || type_tag == range_constant) + int retval = 0; + + if (error_state) + return retval; + + if (! is_numeric_type ()) { tree_constant tmp = make_numeric (); return tmp.is_true (); } - int retval; - switch (type_tag) { case scalar_constant: @@ -698,11 +693,8 @@ } break; - case string_constant: - case range_constant: - case magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg (0, *this); break; } @@ -1220,9 +1212,8 @@ retval = string; break; - case magic_colon: default: - panic_impossible (); + gripe_invalid_conversion (type_as_string (), "string"); break; } @@ -1354,9 +1345,8 @@ } break; - case magic_colon: default: - panic_impossible (); + gripe_invalid_conversion (type_as_string (), "numeric type"); break; } } @@ -1394,9 +1384,8 @@ retval.force_numeric (force_str_conv); break; - case magic_colon: default: - panic_impossible (); + gripe_invalid_conversion (type_as_string (), "numeric value"); break; } @@ -1427,18 +1416,13 @@ *complex_matrix = *complex_matrix + 1.0; break; - case string_constant: - ::error ("string++ and ++string not implemented yet, ok?"); - break; - case range_constant: range->set_base (range->base () + 1.0); range->set_limit (range->limit () + 1.0); break; - case magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg ("operator ++", type_as_string ()); break; } break; @@ -1454,18 +1438,13 @@ *matrix = *matrix - 1.0; break; - case string_constant: - ::error ("string-- and -- string not implemented yet, ok?"); - break; - case range_constant: range->set_base (range->base () - 1.0); range->set_limit (range->limit () - 1.0); break; - case magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg ("operator --", type_as_string ()); break; } break; @@ -1490,7 +1469,7 @@ break; default: - panic_impossible (); + gripe_wrong_type_arg ("resize", type_as_string ()); break; } } @@ -1509,7 +1488,7 @@ break; default: - panic_impossible (); + gripe_wrong_type_arg ("resize", type_as_string ()); break; } } @@ -1625,16 +1604,7 @@ } break; - case scalar_constant: - case matrix_constant: - case string_constant: - case range_constant: - case map_constant: - case magic_colon: - break; - default: - panic_impossible (); break; } @@ -1740,8 +1710,8 @@ } break; + case unknown_constant: case magic_colon: - default: panic_impossible (); break; } @@ -1849,12 +1819,23 @@ os << ":"; break; - default: + case map_constant: + case unknown_constant: panic_impossible (); break; } } +void +TC_REP::gripe_wrong_type_arg (const char *name, + const tree_constant_rep& tcr) const +{ + if (name) + ::error ("%s: wrong type argument `%s'", name, tcr.type_as_string ()); + else + ::error ("wrong type argument `%s'", name, tcr.type_as_string ()); +} + char * TC_REP::type_as_string (void) const { @@ -1878,6 +1859,9 @@ case range_constant: return "range"; + case map_constant: + return "structure"; + default: return "<unknown type>"; } @@ -1886,7 +1870,7 @@ tree_constant do_binary_op (tree_constant& a, tree_constant& b, tree_expression::type t) { - tree_constant ans; + tree_constant retval; int first_empty = (a.rows () == 0 || a.columns () == 0); int second_empty = (b.rows () == 0 || b.columns () == 0); @@ -1899,13 +1883,20 @@ else if (flag == 0) { ::error ("invalid binary operation on empty matrix"); - return ans; + return retval; } } tree_constant tmp_a = a.make_numeric (); + + if (error_state) + return retval; + tree_constant tmp_b = b.make_numeric (); + if (error_state) + return retval; + TC_REP::constant_type a_type = tmp_a.const_type (); TC_REP::constant_type b_type = tmp_b.const_type (); @@ -1924,27 +1915,26 @@ { case TC_REP::scalar_constant: d2 = tmp_b.double_value (); - ans = do_binary_op (d1, d2, t); + retval = do_binary_op (d1, d2, t); break; case TC_REP::matrix_constant: m2 = tmp_b.matrix_value (); - ans = do_binary_op (d1, m2, t); + retval = do_binary_op (d1, m2, t); break; case TC_REP::complex_scalar_constant: c2 = tmp_b.complex_value (); - ans = do_binary_op (d1, c2, t); + retval = do_binary_op (d1, c2, t); break; case TC_REP::complex_matrix_constant: cm2 = tmp_b.complex_matrix_value (); - ans = do_binary_op (d1, cm2, t); + retval = do_binary_op (d1, cm2, t); break; - case TC_REP::magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg_for_binary_op (tmp_b); break; } break; @@ -1957,27 +1947,26 @@ { case TC_REP::scalar_constant: d2 = tmp_b.double_value (); - ans = do_binary_op (m1, d2, t); + retval = do_binary_op (m1, d2, t); break; case TC_REP::matrix_constant: m2 = tmp_b.matrix_value (); - ans = do_binary_op (m1, m2, t); + retval = do_binary_op (m1, m2, t); break; case TC_REP::complex_scalar_constant: c2 = tmp_b.complex_value (); - ans = do_binary_op (m1, c2, t); + retval = do_binary_op (m1, c2, t); break; case TC_REP::complex_matrix_constant: cm2 = tmp_b.complex_matrix_value (); - ans = do_binary_op (m1, cm2, t); + retval = do_binary_op (m1, cm2, t); break; - case TC_REP::magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg_for_binary_op (tmp_b); break; } break; @@ -1990,27 +1979,26 @@ { case TC_REP::scalar_constant: d2 = tmp_b.double_value (); - ans = do_binary_op (c1, d2, t); + retval = do_binary_op (c1, d2, t); break; case TC_REP::matrix_constant: m2 = tmp_b.matrix_value (); - ans = do_binary_op (c1, m2, t); + retval = do_binary_op (c1, m2, t); break; case TC_REP::complex_scalar_constant: c2 = tmp_b.complex_value (); - ans = do_binary_op (c1, c2, t); + retval = do_binary_op (c1, c2, t); break; case TC_REP::complex_matrix_constant: cm2 = tmp_b.complex_matrix_value (); - ans = do_binary_op (c1, cm2, t); + retval = do_binary_op (c1, cm2, t); break; - case TC_REP::magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg_for_binary_op (tmp_b); break; } break; @@ -2023,44 +2011,42 @@ { case TC_REP::scalar_constant: d2 = tmp_b.double_value (); - ans = do_binary_op (cm1, d2, t); + retval = do_binary_op (cm1, d2, t); break; case TC_REP::matrix_constant: m2 = tmp_b.matrix_value (); - ans = do_binary_op (cm1, m2, t); + retval = do_binary_op (cm1, m2, t); break; case TC_REP::complex_scalar_constant: c2 = tmp_b.complex_value (); - ans = do_binary_op (cm1, c2, t); + retval = do_binary_op (cm1, c2, t); break; case TC_REP::complex_matrix_constant: cm2 = tmp_b.complex_matrix_value (); - ans = do_binary_op (cm1, cm2, t); + retval = do_binary_op (cm1, cm2, t); break; - case TC_REP::magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg_for_binary_op (tmp_b); break; } break; - case TC_REP::magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg_for_binary_op (tmp_a); break; } - return ans; + return retval; } tree_constant do_unary_op (tree_constant& a, tree_expression::type t) { - tree_constant ans; + tree_constant retval; if (a.rows () == 0 || a.columns () == 0) { @@ -2070,43 +2056,45 @@ else if (flag == 0) { ::error ("invalid unary operation on empty matrix"); - return ans; + return retval; } } tree_constant tmp_a = a.make_numeric (); + if (error_state) + return retval; + switch (tmp_a.const_type ()) { case TC_REP::scalar_constant: - ans = do_unary_op (tmp_a.double_value (), t); + retval = do_unary_op (tmp_a.double_value (), t); break; case TC_REP::matrix_constant: { Matrix m = tmp_a.matrix_value (); - ans = do_unary_op (m, t); + retval = do_unary_op (m, t); } break; case TC_REP::complex_scalar_constant: - ans = do_unary_op (tmp_a.complex_value (), t); + retval = do_unary_op (tmp_a.complex_value (), t); break; case TC_REP::complex_matrix_constant: { ComplexMatrix m = tmp_a.complex_matrix_value (); - ans = do_unary_op (m, t); + retval = do_unary_op (m, t); } break; - case TC_REP::magic_colon: default: - panic_impossible (); + gripe_wrong_type_arg_for_unary_op (tmp_a); break; } - return ans; + return retval; } /*