|
36 | 36 | import org.truffleruby.core.array.library.ArrayStoreLibrary;
|
37 | 37 | import org.truffleruby.core.encoding.Encodings;
|
38 | 38 | import org.truffleruby.core.encoding.RubyEncoding;
|
| 39 | +import org.truffleruby.core.numeric.FixnumOrBignumNode; |
39 | 40 | import org.truffleruby.core.string.RubyString;
|
40 | 41 | import org.truffleruby.core.string.StringHelperNodes;
|
41 | 42 | import org.truffleruby.core.string.StringOperations;
|
@@ -1051,6 +1052,15 @@ protected boolean fits(Object receiver,
|
1051 | 1052 | }
|
1052 | 1053 | }
|
1053 | 1054 |
|
| 1055 | + @CoreMethod(names = "fits_in_big_integer?", onSingleton = true, required = 1) |
| 1056 | + public abstract static class FitsInBigIntegerNode extends CoreMethodArrayArgumentsNode { |
| 1057 | + @Specialization(limit = "getInteropCacheLimit()") |
| 1058 | + protected boolean fits(Object receiver, |
| 1059 | + @CachedLibrary("receiver") InteropLibrary receivers) { |
| 1060 | + return receivers.fitsInBigInteger(receiver); |
| 1061 | + } |
| 1062 | + } |
| 1063 | + |
1054 | 1064 | @CoreMethod(names = "fits_in_float?", onSingleton = true, required = 1)
|
1055 | 1065 | public abstract static class FitsInFloatNode extends CoreMethodArrayArgumentsNode {
|
1056 | 1066 | @Specialization(limit = "getInteropCacheLimit()")
|
@@ -1125,6 +1135,21 @@ protected long as(Object receiver,
|
1125 | 1135 | }
|
1126 | 1136 | }
|
1127 | 1137 |
|
| 1138 | + @CoreMethod(names = "as_big_integer", onSingleton = true, required = 1) |
| 1139 | + public abstract static class AsBigIntegerNode extends CoreMethodArrayArgumentsNode { |
| 1140 | + @Specialization(limit = "getInteropCacheLimit()") |
| 1141 | + protected Object as(Object receiver, |
| 1142 | + @CachedLibrary("receiver") InteropLibrary receivers, |
| 1143 | + @Cached FixnumOrBignumNode fixnumOrBignumNode, |
| 1144 | + @Cached TranslateInteropExceptionNode translateInteropException) { |
| 1145 | + try { |
| 1146 | + return fixnumOrBignumNode.fixnumOrBignum(receivers.asBigInteger(receiver)); |
| 1147 | + } catch (InteropException e) { |
| 1148 | + throw translateInteropException.execute(e); |
| 1149 | + } |
| 1150 | + } |
| 1151 | + } |
| 1152 | + |
1128 | 1153 | @CoreMethod(names = "as_float", onSingleton = true, required = 1)
|
1129 | 1154 | public abstract static class AsFloatNode extends CoreMethodArrayArgumentsNode {
|
1130 | 1155 | @Specialization(limit = "getInteropCacheLimit()")
|
|
0 commit comments