50
50
import com .oracle .graal .python .nodes .SpecialMethodNames ;
51
51
import com .oracle .graal .python .nodes .function .PythonBuiltinNode ;
52
52
import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
53
+ import com .oracle .graal .python .nodes .function .builtins .PythonTernaryBuiltinNode ;
53
54
import com .oracle .graal .python .nodes .function .builtins .PythonUnaryBuiltinNode ;
54
55
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
55
56
import com .oracle .graal .python .runtime .ArithmeticUtil ;
@@ -805,11 +806,11 @@ Object doGeneric(Object left, Object right) {
805
806
abstract static class RMulNode extends MulNode {
806
807
}
807
808
808
- @ Builtin (name = SpecialMethodNames .__POW__ , fixedNumOfArguments = 2 )
809
+ @ Builtin (name = SpecialMethodNames .__POW__ , minNumOfArguments = 2 , maxNumOfArguments = 3 )
809
810
@ GenerateNodeFactory
810
- abstract static class PowNode extends PythonBinaryBuiltinNode {
811
+ abstract static class PowNode extends PythonTernaryBuiltinNode {
811
812
@ Specialization (guards = "right >= 0" , rewriteOn = ArithmeticException .class )
812
- int doIntegerFast (int left , int right ) {
813
+ int doIntegerFast (int left , int right , @ SuppressWarnings ( "unused" ) PNone none ) {
813
814
int result = 1 ;
814
815
int exponent = right ;
815
816
int base = left ;
@@ -824,32 +825,32 @@ int doIntegerFast(int left, int right) {
824
825
}
825
826
826
827
@ Specialization (guards = "right >= 0" )
827
- PInt doInteger (int left , int right ) {
828
+ PInt doInteger (int left , int right , @ SuppressWarnings ( "unused" ) PNone none ) {
828
829
return factory ().createInt (op (BigInteger .valueOf (left ), right ));
829
830
}
830
831
831
832
@ Specialization (guards = "right >= 0" , rewriteOn = ArithmeticException .class )
832
- long doLongFast (long left , int right ) {
833
- return doLongFast (left , (long ) right );
833
+ long doLongFast (long left , int right , PNone none ) {
834
+ return doLongFast (left , (long ) right , none );
834
835
}
835
836
836
837
@ Specialization (guards = "right >= 0" )
837
- PInt doLong (long left , int right ) {
838
- return doLong (left , (long ) right );
838
+ PInt doLong (long left , int right , PNone none ) {
839
+ return doLong (left , (long ) right , none );
839
840
}
840
841
841
842
@ Specialization (guards = "right >= 0" , rewriteOn = ArithmeticException .class )
842
- long doLongFast (int left , long right ) {
843
- return doLongFast ((long ) left , right );
843
+ long doLongFast (int left , long right , PNone none ) {
844
+ return doLongFast ((long ) left , right , none );
844
845
}
845
846
846
847
@ Specialization (guards = "right >= 0" )
847
- PInt doLong (int left , long right ) {
848
- return doLong ((long ) left , right );
848
+ PInt doLong (int left , long right , PNone none ) {
849
+ return doLong ((long ) left , right , none );
849
850
}
850
851
851
852
@ Specialization (guards = "right >= 0" , rewriteOn = ArithmeticException .class )
852
- long doLongFast (long left , long right ) {
853
+ long doLongFast (long left , long right , @ SuppressWarnings ( "unused" ) PNone none ) {
853
854
long result = 1 ;
854
855
long exponent = right ;
855
856
long base = left ;
@@ -864,22 +865,22 @@ long doLongFast(long left, long right) {
864
865
}
865
866
866
867
@ Specialization (guards = "right >= 0" )
867
- PInt doLong (long left , long right ) {
868
+ PInt doLong (long left , long right , @ SuppressWarnings ( "unused" ) PNone none ) {
868
869
return factory ().createInt (op (BigInteger .valueOf (left ), right ));
869
870
}
870
871
871
872
@ Specialization
872
- double doInt (long left , long right ) {
873
+ double doInt (long left , long right , @ SuppressWarnings ( "unused" ) PNone none ) {
873
874
return Math .pow (left , right );
874
875
}
875
876
876
877
@ Specialization
877
- double doInt (long left , double right ) {
878
+ double doInt (long left , double right , @ SuppressWarnings ( "unused" ) PNone none ) {
878
879
return Math .pow (left , right );
879
880
}
880
881
881
882
@ Specialization
882
- PInt doPInt (PInt left , PInt right ) {
883
+ PInt doPInt (PInt left , PInt right , @ SuppressWarnings ( "unused" ) PNone none ) {
883
884
try {
884
885
return factory ().createInt (op (left .getValue (), right .getValue ().longValueExact ()));
885
886
} catch (ArithmeticException e ) {
0 commit comments