7#include "nuitka/prelude.h"
13static inline bool _INPLACE_OPERATION_RSHIFT_LONG_LONG(PyObject **operand1, PyObject *operand2) {
16 CHECK_OBJECT(*operand1);
17 assert(PyLong_CheckExact(*operand1));
18 CHECK_OBJECT(operand2);
19 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;
44 *operand1 = obj_result;
54bool INPLACE_OPERATION_RSHIFT_LONG_LONG(PyObject **operand1, PyObject *operand2) {
55 return _INPLACE_OPERATION_RSHIFT_LONG_LONG(operand1, operand2);
59static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_RSHIFT_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
60 PyTypeObject *type1 = Py_TYPE(*operand1);
64#pragma warning(disable : 4101)
66 NUITKA_MAY_BE_UNUSED
bool cbool_result;
67 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
73 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_rshift : NULL;
76 PyObject *x = islot(*operand1, operand2);
78 if (x != Py_NotImplemented) {
80 goto exit_inplace_result_object;
83 Py_DECREF_IMMORTAL(x);
88 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
89 binaryfunc slot2 = NULL;
91 if (!(type1 == &PyLong_Type)) {
94 slot2 = PyLong_Type.tp_as_number->nb_rshift;
102 PyObject *x = slot1(*operand1, operand2);
104 if (x != Py_NotImplemented) {
106 goto exit_inplace_result_object;
109 Py_DECREF_IMMORTAL(x);
113 PyObject *x = slot2(*operand1, operand2);
115 if (x != Py_NotImplemented) {
117 goto exit_inplace_result_object;
120 Py_DECREF_IMMORTAL(x);
123#if PYTHON_VERSION < 0x300
124 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
126 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
129 PyObject *coerced1 = *operand1;
130 PyObject *coerced2 = operand2;
132 int err = c1(&coerced1, &coerced2);
134 if (unlikely(err < 0)) {
135 goto exit_inplace_exception;
139 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
141 if (likely(mv == NULL)) {
142 binaryfunc slot = mv->nb_rshift;
144 if (likely(slot != NULL)) {
145 PyObject *x = slot(coerced1, coerced2);
151 goto exit_inplace_result_object;
160 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
163 PyObject *coerced1 = *operand1;
164 PyObject *coerced2 = operand2;
166 int err = c2(&coerced2, &coerced1);
168 if (unlikely(err < 0)) {
169 goto exit_inplace_exception;
173 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
175 if (likely(mv == NULL)) {
176 binaryfunc slot = mv->nb_rshift;
178 if (likely(slot != NULL)) {
179 PyObject *x = slot(coerced1, coerced2);
185 goto exit_inplace_result_object;
197#if PYTHON_VERSION < 0x300
198 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: '%s' and 'long'", type1->tp_name);
200 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: '%s' and 'int'", type1->tp_name);
202 goto exit_inplace_exception;
205exit_inplace_result_object:
206 if (unlikely(obj_result == NULL)) {
211 Py_DECREF(*operand1);
215 *operand1 = obj_result;
219exit_inplace_exception:
222static inline bool _INPLACE_OPERATION_RSHIFT_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
225 CHECK_OBJECT(*operand1);
226 CHECK_OBJECT(operand2);
227 assert(PyLong_CheckExact(operand2));
229 PyTypeObject *type1 = Py_TYPE(*operand1);
231 if (type1 == &PyLong_Type) {
237#pragma warning(disable : 4101)
239 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
240 NUITKA_MAY_BE_UNUSED
long clong_result;
245 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(*operand1, operand2);
246 assert(x != Py_NotImplemented);
249 goto exit_result_object;
252 if (unlikely(obj_result == NULL)) {
253 goto exit_result_exception;
256 Py_DECREF(*operand1);
257 *operand1 = obj_result;
263 exit_result_exception:
267 return __INPLACE_OPERATION_RSHIFT_OBJECT_LONG(operand1, operand2);
270bool INPLACE_OPERATION_RSHIFT_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
271 return _INPLACE_OPERATION_RSHIFT_OBJECT_LONG(operand1, operand2);
275static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_RSHIFT_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
276 PyTypeObject *type2 = Py_TYPE(operand2);
280#pragma warning(disable : 4101)
282 NUITKA_MAY_BE_UNUSED
bool cbool_result;
283 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
291 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_rshift;
292 binaryfunc slot2 = NULL;
294 if (!(&PyLong_Type == type2)) {
298 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
300 if (slot1 == slot2) {
307 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
308 PyObject *x = slot2(*operand1, operand2);
310 if (x != Py_NotImplemented) {
312 goto exit_inplace_result_object;
315 Py_DECREF_IMMORTAL(x);
320 PyObject *x = slot1(*operand1, operand2);
322 if (x != Py_NotImplemented) {
324 goto exit_inplace_result_object;
327 Py_DECREF_IMMORTAL(x);
331 PyObject *x = slot2(*operand1, operand2);
333 if (x != Py_NotImplemented) {
335 goto exit_inplace_result_object;
338 Py_DECREF_IMMORTAL(x);
341#if PYTHON_VERSION < 0x300
342 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
343 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
346 PyObject *coerced1 = *operand1;
347 PyObject *coerced2 = operand2;
349 int err = c1(&coerced1, &coerced2);
351 if (unlikely(err < 0)) {
352 goto exit_inplace_exception;
356 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
358 if (likely(mv == NULL)) {
359 binaryfunc slot = mv->nb_rshift;
361 if (likely(slot != NULL)) {
362 PyObject *x = slot(coerced1, coerced2);
368 goto exit_inplace_result_object;
378 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
381 PyObject *coerced1 = *operand1;
382 PyObject *coerced2 = operand2;
384 int err = c2(&coerced2, &coerced1);
386 if (unlikely(err < 0)) {
387 goto exit_inplace_exception;
391 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
393 if (likely(mv == NULL)) {
394 binaryfunc slot = mv->nb_rshift;
396 if (likely(slot != NULL)) {
397 PyObject *x = slot(coerced1, coerced2);
403 goto exit_inplace_result_object;
415#if PYTHON_VERSION < 0x300
416 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: 'long' and '%s'", type2->tp_name);
418 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: 'int' and '%s'", type2->tp_name);
420 goto exit_inplace_exception;
423exit_inplace_result_object:
424 if (unlikely(obj_result == NULL)) {
429 Py_DECREF(*operand1);
433 *operand1 = obj_result;
437exit_inplace_exception:
440static inline bool _INPLACE_OPERATION_RSHIFT_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
443 CHECK_OBJECT(*operand1);
444 assert(PyLong_CheckExact(*operand1));
445 CHECK_OBJECT(operand2);
447 PyTypeObject *type2 = Py_TYPE(operand2);
449 if (&PyLong_Type == type2) {
455#pragma warning(disable : 4101)
457 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
458 NUITKA_MAY_BE_UNUSED
long clong_result;
463 PyObject *x = PyLong_Type.tp_as_number->nb_rshift(*operand1, operand2);
464 assert(x != Py_NotImplemented);
467 goto exit_result_object;
470 if (unlikely(obj_result == NULL)) {
471 goto exit_result_exception;
474 Py_DECREF(*operand1);
475 *operand1 = obj_result;
481 exit_result_exception:
485 return __INPLACE_OPERATION_RSHIFT_LONG_OBJECT(operand1, operand2);
488bool INPLACE_OPERATION_RSHIFT_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
489 return _INPLACE_OPERATION_RSHIFT_LONG_OBJECT(operand1, operand2);
492#if PYTHON_VERSION < 0x300
494static inline bool _INPLACE_OPERATION_RSHIFT_INT_INT(PyObject **operand1, PyObject *operand2) {
497 CHECK_OBJECT(*operand1);
498 assert(PyInt_CheckExact(*operand1));
499 CHECK_OBJECT(operand2);
500 assert(PyInt_CheckExact(operand2));
505#pragma warning(disable : 4101)
507 NUITKA_MAY_BE_UNUSED
bool cbool_result;
508 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
509 NUITKA_MAY_BE_UNUSED
long clong_result;
510 NUITKA_MAY_BE_UNUSED
double cfloat_result;
515 CHECK_OBJECT(*operand1);
516 assert(PyInt_CheckExact(*operand1));
517 CHECK_OBJECT(operand2);
518 assert(PyInt_CheckExact(operand2));
520 const long a = PyInt_AS_LONG(*operand1);
521 const long b = PyInt_AS_LONG(operand2);
523 if (unlikely(b < 0)) {
524 PyThreadState *tstate = PyThreadState_GET();
526 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
527 goto exit_result_exception;
531 if (a == 0 || b == 0) {
532 goto exit_result_ok_left;
533 }
else if (b >= LONG_BIT) {
535 goto exit_result_ok_const_int_neg_1;
537 goto exit_result_ok_const_int_0;
540 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
543 goto exit_result_ok_clong;
549 Py_DECREF(*operand1);
553 *operand1 = Nuitka_PyInt_FromLong(clong_result);
559exit_result_ok_const_int_0:
561 Py_DECREF(*operand1);
562 Py_INCREF(const_int_0);
563 *operand1 = const_int_0;
566exit_result_ok_const_int_neg_1:
568 Py_DECREF(*operand1);
569 Py_INCREF(const_int_neg_1);
570 *operand1 = const_int_neg_1;
576exit_result_exception:
580bool INPLACE_OPERATION_RSHIFT_INT_INT(PyObject **operand1, PyObject *operand2) {
581 return _INPLACE_OPERATION_RSHIFT_INT_INT(operand1, operand2);
585#if PYTHON_VERSION < 0x300
587static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_RSHIFT_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
588 PyTypeObject *type1 = Py_TYPE(*operand1);
592#pragma warning(disable : 4101)
594 NUITKA_MAY_BE_UNUSED
bool cbool_result;
595 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
601 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_rshift : NULL;
604 PyObject *x = islot(*operand1, operand2);
606 if (x != Py_NotImplemented) {
608 goto exit_inplace_result_object;
611 Py_DECREF_IMMORTAL(x);
616 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
617 binaryfunc slot2 = NULL;
619 if (!(type1 == &PyInt_Type)) {
622 slot2 = PyInt_Type.tp_as_number->nb_rshift;
624 if (slot1 == slot2) {
630 PyObject *x = slot1(*operand1, operand2);
632 if (x != Py_NotImplemented) {
634 goto exit_inplace_result_object;
637 Py_DECREF_IMMORTAL(x);
641 PyObject *x = slot2(*operand1, operand2);
643 if (x != Py_NotImplemented) {
645 goto exit_inplace_result_object;
648 Py_DECREF_IMMORTAL(x);
651#if PYTHON_VERSION < 0x300
652 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
654 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
657 PyObject *coerced1 = *operand1;
658 PyObject *coerced2 = operand2;
660 int err = c1(&coerced1, &coerced2);
662 if (unlikely(err < 0)) {
663 goto exit_inplace_exception;
667 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
669 if (likely(mv == NULL)) {
670 binaryfunc slot = mv->nb_rshift;
672 if (likely(slot != NULL)) {
673 PyObject *x = slot(coerced1, coerced2);
679 goto exit_inplace_result_object;
688 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
691 PyObject *coerced1 = *operand1;
692 PyObject *coerced2 = operand2;
694 int err = c2(&coerced2, &coerced1);
696 if (unlikely(err < 0)) {
697 goto exit_inplace_exception;
701 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
703 if (likely(mv == NULL)) {
704 binaryfunc slot = mv->nb_rshift;
706 if (likely(slot != NULL)) {
707 PyObject *x = slot(coerced1, coerced2);
713 goto exit_inplace_result_object;
725 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: '%s' and 'int'", type1->tp_name);
726 goto exit_inplace_exception;
729exit_inplace_result_object:
730 if (unlikely(obj_result == NULL)) {
735 Py_DECREF(*operand1);
739 *operand1 = obj_result;
743exit_inplace_exception:
746static inline bool _INPLACE_OPERATION_RSHIFT_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
749 CHECK_OBJECT(*operand1);
750 CHECK_OBJECT(operand2);
751 assert(PyInt_CheckExact(operand2));
753 PyTypeObject *type1 = Py_TYPE(*operand1);
755 if (type1 == &PyInt_Type) {
761#pragma warning(disable : 4101)
763 NUITKA_MAY_BE_UNUSED
bool cbool_result;
764 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
765 NUITKA_MAY_BE_UNUSED
long clong_result;
766 NUITKA_MAY_BE_UNUSED
double cfloat_result;
771 CHECK_OBJECT(*operand1);
772 assert(PyInt_CheckExact(*operand1));
773 CHECK_OBJECT(operand2);
774 assert(PyInt_CheckExact(operand2));
776 const long a = PyInt_AS_LONG(*operand1);
777 const long b = PyInt_AS_LONG(operand2);
779 if (unlikely(b < 0)) {
780 PyThreadState *tstate = PyThreadState_GET();
782 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
783 goto exit_result_exception;
787 if (a == 0 || b == 0) {
788 goto exit_result_ok_left;
789 }
else if (b >= LONG_BIT) {
791 goto exit_result_ok_const_int_neg_1;
793 goto exit_result_ok_const_int_0;
796 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
799 goto exit_result_ok_clong;
802 exit_result_ok_clong:
805 Py_DECREF(*operand1);
809 *operand1 = Nuitka_PyInt_FromLong(clong_result);
815 exit_result_ok_const_int_0:
817 Py_DECREF(*operand1);
818 Py_INCREF(const_int_0);
819 *operand1 = const_int_0;
822 exit_result_ok_const_int_neg_1:
824 Py_DECREF(*operand1);
825 Py_INCREF(const_int_neg_1);
826 *operand1 = const_int_neg_1;
832 exit_result_exception:
836 return __INPLACE_OPERATION_RSHIFT_OBJECT_INT(operand1, operand2);
839bool INPLACE_OPERATION_RSHIFT_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
840 return _INPLACE_OPERATION_RSHIFT_OBJECT_INT(operand1, operand2);
844#if PYTHON_VERSION < 0x300
846static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_RSHIFT_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
847 PyTypeObject *type2 = Py_TYPE(operand2);
851#pragma warning(disable : 4101)
853 NUITKA_MAY_BE_UNUSED
bool cbool_result;
854 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
862 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_rshift;
863 binaryfunc slot2 = NULL;
865 if (!(&PyInt_Type == type2)) {
869 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
871 if (slot1 == slot2) {
878 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
879 PyObject *x = slot2(*operand1, operand2);
881 if (x != Py_NotImplemented) {
883 goto exit_inplace_result_object;
886 Py_DECREF_IMMORTAL(x);
891 PyObject *x = slot1(*operand1, operand2);
893 if (x != Py_NotImplemented) {
895 goto exit_inplace_result_object;
898 Py_DECREF_IMMORTAL(x);
902 PyObject *x = slot2(*operand1, operand2);
904 if (x != Py_NotImplemented) {
906 goto exit_inplace_result_object;
909 Py_DECREF_IMMORTAL(x);
912#if PYTHON_VERSION < 0x300
913 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
914 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
917 PyObject *coerced1 = *operand1;
918 PyObject *coerced2 = operand2;
920 int err = c1(&coerced1, &coerced2);
922 if (unlikely(err < 0)) {
923 goto exit_inplace_exception;
927 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
929 if (likely(mv == NULL)) {
930 binaryfunc slot = mv->nb_rshift;
932 if (likely(slot != NULL)) {
933 PyObject *x = slot(coerced1, coerced2);
939 goto exit_inplace_result_object;
949 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
952 PyObject *coerced1 = *operand1;
953 PyObject *coerced2 = operand2;
955 int err = c2(&coerced2, &coerced1);
957 if (unlikely(err < 0)) {
958 goto exit_inplace_exception;
962 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
964 if (likely(mv == NULL)) {
965 binaryfunc slot = mv->nb_rshift;
967 if (likely(slot != NULL)) {
968 PyObject *x = slot(coerced1, coerced2);
974 goto exit_inplace_result_object;
986 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: 'int' and '%s'", type2->tp_name);
987 goto exit_inplace_exception;
990exit_inplace_result_object:
991 if (unlikely(obj_result == NULL)) {
996 Py_DECREF(*operand1);
1000 *operand1 = obj_result;
1004exit_inplace_exception:
1007static inline bool _INPLACE_OPERATION_RSHIFT_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
1010 CHECK_OBJECT(*operand1);
1011 assert(PyInt_CheckExact(*operand1));
1012 CHECK_OBJECT(operand2);
1014 PyTypeObject *type2 = Py_TYPE(operand2);
1016 if (&PyInt_Type == type2) {
1020#if defined(_MSC_VER)
1021#pragma warning(push)
1022#pragma warning(disable : 4101)
1024 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1025 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1026 NUITKA_MAY_BE_UNUSED
long clong_result;
1027 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1028#if defined(_MSC_VER)
1032 CHECK_OBJECT(*operand1);
1033 assert(PyInt_CheckExact(*operand1));
1034 CHECK_OBJECT(operand2);
1035 assert(PyInt_CheckExact(operand2));
1037 const long a = PyInt_AS_LONG(*operand1);
1038 const long b = PyInt_AS_LONG(operand2);
1040 if (unlikely(b < 0)) {
1041 PyThreadState *tstate = PyThreadState_GET();
1043 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1044 goto exit_result_exception;
1048 if (a == 0 || b == 0) {
1049 goto exit_result_ok_left;
1050 }
else if (b >= LONG_BIT) {
1052 goto exit_result_ok_const_int_neg_1;
1054 goto exit_result_ok_const_int_0;
1057 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
1060 goto exit_result_ok_clong;
1063 exit_result_ok_clong:
1066 Py_DECREF(*operand1);
1070 *operand1 = Nuitka_PyInt_FromLong(clong_result);
1071 goto exit_result_ok;
1073 exit_result_ok_left:
1074 goto exit_result_ok;
1076 exit_result_ok_const_int_0:
1078 Py_DECREF(*operand1);
1079 Py_INCREF(const_int_0);
1080 *operand1 = const_int_0;
1081 goto exit_result_ok;
1083 exit_result_ok_const_int_neg_1:
1085 Py_DECREF(*operand1);
1086 Py_INCREF(const_int_neg_1);
1087 *operand1 = const_int_neg_1;
1088 goto exit_result_ok;
1093 exit_result_exception:
1097 return __INPLACE_OPERATION_RSHIFT_INT_OBJECT(operand1, operand2);
1100bool INPLACE_OPERATION_RSHIFT_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
1101 return _INPLACE_OPERATION_RSHIFT_INT_OBJECT(operand1, operand2);
1105#if PYTHON_VERSION < 0x300
1107static inline bool _INPLACE_OPERATION_RSHIFT_LONG_INT(PyObject **operand1, PyObject *operand2) {
1110 CHECK_OBJECT(*operand1);
1111 assert(PyLong_CheckExact(*operand1));
1112 CHECK_OBJECT(operand2);
1113 assert(PyInt_CheckExact(operand2));
1115#if defined(_MSC_VER)
1116#pragma warning(push)
1117#pragma warning(disable : 4101)
1119 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1120 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1121#if defined(_MSC_VER)
1128 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_rshift;
1131 if (slot1 != NULL) {
1132 PyObject *x = slot1(*operand1, operand2);
1134 if (x != Py_NotImplemented) {
1136 goto exit_inplace_result_object;
1139 Py_DECREF_IMMORTAL(x);
1144 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: 'long' and 'int'");
1145 goto exit_inplace_exception;
1148exit_inplace_result_object:
1149 if (unlikely(obj_result == NULL)) {
1154 Py_DECREF(*operand1);
1158 *operand1 = obj_result;
1162exit_inplace_exception:
1166bool INPLACE_OPERATION_RSHIFT_LONG_INT(PyObject **operand1, PyObject *operand2) {
1167 return _INPLACE_OPERATION_RSHIFT_LONG_INT(operand1, operand2);
1171#if PYTHON_VERSION < 0x300
1173static inline bool _INPLACE_OPERATION_RSHIFT_INT_LONG(PyObject **operand1, PyObject *operand2) {
1176 CHECK_OBJECT(*operand1);
1177 assert(PyInt_CheckExact(*operand1));
1178 CHECK_OBJECT(operand2);
1179 assert(PyLong_CheckExact(operand2));
1181#if defined(_MSC_VER)
1182#pragma warning(push)
1183#pragma warning(disable : 4101)
1185 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1186 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1187#if defined(_MSC_VER)
1195 binaryfunc slot2 = NULL;
1200 slot2 = PyLong_Type.tp_as_number->nb_rshift;
1203 if (slot2 != NULL) {
1204 PyObject *x = slot2(*operand1, operand2);
1206 if (x != Py_NotImplemented) {
1208 goto exit_inplace_result_object;
1211 Py_DECREF_IMMORTAL(x);
1216 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: 'int' and 'long'");
1217 goto exit_inplace_exception;
1220exit_inplace_result_object:
1221 if (unlikely(obj_result == NULL)) {
1226 Py_DECREF(*operand1);
1230 *operand1 = obj_result;
1234exit_inplace_exception:
1238bool INPLACE_OPERATION_RSHIFT_INT_LONG(PyObject **operand1, PyObject *operand2) {
1239 return _INPLACE_OPERATION_RSHIFT_INT_LONG(operand1, operand2);
1244static inline bool _INPLACE_OPERATION_RSHIFT_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
1247 CHECK_OBJECT(*operand1);
1248 CHECK_OBJECT(operand2);
1250#if PYTHON_VERSION < 0x300
1251 if (PyInt_CheckExact(*operand1) && PyInt_CheckExact(operand2)) {
1254#if defined(_MSC_VER)
1255#pragma warning(push)
1256#pragma warning(disable : 4101)
1258 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1259 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1260 NUITKA_MAY_BE_UNUSED
long clong_result;
1261 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1262#if defined(_MSC_VER)
1266 CHECK_OBJECT(*operand1);
1267 assert(PyInt_CheckExact(*operand1));
1268 CHECK_OBJECT(operand2);
1269 assert(PyInt_CheckExact(operand2));
1271 const long a = PyInt_AS_LONG(*operand1);
1272 const long b = PyInt_AS_LONG(operand2);
1274 if (unlikely(b < 0)) {
1275 PyThreadState *tstate = PyThreadState_GET();
1277 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1278 goto exit_result_exception;
1282 if (a == 0 || b == 0) {
1283 goto exit_result_ok_left;
1284 }
else if (b >= LONG_BIT) {
1286 goto exit_result_ok_const_int_neg_1;
1288 goto exit_result_ok_const_int_0;
1291 long r = Py_ARITHMETIC_RIGHT_SHIFT(
long, a, b);
1294 goto exit_result_ok_clong;
1297 exit_result_ok_clong:
1300 Py_DECREF(*operand1);
1304 *operand1 = Nuitka_PyInt_FromLong(clong_result);
1305 goto exit_result_ok;
1307 exit_result_ok_left:
1308 goto exit_result_ok;
1310 exit_result_ok_const_int_0:
1312 Py_DECREF(*operand1);
1313 Py_INCREF(const_int_0);
1314 *operand1 = const_int_0;
1315 goto exit_result_ok;
1317 exit_result_ok_const_int_neg_1:
1319 Py_DECREF(*operand1);
1320 Py_INCREF(const_int_neg_1);
1321 *operand1 = const_int_neg_1;
1322 goto exit_result_ok;
1327 exit_result_exception:
1332 if (Py_TYPE(*operand1) == Py_TYPE(operand2)) {
1333#if PYTHON_VERSION >= 0x300
1334 if (PyLong_CheckExact(operand2)) {
1335 return _INPLACE_OPERATION_RSHIFT_LONG_LONG(operand1, operand2);
1340 PyTypeObject *type1 = Py_TYPE(*operand1);
1341 PyTypeObject *type2 = Py_TYPE(operand2);
1343#if defined(_MSC_VER)
1344#pragma warning(push)
1345#pragma warning(disable : 4101)
1347 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1348 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1349#if defined(_MSC_VER)
1354 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_rshift : NULL;
1356 if (islot != NULL) {
1357 PyObject *x = islot(*operand1, operand2);
1359 if (x != Py_NotImplemented) {
1361 goto exit_inplace_result_object;
1364 Py_DECREF_IMMORTAL(x);
1369 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_rshift : NULL;
1370 binaryfunc slot2 = NULL;
1372 if (!(type1 == type2)) {
1376 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_rshift : NULL;
1378 if (slot1 == slot2) {
1383 if (slot1 != NULL) {
1384 if (slot2 != NULL) {
1385 if (Nuitka_Type_IsSubtype(type2, type1)) {
1386 PyObject *x = slot2(*operand1, operand2);
1388 if (x != Py_NotImplemented) {
1390 goto exit_inplace_result_object;
1393 Py_DECREF_IMMORTAL(x);
1398 PyObject *x = slot1(*operand1, operand2);
1400 if (x != Py_NotImplemented) {
1402 goto exit_inplace_result_object;
1405 Py_DECREF_IMMORTAL(x);
1408 if (slot2 != NULL) {
1409 PyObject *x = slot2(*operand1, operand2);
1411 if (x != Py_NotImplemented) {
1413 goto exit_inplace_result_object;
1416 Py_DECREF_IMMORTAL(x);
1419#if PYTHON_VERSION < 0x300
1420 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
1422 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1425 PyObject *coerced1 = *operand1;
1426 PyObject *coerced2 = operand2;
1428 int err = c1(&coerced1, &coerced2);
1430 if (unlikely(err < 0)) {
1431 goto exit_inplace_exception;
1435 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1437 if (likely(mv == NULL)) {
1438 binaryfunc slot = mv->nb_rshift;
1440 if (likely(slot != NULL)) {
1441 PyObject *x = slot(coerced1, coerced2);
1443 Py_DECREF(coerced1);
1444 Py_DECREF(coerced2);
1447 goto exit_inplace_result_object;
1452 Py_DECREF(coerced1);
1453 Py_DECREF(coerced2);
1457 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1460 PyObject *coerced1 = *operand1;
1461 PyObject *coerced2 = operand2;
1463 int err = c2(&coerced2, &coerced1);
1465 if (unlikely(err < 0)) {
1466 goto exit_inplace_exception;
1470 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1472 if (likely(mv == NULL)) {
1473 binaryfunc slot = mv->nb_rshift;
1475 if (likely(slot != NULL)) {
1476 PyObject *x = slot(coerced1, coerced2);
1478 Py_DECREF(coerced1);
1479 Py_DECREF(coerced2);
1482 goto exit_inplace_result_object;
1487 Py_DECREF(coerced1);
1488 Py_DECREF(coerced2);
1494 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for >>=: '%s' and '%s'", type1->tp_name,
1496 goto exit_inplace_exception;
1499exit_inplace_result_object:
1500 if (unlikely(obj_result == NULL)) {
1505 Py_DECREF(*operand1);
1509 *operand1 = obj_result;
1513exit_inplace_exception:
1517bool INPLACE_OPERATION_RSHIFT_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
1518 return _INPLACE_OPERATION_RSHIFT_OBJECT_OBJECT(operand1, operand2);