Skip to content

Instantly share code, notes, and snippets.

@peschwa
Created September 20, 2015 13:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save peschwa/f054f0b8a8baaf72e3c2 to your computer and use it in GitHub Desktop.
diff --git a/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java b/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
index e151917..2174fa9 100644
--- a/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
+++ b/src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
@@ -5949,21 +5949,30 @@ public final class Ops {
return ((P6bigintInstance)obj).value;
int hint = 0;
try {
- Field field_REPRData = obj.st.getClass().getField("REPRData");
- if( field_REPRData != null ) {
- Object REPRData = field_REPRData.get(obj);
- Field field_unboxIntSlot = REPRData.getClass().getField("unboxIntSlot");
- hint = field_unboxIntSlot != null ? (int) field_unboxIntSlot.get(REPRData) : 0;
+ obj.get_attribute_native(tc, null, null, hint);
+ } catch (RuntimeException RTE) {
+ // didn't get it at 0, look for the right hint
+ try {
+ Field field_REPRData = obj.st.getClass().getField("REPRData");
+ if( field_REPRData != null ) {
+ Object REPRData = field_REPRData.get(obj.st);
+ Field field_unboxIntSlot = REPRData.getClass().getField("unboxIntSlot");
+ hint = field_unboxIntSlot != null ? (int) field_unboxIntSlot.get(REPRData) : 0;
+ }
+ if( hint >= 0 ) {
+ obj.get_attribute_native(tc, null, null, hint);
+ } else {
+ // didn't get the hint, let's just guess...?
+ SixModelObject bigint = obj.get_attribute_boxed(tc, null, null, 1);
+ bigint.get_attribute_native(tc, null, null, 0);
+ }
+ } catch (NoSuchFieldException nsfe) {
+ // do nothing, just use hint = 0
+ } catch (IllegalAccessException iae) {
+ // do nothing, we should be able to see all decls usw.
}
- } catch (NoSuchFieldException nsfe) {
- // do nothing, just use hint = 0
- } catch (IllegalAccessException iae) {
- // do nothing, we should be able to see all decls usw.
- } catch (IllegalArgumentException iae2) {
- // do nothing, we didn't get what we were looking for
}
- obj.get_attribute_native(tc, null, null, hint);
return (BigInteger)tc.native_j;
}
@@ -5974,22 +5983,28 @@ public final class Ops {
}
else {
int hint = 0;
+ tc.native_j = value;
try {
- Field field_REPRData = type.st.getClass().getField("REPRData");
- if( field_REPRData != null ) {
- Object REPRData = field_REPRData.get(type);
- Field field_unboxIntSlot = REPRData.getClass().getField("unboxIntSlot");
- hint = field_unboxIntSlot != null ? (int) field_unboxIntSlot.get(REPRData) : 0;
+ res.bind_attribute_native(tc, null, null, hint);
+ } catch (RuntimeException RTE) {
+ // didn't get it at 0, look for the right hint
+ try {
+ Field field_REPRData = type.st.getClass().getField("REPRData");
+ if( field_REPRData != null ) {
+ Object REPRData = field_REPRData.get(type.st);
+ Field field_unboxIntSlot = REPRData.getClass().getField("unboxIntSlot");
+ hint = field_unboxIntSlot != null ? (int) field_unboxIntSlot.get(REPRData) : 0;
+ hint = hint > 0 ? hint : 0;
+ }
+ } catch (NoSuchFieldException nsfe) {
+ // do nothing, just use hint = 0
+ } catch (IllegalAccessException iae) {
+ // do nothing, we should be able to see all decls usw.
+ } catch (RuntimeException rte) {
+ SixModelObject bigint = makeBI(tc, res.get_attribute_boxed(tc, null, null, hint).st.WHAT, value);
+ res.bind_attribute_boxed(tc, null, null, hint, bigint);
}
- } catch (NoSuchFieldException nsfe) {
- // do nothing, just use hint = 0
- } catch (IllegalAccessException iae) {
- // do nothing, we should be able to see all decls usw.
- } catch (IllegalArgumentException iae2) {
- // do nothing, we didn't get what we were looking for
}
- tc.native_j = value;
- res.bind_attribute_native(tc, null, null, hint);
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment