7#include "nuitka/prelude.h"
13static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
14 CHECK_OBJECT(operand1);
15 assert(PyLong_CheckExact(operand1));
16 CHECK_OBJECT(operand2);
17 assert(PyLong_CheckExact(operand2));
24#pragma warning(disable : 4101)
26 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
27 NUITKA_MAY_BE_UNUSED
long clong_result;
32 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(operand1, operand2);
33 assert(x != Py_NotImplemented);
36 goto exit_result_object;
39 if (unlikely(obj_result == NULL)) {
40 goto exit_result_exception;
52PyObject *BINARY_OPERATION_RSHIFT_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
53 return _BINARY_OPERATION_RSHIFT_OBJECT_LONG_LONG(operand1, operand2);
57static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_LONG(PyObject *operand1,
59 PyTypeObject *type1 = Py_TYPE(operand1);
63#pragma warning(disable : 4101)
65 NUITKA_MAY_BE_UNUSED
bool cbool_result;
66 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
72 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
73 binaryfunc slot2 = NULL;
75 if (!(type1 == &PyLong_Type)) {
78 slot2 = PyLong_Type.tp_as_number->nb_rshift;
86 PyObject *x = slot1(operand1, operand2);
88 if (x != Py_NotImplemented) {
90 goto exit_binary_result_object;
93 Py_DECREF_IMMORTAL(x);
97 PyObject *x = slot2(operand1, operand2);
99 if (x != Py_NotImplemented) {
101 goto exit_binary_result_object;
104 Py_DECREF_IMMORTAL(x);
107#if PYTHON_VERSION < 0x300
108 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
110 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
113 PyObject *coerced1 = operand1;
114 PyObject *coerced2 = operand2;
116 int err = c1(&coerced1, &coerced2);
118 if (unlikely(err < 0)) {
119 goto exit_binary_exception;
123 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
125 if (likely(mv == NULL)) {
126 binaryfunc slot = mv->nb_rshift;
128 if (likely(slot != NULL)) {
129 PyObject *x = slot(coerced1, coerced2);
135 goto exit_binary_result_object;
144 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
147 PyObject *coerced1 = operand1;
148 PyObject *coerced2 = operand2;
150 int err = c2(&coerced2, &coerced1);
152 if (unlikely(err < 0)) {
153 goto exit_binary_exception;
157 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
159 if (likely(mv == NULL)) {
160 binaryfunc slot = mv->nb_rshift;
162 if (likely(slot != NULL)) {
163 PyObject *x = slot(coerced1, coerced2);
169 goto exit_binary_result_object;
181#if PYTHON_VERSION < 0x300
182 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and 'long'", type1->tp_name);
184 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and 'int'", type1->tp_name);
186 goto exit_binary_exception;
188exit_binary_result_object:
191exit_binary_exception:
194static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
195 CHECK_OBJECT(operand1);
196 CHECK_OBJECT(operand2);
197 assert(PyLong_CheckExact(operand2));
199 PyTypeObject *type1 = Py_TYPE(operand1);
201 if (type1 == &PyLong_Type) {
209#pragma warning(disable : 4101)
211 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
212 NUITKA_MAY_BE_UNUSED
long clong_result;
217 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(operand1, operand2);
218 assert(x != Py_NotImplemented);
221 goto exit_result_object;
224 if (unlikely(obj_result == NULL)) {
225 goto exit_result_exception;
233 exit_result_exception:
237 return __BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_LONG(operand1, operand2);
240PyObject *BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
241 return _BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_LONG(operand1, operand2);
245static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_RSHIFT_OBJECT_LONG_OBJECT(PyObject *operand1,
246 PyObject *operand2) {
247 PyTypeObject *type2 = Py_TYPE(operand2);
251#pragma warning(disable : 4101)
253 NUITKA_MAY_BE_UNUSED
bool cbool_result;
254 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
259 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_rshift;
260 binaryfunc slot2 = NULL;
262 if (!(&PyLong_Type == type2)) {
265 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
267 if (slot1 == slot2) {
274 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
275 PyObject *x = slot2(operand1, operand2);
277 if (x != Py_NotImplemented) {
279 goto exit_binary_result_object;
282 Py_DECREF_IMMORTAL(x);
287 PyObject *x = slot1(operand1, operand2);
289 if (x != Py_NotImplemented) {
291 goto exit_binary_result_object;
294 Py_DECREF_IMMORTAL(x);
298 PyObject *x = slot2(operand1, operand2);
300 if (x != Py_NotImplemented) {
302 goto exit_binary_result_object;
305 Py_DECREF_IMMORTAL(x);
308#if PYTHON_VERSION < 0x300
309 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
310 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
313 PyObject *coerced1 = operand1;
314 PyObject *coerced2 = operand2;
316 int err = c1(&coerced1, &coerced2);
318 if (unlikely(err < 0)) {
319 goto exit_binary_exception;
323 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
325 if (likely(mv == NULL)) {
326 binaryfunc slot = mv->nb_rshift;
328 if (likely(slot != NULL)) {
329 PyObject *x = slot(coerced1, coerced2);
335 goto exit_binary_result_object;
345 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
348 PyObject *coerced1 = operand1;
349 PyObject *coerced2 = operand2;
351 int err = c2(&coerced2, &coerced1);
353 if (unlikely(err < 0)) {
354 goto exit_binary_exception;
358 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
360 if (likely(mv == NULL)) {
361 binaryfunc slot = mv->nb_rshift;
363 if (likely(slot != NULL)) {
364 PyObject *x = slot(coerced1, coerced2);
370 goto exit_binary_result_object;
382#if PYTHON_VERSION < 0x300
383 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'long' and '%s'", type2->tp_name);
385 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'int' and '%s'", type2->tp_name);
387 goto exit_binary_exception;
389exit_binary_result_object:
392exit_binary_exception:
395static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
396 CHECK_OBJECT(operand1);
397 assert(PyLong_CheckExact(operand1));
398 CHECK_OBJECT(operand2);
400 PyTypeObject *type2 = Py_TYPE(operand2);
402 if (&PyLong_Type == type2) {
410#pragma warning(disable : 4101)
412 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
413 NUITKA_MAY_BE_UNUSED
long clong_result;
418 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(operand1, operand2);
419 assert(x != Py_NotImplemented);
422 goto exit_result_object;
425 if (unlikely(obj_result == NULL)) {
426 goto exit_result_exception;
434 exit_result_exception:
438 return __BINARY_OPERATION_RSHIFT_OBJECT_LONG_OBJECT(operand1, operand2);
441PyObject *BINARY_OPERATION_RSHIFT_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
442 return _BINARY_OPERATION_RSHIFT_OBJECT_LONG_OBJECT(operand1, operand2);
446static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
447 CHECK_OBJECT(operand1);
448 assert(PyLong_CheckExact(operand1));
449 CHECK_OBJECT(operand2);
450 assert(PyLong_CheckExact(operand2));
457#pragma warning(disable : 4101)
459 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
460 NUITKA_MAY_BE_UNUSED
long clong_result;
465 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(operand1, operand2);
466 assert(x != Py_NotImplemented);
469 goto exit_result_object;
472 if (unlikely(obj_result == NULL)) {
473 goto exit_result_exception;
475 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
476 Py_DECREF(obj_result);
482exit_result_exception:
483 return NUITKA_BOOL_EXCEPTION;
486nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
487 return _BINARY_OPERATION_RSHIFT_NBOOL_LONG_LONG(operand1, operand2);
491static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_LONG(PyObject *operand1,
492 PyObject *operand2) {
493 PyTypeObject *type1 = Py_TYPE(operand1);
497#pragma warning(disable : 4101)
499 NUITKA_MAY_BE_UNUSED
bool cbool_result;
500 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
506 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
507 binaryfunc slot2 = NULL;
509 if (!(type1 == &PyLong_Type)) {
512 slot2 = PyLong_Type.tp_as_number->nb_rshift;
514 if (slot1 == slot2) {
520 PyObject *x = slot1(operand1, operand2);
522 if (x != Py_NotImplemented) {
524 goto exit_binary_result_object;
527 Py_DECREF_IMMORTAL(x);
531 PyObject *x = slot2(operand1, operand2);
533 if (x != Py_NotImplemented) {
535 goto exit_binary_result_object;
538 Py_DECREF_IMMORTAL(x);
541#if PYTHON_VERSION < 0x300
542 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
544 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
547 PyObject *coerced1 = operand1;
548 PyObject *coerced2 = operand2;
550 int err = c1(&coerced1, &coerced2);
552 if (unlikely(err < 0)) {
553 goto exit_binary_exception;
557 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
559 if (likely(mv == NULL)) {
560 binaryfunc slot = mv->nb_rshift;
562 if (likely(slot != NULL)) {
563 PyObject *x = slot(coerced1, coerced2);
569 goto exit_binary_result_object;
578 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
581 PyObject *coerced1 = operand1;
582 PyObject *coerced2 = operand2;
584 int err = c2(&coerced2, &coerced1);
586 if (unlikely(err < 0)) {
587 goto exit_binary_exception;
591 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
593 if (likely(mv == NULL)) {
594 binaryfunc slot = mv->nb_rshift;
596 if (likely(slot != NULL)) {
597 PyObject *x = slot(coerced1, coerced2);
603 goto exit_binary_result_object;
615#if PYTHON_VERSION < 0x300
616 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and 'long'", type1->tp_name);
618 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and 'int'", type1->tp_name);
620 goto exit_binary_exception;
622exit_binary_result_object:
623 if (unlikely(obj_result == NULL)) {
624 return NUITKA_BOOL_EXCEPTION;
628 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
629 Py_DECREF(obj_result);
633exit_binary_exception:
634 return NUITKA_BOOL_EXCEPTION;
636static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
637 CHECK_OBJECT(operand1);
638 CHECK_OBJECT(operand2);
639 assert(PyLong_CheckExact(operand2));
641 PyTypeObject *type1 = Py_TYPE(operand1);
643 if (type1 == &PyLong_Type) {
651#pragma warning(disable : 4101)
653 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
654 NUITKA_MAY_BE_UNUSED
long clong_result;
659 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(operand1, operand2);
660 assert(x != Py_NotImplemented);
663 goto exit_result_object;
666 if (unlikely(obj_result == NULL)) {
667 goto exit_result_exception;
669 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
670 Py_DECREF(obj_result);
676 exit_result_exception:
677 return NUITKA_BOOL_EXCEPTION;
680 return __BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_LONG(operand1, operand2);
683nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
684 return _BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_LONG(operand1, operand2);
688static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_RSHIFT_NBOOL_LONG_OBJECT(PyObject *operand1,
689 PyObject *operand2) {
690 PyTypeObject *type2 = Py_TYPE(operand2);
694#pragma warning(disable : 4101)
696 NUITKA_MAY_BE_UNUSED
bool cbool_result;
697 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
702 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_rshift;
703 binaryfunc slot2 = NULL;
705 if (!(&PyLong_Type == type2)) {
708 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
710 if (slot1 == slot2) {
717 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
718 PyObject *x = slot2(operand1, operand2);
720 if (x != Py_NotImplemented) {
722 goto exit_binary_result_object;
725 Py_DECREF_IMMORTAL(x);
730 PyObject *x = slot1(operand1, operand2);
732 if (x != Py_NotImplemented) {
734 goto exit_binary_result_object;
737 Py_DECREF_IMMORTAL(x);
741 PyObject *x = slot2(operand1, operand2);
743 if (x != Py_NotImplemented) {
745 goto exit_binary_result_object;
748 Py_DECREF_IMMORTAL(x);
751#if PYTHON_VERSION < 0x300
752 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
753 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
756 PyObject *coerced1 = operand1;
757 PyObject *coerced2 = operand2;
759 int err = c1(&coerced1, &coerced2);
761 if (unlikely(err < 0)) {
762 goto exit_binary_exception;
766 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
768 if (likely(mv == NULL)) {
769 binaryfunc slot = mv->nb_rshift;
771 if (likely(slot != NULL)) {
772 PyObject *x = slot(coerced1, coerced2);
778 goto exit_binary_result_object;
788 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
791 PyObject *coerced1 = operand1;
792 PyObject *coerced2 = operand2;
794 int err = c2(&coerced2, &coerced1);
796 if (unlikely(err < 0)) {
797 goto exit_binary_exception;
801 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
803 if (likely(mv == NULL)) {
804 binaryfunc slot = mv->nb_rshift;
806 if (likely(slot != NULL)) {
807 PyObject *x = slot(coerced1, coerced2);
813 goto exit_binary_result_object;
825#if PYTHON_VERSION < 0x300
826 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'long' and '%s'", type2->tp_name);
828 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'int' and '%s'", type2->tp_name);
830 goto exit_binary_exception;
832exit_binary_result_object:
833 if (unlikely(obj_result == NULL)) {
834 return NUITKA_BOOL_EXCEPTION;
838 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
839 Py_DECREF(obj_result);
843exit_binary_exception:
844 return NUITKA_BOOL_EXCEPTION;
846static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
847 CHECK_OBJECT(operand1);
848 assert(PyLong_CheckExact(operand1));
849 CHECK_OBJECT(operand2);
851 PyTypeObject *type2 = Py_TYPE(operand2);
853 if (&PyLong_Type == type2) {
861#pragma warning(disable : 4101)
863 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
864 NUITKA_MAY_BE_UNUSED
long clong_result;
869 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(operand1, operand2);
870 assert(x != Py_NotImplemented);
873 goto exit_result_object;
876 if (unlikely(obj_result == NULL)) {
877 goto exit_result_exception;
879 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
880 Py_DECREF(obj_result);
886 exit_result_exception:
887 return NUITKA_BOOL_EXCEPTION;
890 return __BINARY_OPERATION_RSHIFT_NBOOL_LONG_OBJECT(operand1, operand2);
893nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
894 return _BINARY_OPERATION_RSHIFT_NBOOL_LONG_OBJECT(operand1, operand2);
897#if PYTHON_VERSION < 0x300
899static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
900 CHECK_OBJECT(operand1);
901 assert(PyInt_CheckExact(operand1));
902 CHECK_OBJECT(operand2);
903 assert(PyInt_CheckExact(operand2));
910#pragma warning(disable : 4101)
912 NUITKA_MAY_BE_UNUSED
bool cbool_result;
913 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
914 NUITKA_MAY_BE_UNUSED
long clong_result;
915 NUITKA_MAY_BE_UNUSED
double cfloat_result;
920 CHECK_OBJECT(operand1);
921 assert(PyInt_CheckExact(operand1));
922 CHECK_OBJECT(operand2);
923 assert(PyInt_CheckExact(operand2));
925 const long a = PyInt_AS_LONG(operand1);
926 const long b = PyInt_AS_LONG(operand2);
928 if (unlikely(b < 0)) {
929 PyThreadState *tstate = PyThreadState_GET();
931 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
932 goto exit_result_exception;
936 if (a == 0 || b == 0) {
937 goto exit_result_ok_left;
938 }
else if (b >= LONG_BIT) {
940 goto exit_result_ok_const_int_neg_1;
942 goto exit_result_ok_const_int_0;
945 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
948 goto exit_result_ok_clong;
952 result = Nuitka_PyInt_FromLong(clong_result);
960exit_result_ok_const_int_0:
961 Py_INCREF(const_int_0);
962 result = const_int_0;
965exit_result_ok_const_int_neg_1:
966 Py_INCREF(const_int_neg_1);
967 result = const_int_neg_1;
973exit_result_exception:
977PyObject *BINARY_OPERATION_RSHIFT_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
978 return _BINARY_OPERATION_RSHIFT_OBJECT_INT_INT(operand1, operand2);
982#if PYTHON_VERSION < 0x300
984static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_INT(PyObject *operand1,
985 PyObject *operand2) {
986 PyTypeObject *type1 = Py_TYPE(operand1);
990#pragma warning(disable : 4101)
992 NUITKA_MAY_BE_UNUSED
bool cbool_result;
993 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
999 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
1000 binaryfunc slot2 = NULL;
1002 if (!(type1 == &PyInt_Type)) {
1005 slot2 = PyInt_Type.tp_as_number->nb_rshift;
1007 if (slot1 == slot2) {
1012 if (slot1 != NULL) {
1013 PyObject *x = slot1(operand1, operand2);
1015 if (x != Py_NotImplemented) {
1017 goto exit_binary_result_object;
1020 Py_DECREF_IMMORTAL(x);
1023 if (slot2 != NULL) {
1024 PyObject *x = slot2(operand1, operand2);
1026 if (x != Py_NotImplemented) {
1028 goto exit_binary_result_object;
1031 Py_DECREF_IMMORTAL(x);
1034#if PYTHON_VERSION < 0x300
1035 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1037 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1040 PyObject *coerced1 = operand1;
1041 PyObject *coerced2 = operand2;
1043 int err = c1(&coerced1, &coerced2);
1045 if (unlikely(err < 0)) {
1046 goto exit_binary_exception;
1050 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1052 if (likely(mv == NULL)) {
1053 binaryfunc slot = mv->nb_rshift;
1055 if (likely(slot != NULL)) {
1056 PyObject *x = slot(coerced1, coerced2);
1058 Py_DECREF(coerced1);
1059 Py_DECREF(coerced2);
1062 goto exit_binary_result_object;
1067 Py_DECREF(coerced1);
1068 Py_DECREF(coerced2);
1071 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
1074 PyObject *coerced1 = operand1;
1075 PyObject *coerced2 = operand2;
1077 int err = c2(&coerced2, &coerced1);
1079 if (unlikely(err < 0)) {
1080 goto exit_binary_exception;
1084 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1086 if (likely(mv == NULL)) {
1087 binaryfunc slot = mv->nb_rshift;
1089 if (likely(slot != NULL)) {
1090 PyObject *x = slot(coerced1, coerced2);
1092 Py_DECREF(coerced1);
1093 Py_DECREF(coerced2);
1096 goto exit_binary_result_object;
1101 Py_DECREF(coerced1);
1102 Py_DECREF(coerced2);
1108 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and 'int'", type1->tp_name);
1109 goto exit_binary_exception;
1111exit_binary_result_object:
1114exit_binary_exception:
1117static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
1118 CHECK_OBJECT(operand1);
1119 CHECK_OBJECT(operand2);
1120 assert(PyInt_CheckExact(operand2));
1122 PyTypeObject *type1 = Py_TYPE(operand1);
1124 if (type1 == &PyInt_Type) {
1130#if defined(_MSC_VER)
1131#pragma warning(push)
1132#pragma warning(disable : 4101)
1134 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1135 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1136 NUITKA_MAY_BE_UNUSED
long clong_result;
1137 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1138#if defined(_MSC_VER)
1142 CHECK_OBJECT(operand1);
1143 assert(PyInt_CheckExact(operand1));
1144 CHECK_OBJECT(operand2);
1145 assert(PyInt_CheckExact(operand2));
1147 const long a = PyInt_AS_LONG(operand1);
1148 const long b = PyInt_AS_LONG(operand2);
1150 if (unlikely(b < 0)) {
1151 PyThreadState *tstate = PyThreadState_GET();
1153 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1154 goto exit_result_exception;
1158 if (a == 0 || b == 0) {
1159 goto exit_result_ok_left;
1160 }
else if (b >= LONG_BIT) {
1162 goto exit_result_ok_const_int_neg_1;
1164 goto exit_result_ok_const_int_0;
1167 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
1170 goto exit_result_ok_clong;
1173 exit_result_ok_clong:
1174 result = Nuitka_PyInt_FromLong(clong_result);
1175 goto exit_result_ok;
1177 exit_result_ok_left:
1180 goto exit_result_ok;
1182 exit_result_ok_const_int_0:
1183 Py_INCREF(const_int_0);
1184 result = const_int_0;
1185 goto exit_result_ok;
1187 exit_result_ok_const_int_neg_1:
1188 Py_INCREF(const_int_neg_1);
1189 result = const_int_neg_1;
1190 goto exit_result_ok;
1195 exit_result_exception:
1199 return __BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_INT(operand1, operand2);
1202PyObject *BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
1203 return _BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_INT(operand1, operand2);
1207#if PYTHON_VERSION < 0x300
1209static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_RSHIFT_OBJECT_INT_OBJECT(PyObject *operand1,
1210 PyObject *operand2) {
1211 PyTypeObject *type2 = Py_TYPE(operand2);
1213#if defined(_MSC_VER)
1214#pragma warning(push)
1215#pragma warning(disable : 4101)
1217 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1218 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1219#if defined(_MSC_VER)
1223 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_rshift;
1224 binaryfunc slot2 = NULL;
1226 if (!(&PyInt_Type == type2)) {
1229 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
1231 if (slot1 == slot2) {
1236 if (slot1 != NULL) {
1237 if (slot2 != NULL) {
1238 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
1239 PyObject *x = slot2(operand1, operand2);
1241 if (x != Py_NotImplemented) {
1243 goto exit_binary_result_object;
1246 Py_DECREF_IMMORTAL(x);
1251 PyObject *x = slot1(operand1, operand2);
1253 if (x != Py_NotImplemented) {
1255 goto exit_binary_result_object;
1258 Py_DECREF_IMMORTAL(x);
1261 if (slot2 != NULL) {
1262 PyObject *x = slot2(operand1, operand2);
1264 if (x != Py_NotImplemented) {
1266 goto exit_binary_result_object;
1269 Py_DECREF_IMMORTAL(x);
1272#if PYTHON_VERSION < 0x300
1273 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1274 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
1277 PyObject *coerced1 = operand1;
1278 PyObject *coerced2 = operand2;
1280 int err = c1(&coerced1, &coerced2);
1282 if (unlikely(err < 0)) {
1283 goto exit_binary_exception;
1287 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1289 if (likely(mv == NULL)) {
1290 binaryfunc slot = mv->nb_rshift;
1292 if (likely(slot != NULL)) {
1293 PyObject *x = slot(coerced1, coerced2);
1295 Py_DECREF(coerced1);
1296 Py_DECREF(coerced2);
1299 goto exit_binary_result_object;
1304 Py_DECREF(coerced1);
1305 Py_DECREF(coerced2);
1309 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1312 PyObject *coerced1 = operand1;
1313 PyObject *coerced2 = operand2;
1315 int err = c2(&coerced2, &coerced1);
1317 if (unlikely(err < 0)) {
1318 goto exit_binary_exception;
1322 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1324 if (likely(mv == NULL)) {
1325 binaryfunc slot = mv->nb_rshift;
1327 if (likely(slot != NULL)) {
1328 PyObject *x = slot(coerced1, coerced2);
1330 Py_DECREF(coerced1);
1331 Py_DECREF(coerced2);
1334 goto exit_binary_result_object;
1339 Py_DECREF(coerced1);
1340 Py_DECREF(coerced2);
1346 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'int' and '%s'", type2->tp_name);
1347 goto exit_binary_exception;
1349exit_binary_result_object:
1352exit_binary_exception:
1355static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1356 CHECK_OBJECT(operand1);
1357 assert(PyInt_CheckExact(operand1));
1358 CHECK_OBJECT(operand2);
1360 PyTypeObject *type2 = Py_TYPE(operand2);
1362 if (&PyInt_Type == type2) {
1368#if defined(_MSC_VER)
1369#pragma warning(push)
1370#pragma warning(disable : 4101)
1372 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1373 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1374 NUITKA_MAY_BE_UNUSED
long clong_result;
1375 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1376#if defined(_MSC_VER)
1380 CHECK_OBJECT(operand1);
1381 assert(PyInt_CheckExact(operand1));
1382 CHECK_OBJECT(operand2);
1383 assert(PyInt_CheckExact(operand2));
1385 const long a = PyInt_AS_LONG(operand1);
1386 const long b = PyInt_AS_LONG(operand2);
1388 if (unlikely(b < 0)) {
1389 PyThreadState *tstate = PyThreadState_GET();
1391 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1392 goto exit_result_exception;
1396 if (a == 0 || b == 0) {
1397 goto exit_result_ok_left;
1398 }
else if (b >= LONG_BIT) {
1400 goto exit_result_ok_const_int_neg_1;
1402 goto exit_result_ok_const_int_0;
1405 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
1408 goto exit_result_ok_clong;
1411 exit_result_ok_clong:
1412 result = Nuitka_PyInt_FromLong(clong_result);
1413 goto exit_result_ok;
1415 exit_result_ok_left:
1418 goto exit_result_ok;
1420 exit_result_ok_const_int_0:
1421 Py_INCREF(const_int_0);
1422 result = const_int_0;
1423 goto exit_result_ok;
1425 exit_result_ok_const_int_neg_1:
1426 Py_INCREF(const_int_neg_1);
1427 result = const_int_neg_1;
1428 goto exit_result_ok;
1433 exit_result_exception:
1437 return __BINARY_OPERATION_RSHIFT_OBJECT_INT_OBJECT(operand1, operand2);
1440PyObject *BINARY_OPERATION_RSHIFT_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1441 return _BINARY_OPERATION_RSHIFT_OBJECT_INT_OBJECT(operand1, operand2);
1445#if PYTHON_VERSION < 0x300
1447static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
1448 CHECK_OBJECT(operand1);
1449 assert(PyInt_CheckExact(operand1));
1450 CHECK_OBJECT(operand2);
1451 assert(PyInt_CheckExact(operand2));
1456#if defined(_MSC_VER)
1457#pragma warning(push)
1458#pragma warning(disable : 4101)
1460 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1461 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1462 NUITKA_MAY_BE_UNUSED
long clong_result;
1463 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1464#if defined(_MSC_VER)
1468 CHECK_OBJECT(operand1);
1469 assert(PyInt_CheckExact(operand1));
1470 CHECK_OBJECT(operand2);
1471 assert(PyInt_CheckExact(operand2));
1473 const long a = PyInt_AS_LONG(operand1);
1474 const long b = PyInt_AS_LONG(operand2);
1476 if (unlikely(b < 0)) {
1477 PyThreadState *tstate = PyThreadState_GET();
1479 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1480 goto exit_result_exception;
1484 if (a == 0 || b == 0) {
1485 goto exit_result_ok_left;
1486 }
else if (b >= LONG_BIT) {
1488 goto exit_result_ok_const_int_neg_1;
1490 goto exit_result_ok_const_int_0;
1493 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
1496 goto exit_result_ok_clong;
1499exit_result_ok_clong:
1500 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1501 goto exit_result_ok;
1504 result = PyInt_AS_LONG(operand1) != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1505 goto exit_result_ok;
1507exit_result_ok_const_int_0:
1508 result = 0 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1509 goto exit_result_ok;
1511exit_result_ok_const_int_neg_1:
1512 result = -1 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1513 goto exit_result_ok;
1518exit_result_exception:
1519 return NUITKA_BOOL_EXCEPTION;
1522nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
1523 return _BINARY_OPERATION_RSHIFT_NBOOL_INT_INT(operand1, operand2);
1527#if PYTHON_VERSION < 0x300
1529static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_INT(PyObject *operand1,
1530 PyObject *operand2) {
1531 PyTypeObject *type1 = Py_TYPE(operand1);
1533#if defined(_MSC_VER)
1534#pragma warning(push)
1535#pragma warning(disable : 4101)
1537 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1538 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1539#if defined(_MSC_VER)
1544 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
1545 binaryfunc slot2 = NULL;
1547 if (!(type1 == &PyInt_Type)) {
1550 slot2 = PyInt_Type.tp_as_number->nb_rshift;
1552 if (slot1 == slot2) {
1557 if (slot1 != NULL) {
1558 PyObject *x = slot1(operand1, operand2);
1560 if (x != Py_NotImplemented) {
1562 goto exit_binary_result_object;
1565 Py_DECREF_IMMORTAL(x);
1568 if (slot2 != NULL) {
1569 PyObject *x = slot2(operand1, operand2);
1571 if (x != Py_NotImplemented) {
1573 goto exit_binary_result_object;
1576 Py_DECREF_IMMORTAL(x);
1579#if PYTHON_VERSION < 0x300
1580 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1582 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1585 PyObject *coerced1 = operand1;
1586 PyObject *coerced2 = operand2;
1588 int err = c1(&coerced1, &coerced2);
1590 if (unlikely(err < 0)) {
1591 goto exit_binary_exception;
1595 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1597 if (likely(mv == NULL)) {
1598 binaryfunc slot = mv->nb_rshift;
1600 if (likely(slot != NULL)) {
1601 PyObject *x = slot(coerced1, coerced2);
1603 Py_DECREF(coerced1);
1604 Py_DECREF(coerced2);
1607 goto exit_binary_result_object;
1612 Py_DECREF(coerced1);
1613 Py_DECREF(coerced2);
1616 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
1619 PyObject *coerced1 = operand1;
1620 PyObject *coerced2 = operand2;
1622 int err = c2(&coerced2, &coerced1);
1624 if (unlikely(err < 0)) {
1625 goto exit_binary_exception;
1629 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1631 if (likely(mv == NULL)) {
1632 binaryfunc slot = mv->nb_rshift;
1634 if (likely(slot != NULL)) {
1635 PyObject *x = slot(coerced1, coerced2);
1637 Py_DECREF(coerced1);
1638 Py_DECREF(coerced2);
1641 goto exit_binary_result_object;
1646 Py_DECREF(coerced1);
1647 Py_DECREF(coerced2);
1653 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and 'int'", type1->tp_name);
1654 goto exit_binary_exception;
1656exit_binary_result_object:
1657 if (unlikely(obj_result == NULL)) {
1658 return NUITKA_BOOL_EXCEPTION;
1662 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1663 Py_DECREF(obj_result);
1667exit_binary_exception:
1668 return NUITKA_BOOL_EXCEPTION;
1670static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
1671 CHECK_OBJECT(operand1);
1672 CHECK_OBJECT(operand2);
1673 assert(PyInt_CheckExact(operand2));
1675 PyTypeObject *type1 = Py_TYPE(operand1);
1677 if (type1 == &PyInt_Type) {
1683#if defined(_MSC_VER)
1684#pragma warning(push)
1685#pragma warning(disable : 4101)
1687 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1688 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1689 NUITKA_MAY_BE_UNUSED
long clong_result;
1690 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1691#if defined(_MSC_VER)
1695 CHECK_OBJECT(operand1);
1696 assert(PyInt_CheckExact(operand1));
1697 CHECK_OBJECT(operand2);
1698 assert(PyInt_CheckExact(operand2));
1700 const long a = PyInt_AS_LONG(operand1);
1701 const long b = PyInt_AS_LONG(operand2);
1703 if (unlikely(b < 0)) {
1704 PyThreadState *tstate = PyThreadState_GET();
1706 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1707 goto exit_result_exception;
1711 if (a == 0 || b == 0) {
1712 goto exit_result_ok_left;
1713 }
else if (b >= LONG_BIT) {
1715 goto exit_result_ok_const_int_neg_1;
1717 goto exit_result_ok_const_int_0;
1720 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
1723 goto exit_result_ok_clong;
1726 exit_result_ok_clong:
1727 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1728 goto exit_result_ok;
1730 exit_result_ok_left:
1731 result = PyInt_AS_LONG(operand1) != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1732 goto exit_result_ok;
1734 exit_result_ok_const_int_0:
1735 result = 0 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1736 goto exit_result_ok;
1738 exit_result_ok_const_int_neg_1:
1739 result = -1 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1740 goto exit_result_ok;
1745 exit_result_exception:
1746 return NUITKA_BOOL_EXCEPTION;
1749 return __BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_INT(operand1, operand2);
1752nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
1753 return _BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_INT(operand1, operand2);
1757#if PYTHON_VERSION < 0x300
1759static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_RSHIFT_NBOOL_INT_OBJECT(PyObject *operand1,
1760 PyObject *operand2) {
1761 PyTypeObject *type2 = Py_TYPE(operand2);
1763#if defined(_MSC_VER)
1764#pragma warning(push)
1765#pragma warning(disable : 4101)
1767 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1768 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1769#if defined(_MSC_VER)
1773 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_rshift;
1774 binaryfunc slot2 = NULL;
1776 if (!(&PyInt_Type == type2)) {
1779 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
1781 if (slot1 == slot2) {
1786 if (slot1 != NULL) {
1787 if (slot2 != NULL) {
1788 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
1789 PyObject *x = slot2(operand1, operand2);
1791 if (x != Py_NotImplemented) {
1793 goto exit_binary_result_object;
1796 Py_DECREF_IMMORTAL(x);
1801 PyObject *x = slot1(operand1, operand2);
1803 if (x != Py_NotImplemented) {
1805 goto exit_binary_result_object;
1808 Py_DECREF_IMMORTAL(x);
1811 if (slot2 != NULL) {
1812 PyObject *x = slot2(operand1, operand2);
1814 if (x != Py_NotImplemented) {
1816 goto exit_binary_result_object;
1819 Py_DECREF_IMMORTAL(x);
1822#if PYTHON_VERSION < 0x300
1823 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1824 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
1827 PyObject *coerced1 = operand1;
1828 PyObject *coerced2 = operand2;
1830 int err = c1(&coerced1, &coerced2);
1832 if (unlikely(err < 0)) {
1833 goto exit_binary_exception;
1837 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1839 if (likely(mv == NULL)) {
1840 binaryfunc slot = mv->nb_rshift;
1842 if (likely(slot != NULL)) {
1843 PyObject *x = slot(coerced1, coerced2);
1845 Py_DECREF(coerced1);
1846 Py_DECREF(coerced2);
1849 goto exit_binary_result_object;
1854 Py_DECREF(coerced1);
1855 Py_DECREF(coerced2);
1859 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1862 PyObject *coerced1 = operand1;
1863 PyObject *coerced2 = operand2;
1865 int err = c2(&coerced2, &coerced1);
1867 if (unlikely(err < 0)) {
1868 goto exit_binary_exception;
1872 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1874 if (likely(mv == NULL)) {
1875 binaryfunc slot = mv->nb_rshift;
1877 if (likely(slot != NULL)) {
1878 PyObject *x = slot(coerced1, coerced2);
1880 Py_DECREF(coerced1);
1881 Py_DECREF(coerced2);
1884 goto exit_binary_result_object;
1889 Py_DECREF(coerced1);
1890 Py_DECREF(coerced2);
1896 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'int' and '%s'", type2->tp_name);
1897 goto exit_binary_exception;
1899exit_binary_result_object:
1900 if (unlikely(obj_result == NULL)) {
1901 return NUITKA_BOOL_EXCEPTION;
1905 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1906 Py_DECREF(obj_result);
1910exit_binary_exception:
1911 return NUITKA_BOOL_EXCEPTION;
1913static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1914 CHECK_OBJECT(operand1);
1915 assert(PyInt_CheckExact(operand1));
1916 CHECK_OBJECT(operand2);
1918 PyTypeObject *type2 = Py_TYPE(operand2);
1920 if (&PyInt_Type == type2) {
1926#if defined(_MSC_VER)
1927#pragma warning(push)
1928#pragma warning(disable : 4101)
1930 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1931 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1932 NUITKA_MAY_BE_UNUSED
long clong_result;
1933 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1934#if defined(_MSC_VER)
1938 CHECK_OBJECT(operand1);
1939 assert(PyInt_CheckExact(operand1));
1940 CHECK_OBJECT(operand2);
1941 assert(PyInt_CheckExact(operand2));
1943 const long a = PyInt_AS_LONG(operand1);
1944 const long b = PyInt_AS_LONG(operand2);
1946 if (unlikely(b < 0)) {
1947 PyThreadState *tstate = PyThreadState_GET();
1949 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1950 goto exit_result_exception;
1954 if (a == 0 || b == 0) {
1955 goto exit_result_ok_left;
1956 }
else if (b >= LONG_BIT) {
1958 goto exit_result_ok_const_int_neg_1;
1960 goto exit_result_ok_const_int_0;
1963 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
1966 goto exit_result_ok_clong;
1969 exit_result_ok_clong:
1970 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1971 goto exit_result_ok;
1973 exit_result_ok_left:
1974 result = PyInt_AS_LONG(operand1) != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1975 goto exit_result_ok;
1977 exit_result_ok_const_int_0:
1978 result = 0 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1979 goto exit_result_ok;
1981 exit_result_ok_const_int_neg_1:
1982 result = -1 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1983 goto exit_result_ok;
1988 exit_result_exception:
1989 return NUITKA_BOOL_EXCEPTION;
1992 return __BINARY_OPERATION_RSHIFT_NBOOL_INT_OBJECT(operand1, operand2);
1995nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1996 return _BINARY_OPERATION_RSHIFT_NBOOL_INT_OBJECT(operand1, operand2);
2000#if PYTHON_VERSION < 0x300
2002static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
2003 CHECK_OBJECT(operand1);
2004 assert(PyLong_CheckExact(operand1));
2005 CHECK_OBJECT(operand2);
2006 assert(PyInt_CheckExact(operand2));
2008#if defined(_MSC_VER)
2009#pragma warning(push)
2010#pragma warning(disable : 4101)
2012 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2013 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2014#if defined(_MSC_VER)
2018 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_rshift;
2021 if (slot1 != NULL) {
2022 PyObject *x = slot1(operand1, operand2);
2024 if (x != Py_NotImplemented) {
2026 goto exit_binary_result_object;
2029 Py_DECREF_IMMORTAL(x);
2034 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'long' and 'int'");
2035 goto exit_binary_exception;
2037exit_binary_result_object:
2040exit_binary_exception:
2044PyObject *BINARY_OPERATION_RSHIFT_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
2045 return _BINARY_OPERATION_RSHIFT_OBJECT_LONG_INT(operand1, operand2);
2049#if PYTHON_VERSION < 0x300
2051static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_INT_LONG(PyObject *operand1, PyObject *operand2) {
2052 CHECK_OBJECT(operand1);
2053 assert(PyInt_CheckExact(operand1));
2054 CHECK_OBJECT(operand2);
2055 assert(PyLong_CheckExact(operand2));
2057#if defined(_MSC_VER)
2058#pragma warning(push)
2059#pragma warning(disable : 4101)
2061 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2062 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2063#if defined(_MSC_VER)
2068 binaryfunc slot2 = NULL;
2073 slot2 = PyLong_Type.tp_as_number->nb_rshift;
2076 if (slot2 != NULL) {
2077 PyObject *x = slot2(operand1, operand2);
2079 if (x != Py_NotImplemented) {
2081 goto exit_binary_result_object;
2084 Py_DECREF_IMMORTAL(x);
2089 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'int' and 'long'");
2090 goto exit_binary_exception;
2092exit_binary_result_object:
2095exit_binary_exception:
2099PyObject *BINARY_OPERATION_RSHIFT_OBJECT_INT_LONG(PyObject *operand1, PyObject *operand2) {
2100 return _BINARY_OPERATION_RSHIFT_OBJECT_INT_LONG(operand1, operand2);
2104#if PYTHON_VERSION < 0x300
2106static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
2107 CHECK_OBJECT(operand1);
2108 assert(PyLong_CheckExact(operand1));
2109 CHECK_OBJECT(operand2);
2110 assert(PyInt_CheckExact(operand2));
2112#if defined(_MSC_VER)
2113#pragma warning(push)
2114#pragma warning(disable : 4101)
2116 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2117 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2118#if defined(_MSC_VER)
2122 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_rshift;
2125 if (slot1 != NULL) {
2126 PyObject *x = slot1(operand1, operand2);
2128 if (x != Py_NotImplemented) {
2130 goto exit_binary_result_object;
2133 Py_DECREF_IMMORTAL(x);
2138 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'long' and 'int'");
2139 goto exit_binary_exception;
2141exit_binary_result_object:
2142 if (unlikely(obj_result == NULL)) {
2143 return NUITKA_BOOL_EXCEPTION;
2147 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2148 Py_DECREF(obj_result);
2152exit_binary_exception:
2153 return NUITKA_BOOL_EXCEPTION;
2156nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
2157 return _BINARY_OPERATION_RSHIFT_NBOOL_LONG_INT(operand1, operand2);
2161#if PYTHON_VERSION < 0x300
2163static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_INT_LONG(PyObject *operand1, PyObject *operand2) {
2164 CHECK_OBJECT(operand1);
2165 assert(PyInt_CheckExact(operand1));
2166 CHECK_OBJECT(operand2);
2167 assert(PyLong_CheckExact(operand2));
2169#if defined(_MSC_VER)
2170#pragma warning(push)
2171#pragma warning(disable : 4101)
2173 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2174 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2175#if defined(_MSC_VER)
2180 binaryfunc slot2 = NULL;
2185 slot2 = PyLong_Type.tp_as_number->nb_rshift;
2188 if (slot2 != NULL) {
2189 PyObject *x = slot2(operand1, operand2);
2191 if (x != Py_NotImplemented) {
2193 goto exit_binary_result_object;
2196 Py_DECREF_IMMORTAL(x);
2201 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: 'int' and 'long'");
2202 goto exit_binary_exception;
2204exit_binary_result_object:
2205 if (unlikely(obj_result == NULL)) {
2206 return NUITKA_BOOL_EXCEPTION;
2210 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2211 Py_DECREF(obj_result);
2215exit_binary_exception:
2216 return NUITKA_BOOL_EXCEPTION;
2219nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_INT_LONG(PyObject *operand1, PyObject *operand2) {
2220 return _BINARY_OPERATION_RSHIFT_NBOOL_INT_LONG(operand1, operand2);
2225static PyObject *_BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2226 CHECK_OBJECT(operand1);
2227 CHECK_OBJECT(operand2);
2229#if PYTHON_VERSION < 0x300
2230 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
2234#if defined(_MSC_VER)
2235#pragma warning(push)
2236#pragma warning(disable : 4101)
2238 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2239 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2240 NUITKA_MAY_BE_UNUSED
long clong_result;
2241 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2242#if defined(_MSC_VER)
2246 CHECK_OBJECT(operand1);
2247 assert(PyInt_CheckExact(operand1));
2248 CHECK_OBJECT(operand2);
2249 assert(PyInt_CheckExact(operand2));
2251 const long a = PyInt_AS_LONG(operand1);
2252 const long b = PyInt_AS_LONG(operand2);
2254 if (unlikely(b < 0)) {
2255 PyThreadState *tstate = PyThreadState_GET();
2257 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
2258 goto exit_result_exception;
2262 if (a == 0 || b == 0) {
2263 goto exit_result_ok_left;
2264 }
else if (b >= LONG_BIT) {
2266 goto exit_result_ok_const_int_neg_1;
2268 goto exit_result_ok_const_int_0;
2271 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
2274 goto exit_result_ok_clong;
2277 exit_result_ok_clong:
2278 result = Nuitka_PyInt_FromLong(clong_result);
2279 goto exit_result_ok;
2281 exit_result_ok_left:
2284 goto exit_result_ok;
2286 exit_result_ok_const_int_0:
2287 Py_INCREF(const_int_0);
2288 result = const_int_0;
2289 goto exit_result_ok;
2291 exit_result_ok_const_int_neg_1:
2292 Py_INCREF(const_int_neg_1);
2293 result = const_int_neg_1;
2294 goto exit_result_ok;
2299 exit_result_exception:
2304 PyTypeObject *type1 = Py_TYPE(operand1);
2305 PyTypeObject *type2 = Py_TYPE(operand2);
2307#if defined(_MSC_VER)
2308#pragma warning(push)
2309#pragma warning(disable : 4101)
2311 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2312 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2313#if defined(_MSC_VER)
2318 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
2319 binaryfunc slot2 = NULL;
2321 if (!(type1 == type2)) {
2324 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
2326 if (slot1 == slot2) {
2331 if (slot1 != NULL) {
2332 if (slot2 != NULL) {
2333 if (Nuitka_Type_IsSubtype(type2, type1)) {
2334 PyObject *x = slot2(operand1, operand2);
2336 if (x != Py_NotImplemented) {
2338 goto exit_binary_result_object;
2341 Py_DECREF_IMMORTAL(x);
2346 PyObject *x = slot1(operand1, operand2);
2348 if (x != Py_NotImplemented) {
2350 goto exit_binary_result_object;
2353 Py_DECREF_IMMORTAL(x);
2356 if (slot2 != NULL) {
2357 PyObject *x = slot2(operand1, operand2);
2359 if (x != Py_NotImplemented) {
2361 goto exit_binary_result_object;
2364 Py_DECREF_IMMORTAL(x);
2367#if PYTHON_VERSION < 0x300
2368 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
2370 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2373 PyObject *coerced1 = operand1;
2374 PyObject *coerced2 = operand2;
2376 int err = c1(&coerced1, &coerced2);
2378 if (unlikely(err < 0)) {
2379 goto exit_binary_exception;
2383 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2385 if (likely(mv == NULL)) {
2386 binaryfunc slot = mv->nb_rshift;
2388 if (likely(slot != NULL)) {
2389 PyObject *x = slot(coerced1, coerced2);
2391 Py_DECREF(coerced1);
2392 Py_DECREF(coerced2);
2395 goto exit_binary_result_object;
2400 Py_DECREF(coerced1);
2401 Py_DECREF(coerced2);
2405 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2408 PyObject *coerced1 = operand1;
2409 PyObject *coerced2 = operand2;
2411 int err = c2(&coerced2, &coerced1);
2413 if (unlikely(err < 0)) {
2414 goto exit_binary_exception;
2418 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2420 if (likely(mv == NULL)) {
2421 binaryfunc slot = mv->nb_rshift;
2423 if (likely(slot != NULL)) {
2424 PyObject *x = slot(coerced1, coerced2);
2426 Py_DECREF(coerced1);
2427 Py_DECREF(coerced2);
2430 goto exit_binary_result_object;
2435 Py_DECREF(coerced1);
2436 Py_DECREF(coerced2);
2442 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and '%s'", type1->tp_name, type2->tp_name);
2443 goto exit_binary_exception;
2445exit_binary_result_object:
2448exit_binary_exception:
2452PyObject *BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2453 return _BINARY_OPERATION_RSHIFT_OBJECT_OBJECT_OBJECT(operand1, operand2);
2457static nuitka_bool _BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2458 CHECK_OBJECT(operand1);
2459 CHECK_OBJECT(operand2);
2461#if PYTHON_VERSION < 0x300
2462 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
2466#if defined(_MSC_VER)
2467#pragma warning(push)
2468#pragma warning(disable : 4101)
2470 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2471 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2472 NUITKA_MAY_BE_UNUSED
long clong_result;
2473 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2474#if defined(_MSC_VER)
2478 CHECK_OBJECT(operand1);
2479 assert(PyInt_CheckExact(operand1));
2480 CHECK_OBJECT(operand2);
2481 assert(PyInt_CheckExact(operand2));
2483 const long a = PyInt_AS_LONG(operand1);
2484 const long b = PyInt_AS_LONG(operand2);
2486 if (unlikely(b < 0)) {
2487 PyThreadState *tstate = PyThreadState_GET();
2489 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
2490 goto exit_result_exception;
2494 if (a == 0 || b == 0) {
2495 goto exit_result_ok_left;
2496 }
else if (b >= LONG_BIT) {
2498 goto exit_result_ok_const_int_neg_1;
2500 goto exit_result_ok_const_int_0;
2503 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
2506 goto exit_result_ok_clong;
2509 exit_result_ok_clong:
2510 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2511 goto exit_result_ok;
2513 exit_result_ok_left:
2514 result = PyInt_AS_LONG(operand1) != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2515 goto exit_result_ok;
2517 exit_result_ok_const_int_0:
2518 result = 0 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2519 goto exit_result_ok;
2521 exit_result_ok_const_int_neg_1:
2522 result = -1 != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2523 goto exit_result_ok;
2528 exit_result_exception:
2529 return NUITKA_BOOL_EXCEPTION;
2533 PyTypeObject *type1 = Py_TYPE(operand1);
2534 PyTypeObject *type2 = Py_TYPE(operand2);
2536#if defined(_MSC_VER)
2537#pragma warning(push)
2538#pragma warning(disable : 4101)
2540 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2541 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2542#if defined(_MSC_VER)
2547 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
2548 binaryfunc slot2 = NULL;
2550 if (!(type1 == type2)) {
2553 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
2555 if (slot1 == slot2) {
2560 if (slot1 != NULL) {
2561 if (slot2 != NULL) {
2562 if (Nuitka_Type_IsSubtype(type2, type1)) {
2563 PyObject *x = slot2(operand1, operand2);
2565 if (x != Py_NotImplemented) {
2567 goto exit_binary_result_object;
2570 Py_DECREF_IMMORTAL(x);
2575 PyObject *x = slot1(operand1, operand2);
2577 if (x != Py_NotImplemented) {
2579 goto exit_binary_result_object;
2582 Py_DECREF_IMMORTAL(x);
2585 if (slot2 != NULL) {
2586 PyObject *x = slot2(operand1, operand2);
2588 if (x != Py_NotImplemented) {
2590 goto exit_binary_result_object;
2593 Py_DECREF_IMMORTAL(x);
2596#if PYTHON_VERSION < 0x300
2597 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
2599 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2602 PyObject *coerced1 = operand1;
2603 PyObject *coerced2 = operand2;
2605 int err = c1(&coerced1, &coerced2);
2607 if (unlikely(err < 0)) {
2608 goto exit_binary_exception;
2612 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2614 if (likely(mv == NULL)) {
2615 binaryfunc slot = mv->nb_rshift;
2617 if (likely(slot != NULL)) {
2618 PyObject *x = slot(coerced1, coerced2);
2620 Py_DECREF(coerced1);
2621 Py_DECREF(coerced2);
2624 goto exit_binary_result_object;
2629 Py_DECREF(coerced1);
2630 Py_DECREF(coerced2);
2634 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2637 PyObject *coerced1 = operand1;
2638 PyObject *coerced2 = operand2;
2640 int err = c2(&coerced2, &coerced1);
2642 if (unlikely(err < 0)) {
2643 goto exit_binary_exception;
2647 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2649 if (likely(mv == NULL)) {
2650 binaryfunc slot = mv->nb_rshift;
2652 if (likely(slot != NULL)) {
2653 PyObject *x = slot(coerced1, coerced2);
2655 Py_DECREF(coerced1);
2656 Py_DECREF(coerced2);
2659 goto exit_binary_result_object;
2664 Py_DECREF(coerced1);
2665 Py_DECREF(coerced2);
2671 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>: '%s' and '%s'", type1->tp_name, type2->tp_name);
2672 goto exit_binary_exception;
2674exit_binary_result_object:
2675 if (unlikely(obj_result == NULL)) {
2676 return NUITKA_BOOL_EXCEPTION;
2680 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2681 Py_DECREF(obj_result);
2685exit_binary_exception:
2686 return NUITKA_BOOL_EXCEPTION;
2689nuitka_bool BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
2690 return _BINARY_OPERATION_RSHIFT_NBOOL_OBJECT_OBJECT(operand1, operand2);