File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 57
57
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
58
58
import com .oracle .graal .python .builtins .PythonBuiltins ;
59
59
import com .oracle .graal .python .builtins .modules .MathGuards ;
60
- import com .oracle .graal .python .builtins .modules .SysModuleBuiltins ;
61
60
import com .oracle .graal .python .builtins .objects .PNone ;
62
61
import com .oracle .graal .python .builtins .objects .PNotImplemented ;
63
62
import com .oracle .graal .python .builtins .objects .array .PArray ;
@@ -2657,9 +2656,8 @@ long hash(long self) {
2657
2656
}
2658
2657
2659
2658
@ Specialization
2660
- @ TruffleBoundary
2661
2659
long hash (PInt self ) {
2662
- return self .getValue (). remainder ( BigInteger . valueOf ( SysModuleBuiltins . HASH_MODULUS )). longValue ();
2660
+ return self .hash ();
2663
2661
}
2664
2662
2665
2663
@ Specialization
Original file line number Diff line number Diff line change 31
31
32
32
import com .oracle .graal .python .PythonLanguage ;
33
33
import com .oracle .graal .python .builtins .PythonBuiltinClassType ;
34
+ import com .oracle .graal .python .builtins .modules .SysModuleBuiltins ;
34
35
import com .oracle .graal .python .builtins .objects .cext .PythonNativeWrapperLibrary ;
35
36
import com .oracle .graal .python .builtins .objects .function .PArguments .ThreadState ;
36
37
import com .oracle .graal .python .builtins .objects .object .PythonBuiltinObject ;
@@ -538,4 +539,15 @@ public BigInteger subtract(PInt other) {
538
539
public BigInteger add (PInt other ) {
539
540
return add (other .value );
540
541
}
542
+
543
+ @ ExportMessage
544
+ public long hash () {
545
+ return hashBigInteger (value );
546
+ }
547
+
548
+ @ TruffleBoundary
549
+ public static long hashBigInteger (BigInteger i ) {
550
+ long h = i .remainder (BigInteger .valueOf (SysModuleBuiltins .HASH_MODULUS )).longValue ();
551
+ return h == -1 ? -2 : h ;
552
+ }
541
553
}
You can’t perform that action at this time.
0 commit comments