Skip to content

Commit c717947

Browse files
committed
Rename isBasicInteger => isImplicitLong and isBasicNumber => isImplicitLongOrDouble
1 parent 6e03d1f commit c717947

File tree

7 files changed

+16
-12
lines changed

7 files changed

+16
-12
lines changed

src/main/java/org/truffleruby/core/MathNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ protected double function(double a, NotProvided b) {
467467
return doFunction(a);
468468
}
469469

470-
@Specialization(guards = { "!isRubyBignum(a)", "!isBasicNumber(a)" })
470+
@Specialization(guards = { "!isRubyBignum(a)", "!isImplicitLongOrDouble(a)" })
471471
protected double function(Object a, NotProvided b,
472472
@Cached ToFNode toFNode) {
473473
if (!isANode.executeIsA(a, coreLibrary().numericClass)) {

src/main/java/org/truffleruby/core/array/ArrayNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ protected Object at(RubyArray array, long index) {
245245
return nil;
246246
}
247247

248-
@Specialization(guards = "!isBasicInteger(index)")
248+
@Specialization(guards = "!isImplicitLong(index)")
249249
protected Object at(RubyArray array, Object index,
250250
@Cached ToLongNode toLongNode,
251251
@Cached FixnumLowerNode lowerNode,

src/main/java/org/truffleruby/core/cast/IntegerCastNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected int doLongToBig(long value,
5050
context.getCoreExceptions().rangeError("long too big to convert into `int'", this));
5151
}
5252

53-
@Specialization(guards = "!isBasicInteger(value)")
53+
@Specialization(guards = "!isImplicitLong(value)")
5454
protected int doBasicObject(Object value,
5555
@CachedContext(RubyLanguage.class) RubyContext context) {
5656
throw new RaiseException(

src/main/java/org/truffleruby/core/cast/LongCastNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected long doLong(long value) {
4343
}
4444

4545
@TruffleBoundary
46-
@Specialization(guards = "!isBasicInteger(value)")
46+
@Specialization(guards = "!isImplicitLong(value)")
4747
protected long doBasicObject(Object value,
4848
@CachedContext(RubyLanguage.class) RubyContext context) {
4949
throw new RaiseException(

src/main/java/org/truffleruby/core/cast/ToFNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected double coerceRubyBignum(RubyBignum value) {
5151
return BigIntegerOps.doubleValue(value);
5252
}
5353

54-
@Specialization(guards = { "!isRubyBignum(object)", "!isBasicNumber(object)" })
54+
@Specialization(guards = { "!isRubyBignum(object)", "!isImplicitLongOrDouble(object)" })
5555
protected double coerceObject(Object object,
5656
@Cached BranchProfile errorProfile) {
5757
if (toFNode == null) {

src/main/java/org/truffleruby/interop/OutgoingForeignCallNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected int objectId(Object receiver, String name, Object[] args,
9595
"name == cachedName",
9696
"cachedName.equals(INDEX_READ)",
9797
"args.length == 1",
98-
"isBasicInteger(first(args))" },
98+
"isImplicitLong(first(args))" },
9999
limit = "1")
100100
protected Object readArrayElement(Object receiver, String name, Object[] args,
101101
@Cached(value = "name", allowUncached = true) @Shared("name") String cachedName,
@@ -121,7 +121,7 @@ protected Object readMember(Object receiver, String name, Object[] args,
121121
"name == cachedName",
122122
"cachedName.equals(INDEX_WRITE)",
123123
"args.length == 2",
124-
"isBasicInteger(first(args))" },
124+
"isImplicitLong(first(args))" },
125125
limit = "1")
126126
protected Object writeArrayElement(Object receiver, String name, Object[] args,
127127
@Cached(value = "name", allowUncached = true) @Shared("name") String cachedName,
@@ -193,7 +193,7 @@ protected boolean isEqual(Object receiver, String name, Object[] args,
193193
"name == cachedName",
194194
"cachedName.equals(DELETE)",
195195
"args.length == 1",
196-
"isBasicInteger(first(args))" },
196+
"isImplicitLong(first(args))" },
197197
limit = "1")
198198
protected Object deleteArrayElement(Object receiver, String name, Object[] args,
199199
@Cached(value = "name", allowUncached = true) @Shared("name") String cachedName,

src/main/java/org/truffleruby/language/RubyGuards.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ public static boolean isIntOrLong(Object value) {
6262
return value instanceof Integer || value instanceof Long;
6363
}
6464

65-
public static boolean isBasicInteger(Object object) {
65+
public static boolean isImplicitDouble(Object object) {
66+
return object instanceof Float || object instanceof Double;
67+
}
68+
69+
public static boolean isImplicitLong(Object object) {
6670
return object instanceof Byte || object instanceof Short || object instanceof Integer || object instanceof Long;
6771
}
6872

69-
public static boolean isBasicNumber(Object object) {
73+
public static boolean isImplicitLongOrDouble(Object object) {
7074
return object instanceof Byte || object instanceof Short || object instanceof Integer ||
7175
object instanceof Long || object instanceof Float || object instanceof Double;
7276
}
@@ -155,12 +159,12 @@ public static boolean isRubyMatchData(Object object) {
155159
}
156160

157161
public static boolean isRubyInteger(Object object) {
158-
return isBasicInteger(object) || object instanceof RubyBignum;
162+
return isImplicitLong(object) || object instanceof RubyBignum;
159163
}
160164

161165
public static boolean isRubyNumber(Object object) {
162166
// Doesn't include classes like BigDecimal
163-
return isBasicNumber(object) || object instanceof RubyBignum;
167+
return isImplicitLongOrDouble(object) || object instanceof RubyBignum;
164168
}
165169

166170
public static boolean isNil(Object object) {

0 commit comments

Comments
 (0)