Skip to content

Commit

Permalink
Showing 2 changed files with 15 additions and 32 deletions.

This file was deleted.

31 changes: 15 additions & 16 deletions truffle/src/main/java/org/jruby/truffle/stdlib/BigDecimalNodes.java
Original file line number Diff line number Diff line change
@@ -46,7 +46,6 @@
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.UnreachableCodeBranch;
import org.jruby.truffle.language.constants.ReadConstantNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
@@ -98,7 +97,7 @@ public static RoundingMode toRoundingMode(int constValue) {
case 7:
return RoundingMode.HALF_EVEN;
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -729,7 +728,7 @@ public Object negSpecial(VirtualFrame frame, DynamicObject value) {
case NAN:
return value;
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -797,7 +796,7 @@ protected Object multSpecialNormal(VirtualFrame frame, DynamicObject a, DynamicO
return createBigDecimal(frame, Type.POSITIVE_INFINITY);
}
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -824,7 +823,7 @@ protected Object multSpecial(VirtualFrame frame, DynamicObject a, DynamicObject
return bType == Type.POSITIVE_INFINITY ? a : createBigDecimal(frame, (Type.POSITIVE_INFINITY));
}

throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -921,7 +920,7 @@ private Object divBigDecimalWithProfile(DynamicObject a, DynamicObject b, MathCo
case -1:
return Type.NEGATIVE_INFINITY;
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
} else {
return divBigDecimal(aBigDecimal, bBigDecimal, mathContext);
@@ -967,7 +966,7 @@ protected Object divNormalSpecial(VirtualFrame frame, DynamicObject a, DynamicOb
return createBigDecimal(frame, BigDecimal.ZERO);
}
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -1001,7 +1000,7 @@ protected Object divSpecialNormal(VirtualFrame frame, DynamicObject a, DynamicOb
return createBigDecimal(frame, Type.POSITIVE_INFINITY);
}
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -1405,7 +1404,7 @@ public Object moduloSpecial(VirtualFrame frame, DynamicObject a, DynamicObject b
return createBigDecimal(frame, a);
}

throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -1483,7 +1482,7 @@ public Object power(VirtualFrame frame, DynamicObject a, int exponent, Object un
case NEGATIVE_ZERO:
return createBigDecimal(frame, Integer.signum(exponent) == 1 ? BigDecimal.ZERO : Type.NAN);
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}
}
@@ -1544,7 +1543,7 @@ public Object sqrtSpecial(VirtualFrame frame, DynamicObject a, int precision) {
case NEGATIVE_ZERO:
return createBigDecimal(frame, sqrt(BigDecimal.ZERO, new MathContext(precision, getRoundMode(frame))));
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}
}
@@ -1749,7 +1748,7 @@ public int signSpecial(VirtualFrame frame, DynamicObject value) {
case NAN:
return sign.executeGetIntegerConstant(frame, getBigDecimalClass(), "SIGN_NaN");
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -1833,7 +1832,7 @@ public Object absSpecial(VirtualFrame frame, DynamicObject value) {
case NAN:
return createBigDecimal(frame, type);
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -1906,7 +1905,7 @@ public Object roundSpecial(VirtualFrame frame, DynamicObject value, NotProvided
throw new RaiseException(getContext().getCoreLibrary().
floatDomainError("Computation results to 'NaN'(Not a Number)", this));
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();

}
}
@@ -2017,7 +2016,7 @@ public double toFSpecial(DynamicObject value) {
case NAN:
return Double.NaN;
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}

@@ -2081,7 +2080,7 @@ public int toISpecial(DynamicObject value) {
case NEGATIVE_ZERO:
return 0;
default:
throw new UnreachableCodeBranch();
throw new UnsupportedOperationException();
}
}
}

5 comments on commit 673a4c3

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pitr-ch I removed this because it's only used in one place and I think doesn't add much. If you get an UnsupportedOperationException everyone knows generally what that means and where to look to find it. Let me know if you strongly disagree.

Sorry, something went wrong.

@pitr-ch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree, the exception was added based on someones suggestion so I'll defer to @eregon / @nirvdrum.

Sorry, something went wrong.

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the use of UnsupportedOperationException, but I'd like there to be a message for the exception. It makes debugging a lot easier.

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a custom message at each place where the exception is thrown should lead to better messages than a default message in a subclass. For example 'This branch of code should be never reached, because we already know that this value should be in this range'.

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'm just noting that they're currently all blank.

Please sign in to comment.