1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
@@ -52,7 +52,9 @@ private static String getSuffix(boolean isComplex) {
52
52
static String getSlotBaseClass (Slot s ) {
53
53
return switch (s .value ()) {
54
54
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" ;
56
58
case sq_concat -> "TpSlotBinaryFunc.TpSlotSqConcat" ;
57
59
case sq_length , mp_length -> "TpSlotLen.TpSlotLenBuiltin" + getSuffix (s .isComplex ());
58
60
case sq_item , sq_repeat -> "TpSlotSizeArgFun.TpSlotSizeArgFunBuiltin" ;
@@ -68,7 +70,9 @@ static String getSlotNodeBaseClass(Slot s) {
68
70
return switch (s .value ()) {
69
71
case tp_descr_get -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotDescrGet.DescrGetBuiltinNode" ;
70
72
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" ;
72
76
case sq_concat -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotBinaryFunc.SqConcatBuiltinNode" ;
73
77
case sq_length , mp_length -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotLen.LenBuiltinNode" ;
74
78
case sq_item -> "com.oracle.graal.python.builtins.objects.type.slots.TpSlotSizeArgFun.SqItemBuiltinNode" ;
@@ -85,7 +89,9 @@ static String getUncachedExecuteSignature(SlotKind s) {
85
89
case nb_bool -> "boolean executeUncached(Object self)" ;
86
90
case tp_descr_get -> "Object executeUncached(Object self, Object obj, Object type)" ;
87
91
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 ->
89
95
throw new AssertionError ("Should not reach here: should be always complex" );
90
96
};
91
97
}
@@ -94,17 +100,19 @@ static boolean supportsComplex(SlotKind s) {
94
100
return switch (s ) {
95
101
case nb_bool -> false ;
96
102
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 ->
99
106
true ;
100
107
};
101
108
}
102
109
103
110
static boolean supportsSimple (SlotKind s ) {
104
111
return switch (s ) {
105
112
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 ->
108
116
false ;
109
117
};
110
118
}
@@ -114,16 +122,28 @@ static String getUncachedExecuteCall(SlotKind s) {
114
122
case nb_bool -> "executeBool(null, self)" ;
115
123
case sq_length , mp_length -> "executeInt(null, self)" ;
116
124
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 ->
119
128
throw new AssertionError ("Should not reach here: should be always complex" );
120
129
};
121
130
}
122
131
123
132
public static String getExtraCtorArgs (TpSlotData slot ) {
124
133
return switch (slot .slot ().value ()) {
125
134
case nb_add -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___ADD__" ;
135
+ case nb_subtract -> ", com.oracle.graal.python.nodes.SpecialMethodNames.J___SUB__" ;
126
136
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__" ;
127
147
default -> "" ;
128
148
};
129
149
}
0 commit comments