35
35
import static com .oracle .graal .python .nodes .SpecialMethodNames .__STR__ ;
36
36
import static com .oracle .graal .python .nodes .SpecialMethodNames .__XOR__ ;
37
37
38
+ import java .math .BigInteger ;
38
39
import java .util .List ;
39
40
40
41
import com .oracle .graal .python .builtins .Builtin ;
41
42
import com .oracle .graal .python .builtins .CoreFunctions ;
42
43
import com .oracle .graal .python .builtins .PythonBuiltins ;
43
44
import com .oracle .graal .python .builtins .objects .PNotImplemented ;
45
+ import com .oracle .graal .python .builtins .objects .ints .PInt ;
44
46
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
45
47
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
46
48
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
49
+ import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
47
50
import com .oracle .truffle .api .dsl .Fallback ;
48
51
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
49
52
import com .oracle .truffle .api .dsl .NodeFactory ;
@@ -64,6 +67,11 @@ abstract static class StrNode extends PythonBuiltinNode {
64
67
public Object str (boolean self ) {
65
68
return self ? "True" : "False" ;
66
69
}
70
+
71
+ @ Specialization
72
+ public Object str (PInt self ) {
73
+ return self .getValue () == BigInteger .ZERO ? "False" : "True" ;
74
+ }
67
75
}
68
76
69
77
@ Builtin (name = __REPR__ , fixedNumOfArguments = 1 )
@@ -79,6 +87,12 @@ boolean eq(boolean left, boolean right) {
79
87
return left == right ;
80
88
}
81
89
90
+ @ TruffleBoundary
91
+ @ Specialization
92
+ boolean eq (PInt left , PInt right ) {
93
+ return left .getValue ().equals (right .getValue ());
94
+ }
95
+
82
96
@ SuppressWarnings ("unused" )
83
97
@ Fallback
84
98
Object doGeneric (Object left , Object right ) {
0 commit comments