public Operand computeValue(String methodName, Operand arg) { double v1 = value; double v2 = (arg instanceof Fixnum) ? 1.0 * ((Fixnum)arg).value : (double)((Float)arg).value; if (methodName.equals("+")) { return new Float(v1 + v2); } else if (methodName.equals("-")) { return new Float(v1 - v2); } else if (methodName.equals("*")) { return new Float(v1 * v2); } else if (methodName.equals("/")) { return v2 == 0.0 ? null : new Float(v1 / v2); // If divisor is zero, don't simplify! } return null; }
public void Float(org.jruby.ir.operands.Float flote) { print(flote.getValue()); } public void UnboxedFloat(org.jruby.ir.operands.UnboxedFloat flote) { print(flote.getValue()); }
case FILENAME: return Filename.decode(this); case FIXNUM: return Fixnum.decode(this); case FLOAT: return org.jruby.ir.operands.Float.decode(this); case FROZEN_STRING: return FrozenString.decode(this); case GLOBAL_VARIABLE: return GlobalVariable.decode(this);
case FILENAME: return Filename.decode(this); case FIXNUM: return Fixnum.decode(this); case FLOAT: return org.jruby.ir.operands.Float.decode(this); case FROZEN_STRING: return FrozenString.decode(this); case GLOBAL_VARIABLE: return GlobalVariable.decode(this);
public Operand computeValue(String methodName, Operand arg) { double v1 = value; double v2 = (arg instanceof Fixnum) ? 1.0 * ((Fixnum)arg).value : (double)((Float)arg).value; if (methodName.equals("+")) { return new Float(v1 + v2); } else if (methodName.equals("-")) { return new Float(v1 - v2); } else if (methodName.equals("*")) { return new Float(v1 * v2); } else if (methodName.equals("/")) { return v2 == 0.0 ? null : new Float(v1 / v2); // If divisor is zero, don't simplify! } return null; }
public void Float(org.jruby.ir.operands.Float flote) { print(flote.getValue()); } public void UnboxedFloat(org.jruby.ir.operands.UnboxedFloat flote) { print(flote.getValue()); }
public Operand buildFloat(FloatNode node) { // Since flaot literals are effectively interned objects, no need to copyAndReturnValue(...) // SSS FIXME: Or is this a premature optimization? return new Float(node.getValue()); }
@Override public void Float(org.jruby.ir.operands.Float flote) { jvmMethod().pushFloat(flote.getValue()); }
public Operand buildFloat(FloatNode node) { // Since flaot literals are effectively interned objects, no need to copyAndReturnValue(...) // SSS FIXME: Or is this a premature optimization? return new Float(node.getValue()); }
@Override public void Float(org.jruby.ir.operands.Float flote) { jvmMethod().pushFloat(flote.getValue()); }
public Operand buildFloat(FloatNode node, IRScope s) { // SSS: Since flaot literals are effectively interned objects, no need to copyAndReturnValue(...) // Or is this a premature optimization? return new Float(node.getValue()); }
@Override public void Float(org.jruby.ir.operands.Float flote) { jvm.method().pushFloat(flote.getValue()); }
public Operand buildFloat(FloatNode node, IRScope s) { // SSS: Since flaot literals are effectively interned objects, no need to copyAndReturnValue(...) // Or is this a premature optimization? return new Float(node.getValue()); }
@Override public void Float(org.jruby.ir.operands.Float flote) { jvm.method().pushFloat(flote.getValue()); }
public static Float decode(IRReaderDecoder d) { return new Float(d.decodeDouble()); }
private Operand getUnboxedOperand(UnboxState state, Map<Variable, TemporaryLocalVariable> unboxMap, Operand arg) { if (arg instanceof Variable) { Variable v = (Variable)arg; Class unboxedType = state.unboxedVars.get(v); return unboxedType == null ? arg : getUnboxedVar(unboxedType, unboxMap, v); } else if (arg instanceof Float) { return new UnboxedFloat(((Float)arg).getValue()); } else if (arg instanceof Fixnum) { return new UnboxedFixnum(((Fixnum)arg).getValue()); } else if (arg instanceof Boolean) { return new UnboxedBoolean(((Boolean)arg).isTrue()); } // This has to be a known operand like (UnboxedBoolean, etc.) return arg; }
public static Float decode(IRReaderDecoder d) { return new Float(d.decodeDouble()); }
private Operand getUnboxedOperand(UnboxState state, Map<Variable, TemporaryLocalVariable> unboxMap, Operand arg) { if (arg instanceof Variable) { Variable v = (Variable)arg; Class unboxedType = state.unboxedVars.get(v); return unboxedType == null ? arg : getUnboxedVar(unboxedType, unboxMap, v); } else if (arg instanceof Float) { return new UnboxedFloat(((Float)arg).getValue()); } else if (arg instanceof Fixnum) { return new UnboxedFixnum(((Fixnum)arg).getValue()); } else if (arg instanceof Boolean) { return new UnboxedBoolean(((Boolean)arg).isTrue()); } // This has to be a known operand like (UnboxedBoolean, etc.) return arg; }
public Operand computeValue(String methodName, Operand arg) { if (arg instanceof Fixnum) { if (methodName.equals("+")) return new Fixnum(value + ((Fixnum)arg).value); if (methodName.equals("-")) return new Fixnum(value - ((Fixnum)arg).value); if (methodName.equals("*")) return new Fixnum(value * ((Fixnum)arg).value); if (methodName.equals("/")) { Long divisor = ((Fixnum)arg).value; return divisor == 0L ? null : new Fixnum(value / divisor); // If divisor is zero, don't simplify! } } else if (arg instanceof Float) { if (methodName.equals("+")) return new Float(value + ((Float)arg).value); if (methodName.equals("-")) return new Float(value - ((Float)arg).value); if (methodName.equals("*")) return new Float(value * ((Float)arg).value); if (methodName.equals("/")) { Double divisor = ((Float)arg).value; return divisor == 0.0 ? null : new Float(value / divisor); // If divisor is zero, don't simplify! } } return null; }
private Operand unboxOperand(UnboxState state, Class reqdType, Map<Variable, TemporaryLocalVariable> unboxMap, Operand arg, List<Instr> newInstrs) { if (arg instanceof Variable) { Variable v = (Variable)arg; boolean isUnboxed = state.unboxedVars.get(v) == reqdType; // Get a temp var for 'v' if we dont already have one TemporaryLocalVariable unboxedVar = getUnboxedVar(reqdType, unboxMap, v); // Unbox if 'v' is not already unboxed if (!isUnboxed) { unboxVar(state, reqdType, unboxMap, v, newInstrs); } return unboxedVar; } else if (arg instanceof Float) { return new UnboxedFloat(((Float)arg).getValue()); } else if (arg instanceof Fixnum) { return new UnboxedFixnum(((Fixnum)arg).getValue()); } else if (arg instanceof Boolean) { return new UnboxedBoolean(((Boolean)arg).isTrue()); } // This has to be a known operand like (UnboxedBoolean, etc.) return arg; }