11/*
2- * Copyright (c) 2024, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2024, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
@@ -52,7 +52,9 @@ private static String getSuffix(boolean isComplex) {
5252 static String getSlotBaseClass (Slot s ) {
5353 return switch (s .value ()) {
5454 case nb_bool -> "TpSlotInquiry.TpSlotInquiryBuiltin" ;
55- case nb_add , nb_multiply -> "TpSlotBinaryOp.TpSlotBinaryOpBuiltin" ;
55+ case nb_add , nb_subtract , nb_multiply , nb_remainder , nb_divmod , nb_lshift , nb_rshift , nb_and , nb_xor , nb_or ,
56+ nb_floor_divide , nb_true_divide , nb_matrix_multiply ->
57+ "TpSlotBinaryOp.TpSlotBinaryOpBuiltin" ;
5658 case sq_concat -> "TpSlotBinaryFunc.TpSlotSqConcat" ;
5759 case sq_length , mp_length -> "TpSlotLen.TpSlotLenBuiltin" + getSuffix (s .isComplex ());
5860 case sq_item , sq_repeat -> "TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin" ;
@@ -68,7 +70,9 @@ static String getSlotNodeBaseClass(Slot s) {
6870 return switch (s .value ()) {
6971 case tp_descr_get -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode" ;
7072 case nb_bool -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotInquiry.NbBoolBuiltinNode" ;
71- case nb_add , nb_multiply -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode" ;
73+ case nb_add , nb_subtract , nb_multiply , nb_remainder , nb_divmod , nb_lshift , nb_rshift , nb_and , nb_xor , nb_or ,
74+ nb_floor_divide , nb_true_divide , nb_matrix_multiply ->
75+ "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryOp.BinaryOpBuiltinNode" ;
7276 case sq_concat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode" ;
7377 case sq_length , mp_length -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode" ;
7478 case sq_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode" ;
@@ -85,7 +89,9 @@ static String getUncachedExecuteSignature(SlotKind s) {
8589 case nb_bool -> "boolean executeUncached(Object self)" ;
8690 case tp_descr_get -> "Object executeUncached(Object self, Object obj, Object type)" ;
8791 case sq_length , mp_length -> "int executeUncached(Object self)" ;
88- case tp_getattro , tp_descr_set , tp_setattro , sq_item , mp_subscript , nb_add , sq_concat , sq_repeat , nb_multiply ->
92+ case tp_getattro , tp_descr_set , tp_setattro , sq_item , mp_subscript , sq_concat , sq_repeat ,
93+ nb_add , nb_subtract , nb_multiply , nb_remainder , nb_divmod , nb_lshift , nb_rshift ,
94+ nb_and , nb_xor , nb_or , nb_floor_divide , nb_true_divide , nb_matrix_multiply ->
8995 throw new AssertionError ("Should not reach here: should be always complex" );
9096 };
9197 }
@@ -94,17 +100,19 @@ static boolean supportsComplex(SlotKind s) {
94100 return switch (s ) {
95101 case nb_bool -> false ;
96102 case sq_length , mp_length , tp_getattro , tp_descr_get , tp_descr_set ,
97- tp_setattro , sq_item , mp_subscript , nb_add , sq_concat ,
98- sq_repeat , nb_multiply ->
103+ tp_setattro , sq_item , mp_subscript , sq_concat , sq_repeat ,
104+ nb_add , nb_subtract , nb_multiply , nb_remainder , nb_divmod , nb_lshift , nb_rshift ,
105+ nb_and , nb_xor , nb_or , nb_floor_divide , nb_true_divide , nb_matrix_multiply ->
99106 true ;
100107 };
101108 }
102109
103110 static boolean supportsSimple (SlotKind s ) {
104111 return switch (s ) {
105112 case nb_bool , sq_length , mp_length , tp_descr_get -> true ;
106- case tp_getattro , tp_descr_set , tp_setattro , sq_item , mp_subscript ,
107- nb_add , sq_concat , sq_repeat , nb_multiply ->
113+ case tp_getattro , tp_descr_set , tp_setattro , sq_item , mp_subscript , sq_concat , sq_repeat ,
114+ nb_add , nb_subtract , nb_multiply , nb_remainder , nb_divmod , nb_lshift , nb_rshift ,
115+ nb_and , nb_xor , nb_or , nb_floor_divide , nb_true_divide , nb_matrix_multiply ->
108116 false ;
109117 };
110118 }
@@ -114,16 +122,28 @@ static String getUncachedExecuteCall(SlotKind s) {
114122 case nb_bool -> "executeBool(null, self)" ;
115123 case sq_length , mp_length -> "executeInt(null, self)" ;
116124 case tp_descr_get -> "execute(null, self, obj, type)" ;
117- case tp_getattro , tp_descr_set , tp_setattro , sq_item , mp_subscript ,
118- nb_add , sq_concat , nb_multiply , sq_repeat ->
125+ case tp_getattro , tp_descr_set , tp_setattro , sq_item , mp_subscript , sq_concat , sq_repeat ,
126+ nb_add , nb_subtract , nb_multiply , nb_remainder , nb_divmod , nb_lshift , nb_rshift ,
127+ nb_and , nb_xor , nb_or , nb_floor_divide , nb_true_divide , nb_matrix_multiply ->
119128 throw new AssertionError ("Should not reach here: should be always complex" );
120129 };
121130 }
122131
123132 public static String getExtraCtorArgs (TpSlotData slot ) {
124133 return switch (slot .slot ().value ()) {
125134 case nb_add -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ADD__" ;
135+ case nb_subtract -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___SUB__" ;
126136 case nb_multiply -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___MUL__" ;
137+ case nb_remainder -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___MOD__" ;
138+ case nb_divmod -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___DIVMOD__" ;
139+ case nb_lshift -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___LSHIFT__" ;
140+ case nb_rshift -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___RSHIFT__" ;
141+ case nb_and -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___AND__" ;
142+ case nb_xor -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___XOR__" ;
143+ case nb_or -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___OR__" ;
144+ case nb_floor_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___FLOORDIV__" ;
145+ case nb_true_divide -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___TRUEDIV__" ;
146+ case nb_matrix_multiply -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___MATMUL__" ;
127147 default -> "" ;
128148 };
129149 }
0 commit comments