Modified:
/src/org/ductilej/runtime/Binop.java
/src/org/ductilej/runtime/Unop.java
=======================================
--- /src/org/ductilej/runtime/Binop.java Sat Jul 10 11:48:44 2010
+++ /src/org/ductilej/runtime/Binop.java Sat Jul 10 11:53:05 2010
@@ -144,14 +144,14 @@
* Returns the {@link BinOps} instance appropriate for the supplied
left- and right-hand-sides
* of a binary expression.
*/
- protected static BinOps get (Object lhs, Object rhs)
- {
- // TODO: we probably want this check here, though it will hurt
performance
- // if (lhs == null || rhs == null) {
- // throw new NullPointerException(
- // "Binary op (" + opcode + ") on null arg (lhs=" + lhs
+ ", rhs=" + rhs + ")");
- // }
- return BINOPS.get(lhs.getClass()).get(rhs.getClass());
+ protected BinOps get (Object lhs, Object rhs)
+ {
+ try {
+ return BINOPS.get(lhs.getClass()).get(rhs.getClass());
+ } catch (NullPointerException npe) {
+ throw new NullPointerException(
+ "Binary op (" + this + ") on null arg (lhs=" + lhs + ",
rhs=" + rhs + ")");
+ }
}
/**
=======================================
--- /src/org/ductilej/runtime/Unop.java Sat Jul 10 11:48:44 2010
+++ /src/org/ductilej/runtime/Unop.java Sat Jul 10 11:53:05 2010
@@ -67,13 +67,13 @@
/**
* Returns the {@link UnOps} instance appropriate for the supplied
expression argument type.
*/
- protected static UnOps get (Object arg)
- {
- // TODO: we probably want this check here, though it will hurt
performance
- // if (arg == null) {
- // throw new NullPointerException("Unary op (" + opcode + ")
on null arg.");
- // }
- return UNOPS.get(arg.getClass());
+ protected UnOps get (Object arg)
+ {
+ try {
+ return UNOPS.get(arg.getClass());
+ } catch (NullPointerException npe) {
+ throw new NullPointerException("Unary op (" + this + ") on
null arg.");
+ }
}
protected static final Map<Class<?>, UnOps> UNOPS =
ImmutableMap.<Class<?>, UnOps>builder().