/** Helper method for testing equals on two primitive or boxable objects. yuck: factor this out into Primitive.java */ public boolean primitiveEquals( BSHSwitchStatement node, Object switchVal, Object targetVal, SimpleNode switchExp ) throws EvalError { if ( switchVal instanceof Primitive || targetVal instanceof Primitive ) try { // binaryOperation can return Primitive or wrapper type Object result = Primitive.binaryOperation( switchVal, targetVal, ParserConstants.EQ ); result = Primitive.unwrap( result ); return result.equals( Boolean.TRUE ); } catch ( UtilEvalError e ) { throw e.toEvalError( "Switch value: "+switchExp.getText()+": ", node, callstack ); } else return switchVal.equals( targetVal ); }
rhs instanceof Number || rhs instanceof Primitive) ) return Primitive.binaryOperation(lhs, rhs, kind);
return Primitive.binaryOperation(lhs, rhs, node.kind); } catch ( UtilEvalError e ) { throw e.toEvalError( node, callstack );