if (o instanceof String) try { return new Double((String)o); } catch (NumberFormatException e) { return new Double(0); }
if (o instanceof Boolean) return ((Boolean)o).booleanValue() ? new Long(1) : new Long(0);
if (o instanceof JS) return ((JS)o).coerceToNumber();
- throw new Error("toNumber() got object of type " + o.getClass().getName() + " which we don't know how to handle");
+ throw new Error("a " + o.getClass().getName() + " has no numeric value");
}