7#include "nuitka/prelude.h"
13static inline bool _INPLACE_OPERATION_LSHIFT_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_lshift(*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_LSHIFT_LONG_LONG(PyObject **operand1, PyObject *operand2) {
55 return _INPLACE_OPERATION_LSHIFT_LONG_LONG(operand1, operand2);
59static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_LSHIFT_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_lshift : 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_lshift : NULL;
89 binaryfunc slot2 = NULL;
91 if (!(type1 == &PyLong_Type)) {
94 slot2 = PyLong_Type.tp_as_number->nb_lshift;
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_lshift;
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_lshift;
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_LSHIFT_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_lshift(*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_LSHIFT_OBJECT_LONG(operand1, operand2);
270bool INPLACE_OPERATION_LSHIFT_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
271 return _INPLACE_OPERATION_LSHIFT_OBJECT_LONG(operand1, operand2);
275static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_LSHIFT_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_lshift;
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_lshift : 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_lshift;
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_lshift;
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_LSHIFT_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_lshift(*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_LSHIFT_LONG_OBJECT(operand1, operand2);
488bool INPLACE_OPERATION_LSHIFT_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
489 return _INPLACE_OPERATION_LSHIFT_LONG_OBJECT(operand1, operand2);
492#if PYTHON_VERSION < 0x300
494static inline bool _INPLACE_OPERATION_LSHIFT_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;
530 if (a == 0 || b == 0) {
531 goto exit_result_ok_left;
532 }
else if (b >= LONG_BIT) {
533 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
534 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
537 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
539 Py_DECREF(operand1_long);
540 Py_DECREF(operand2_long);
543 goto exit_result_object;
547 if (a != Py_ARITHMETIC_RIGHT_SHIFT(
long, c, b)) {
548 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
549 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
552 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
554 Py_DECREF(operand1_long);
555 Py_DECREF(operand2_long);
558 goto exit_result_object;
561 goto exit_result_ok_clong;
568 Py_DECREF(*operand1);
572 *operand1 = Nuitka_PyInt_FromLong(clong_result);
579 if (unlikely(obj_result == NULL)) {
580 goto exit_result_exception;
583 Py_DECREF(*operand1);
585 *operand1 = obj_result;
591exit_result_exception:
595bool INPLACE_OPERATION_LSHIFT_INT_INT(PyObject **operand1, PyObject *operand2) {
596 return _INPLACE_OPERATION_LSHIFT_INT_INT(operand1, operand2);
600#if PYTHON_VERSION < 0x300
602static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_LSHIFT_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
603 PyTypeObject *type1 = Py_TYPE(*operand1);
607#pragma warning(disable : 4101)
609 NUITKA_MAY_BE_UNUSED
bool cbool_result;
610 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
616 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_lshift : NULL;
619 PyObject *x = islot(*operand1, operand2);
621 if (x != Py_NotImplemented) {
623 goto exit_inplace_result_object;
626 Py_DECREF_IMMORTAL(x);
631 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_lshift : NULL;
632 binaryfunc slot2 = NULL;
634 if (!(type1 == &PyInt_Type)) {
637 slot2 = PyInt_Type.tp_as_number->nb_lshift;
639 if (slot1 == slot2) {
645 PyObject *x = slot1(*operand1, operand2);
647 if (x != Py_NotImplemented) {
649 goto exit_inplace_result_object;
652 Py_DECREF_IMMORTAL(x);
656 PyObject *x = slot2(*operand1, operand2);
658 if (x != Py_NotImplemented) {
660 goto exit_inplace_result_object;
663 Py_DECREF_IMMORTAL(x);
666#if PYTHON_VERSION < 0x300
667 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
669 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
672 PyObject *coerced1 = *operand1;
673 PyObject *coerced2 = operand2;
675 int err = c1(&coerced1, &coerced2);
677 if (unlikely(err < 0)) {
678 goto exit_inplace_exception;
682 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
684 if (likely(mv == NULL)) {
685 binaryfunc slot = mv->nb_lshift;
687 if (likely(slot != NULL)) {
688 PyObject *x = slot(coerced1, coerced2);
694 goto exit_inplace_result_object;
703 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
706 PyObject *coerced1 = *operand1;
707 PyObject *coerced2 = operand2;
709 int err = c2(&coerced2, &coerced1);
711 if (unlikely(err < 0)) {
712 goto exit_inplace_exception;
716 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
718 if (likely(mv == NULL)) {
719 binaryfunc slot = mv->nb_lshift;
721 if (likely(slot != NULL)) {
722 PyObject *x = slot(coerced1, coerced2);
728 goto exit_inplace_result_object;
740 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for <<=: '%s' and 'int'", type1->tp_name);
741 goto exit_inplace_exception;
744exit_inplace_result_object:
745 if (unlikely(obj_result == NULL)) {
750 Py_DECREF(*operand1);
754 *operand1 = obj_result;
758exit_inplace_exception:
761static inline bool _INPLACE_OPERATION_LSHIFT_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
764 CHECK_OBJECT(*operand1);
765 CHECK_OBJECT(operand2);
766 assert(PyInt_CheckExact(operand2));
768 PyTypeObject *type1 = Py_TYPE(*operand1);
770 if (type1 == &PyInt_Type) {
776#pragma warning(disable : 4101)
778 NUITKA_MAY_BE_UNUSED
bool cbool_result;
779 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
780 NUITKA_MAY_BE_UNUSED
long clong_result;
781 NUITKA_MAY_BE_UNUSED
double cfloat_result;
786 CHECK_OBJECT(*operand1);
787 assert(PyInt_CheckExact(*operand1));
788 CHECK_OBJECT(operand2);
789 assert(PyInt_CheckExact(operand2));
791 const long a = PyInt_AS_LONG(*operand1);
792 const long b = PyInt_AS_LONG(operand2);
794 if (unlikely(b < 0)) {
795 PyThreadState *tstate = PyThreadState_GET();
797 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
798 goto exit_result_exception;
801 if (a == 0 || b == 0) {
802 goto exit_result_ok_left;
803 }
else if (b >= LONG_BIT) {
804 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
805 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
808 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
810 Py_DECREF(operand1_long);
811 Py_DECREF(operand2_long);
814 goto exit_result_object;
818 if (a != Py_ARITHMETIC_RIGHT_SHIFT(
long, c, b)) {
819 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
820 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
823 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
825 Py_DECREF(operand1_long);
826 Py_DECREF(operand2_long);
829 goto exit_result_object;
832 goto exit_result_ok_clong;
836 exit_result_ok_clong:
839 Py_DECREF(*operand1);
843 *operand1 = Nuitka_PyInt_FromLong(clong_result);
850 if (unlikely(obj_result == NULL)) {
851 goto exit_result_exception;
854 Py_DECREF(*operand1);
856 *operand1 = obj_result;
862 exit_result_exception:
866 return __INPLACE_OPERATION_LSHIFT_OBJECT_INT(operand1, operand2);
869bool INPLACE_OPERATION_LSHIFT_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
870 return _INPLACE_OPERATION_LSHIFT_OBJECT_INT(operand1, operand2);
874#if PYTHON_VERSION < 0x300
876static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_LSHIFT_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
877 PyTypeObject *type2 = Py_TYPE(operand2);
881#pragma warning(disable : 4101)
883 NUITKA_MAY_BE_UNUSED
bool cbool_result;
884 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
892 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_lshift;
893 binaryfunc slot2 = NULL;
895 if (!(&PyInt_Type == type2)) {
899 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_lshift : NULL;
901 if (slot1 == slot2) {
908 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
909 PyObject *x = slot2(*operand1, operand2);
911 if (x != Py_NotImplemented) {
913 goto exit_inplace_result_object;
916 Py_DECREF_IMMORTAL(x);
921 PyObject *x = slot1(*operand1, operand2);
923 if (x != Py_NotImplemented) {
925 goto exit_inplace_result_object;
928 Py_DECREF_IMMORTAL(x);
932 PyObject *x = slot2(*operand1, operand2);
934 if (x != Py_NotImplemented) {
936 goto exit_inplace_result_object;
939 Py_DECREF_IMMORTAL(x);
942#if PYTHON_VERSION < 0x300
943 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
944 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
947 PyObject *coerced1 = *operand1;
948 PyObject *coerced2 = operand2;
950 int err = c1(&coerced1, &coerced2);
952 if (unlikely(err < 0)) {
953 goto exit_inplace_exception;
957 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
959 if (likely(mv == NULL)) {
960 binaryfunc slot = mv->nb_lshift;
962 if (likely(slot != NULL)) {
963 PyObject *x = slot(coerced1, coerced2);
969 goto exit_inplace_result_object;
979 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
982 PyObject *coerced1 = *operand1;
983 PyObject *coerced2 = operand2;
985 int err = c2(&coerced2, &coerced1);
987 if (unlikely(err < 0)) {
988 goto exit_inplace_exception;
992 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
994 if (likely(mv == NULL)) {
995 binaryfunc slot = mv->nb_lshift;
997 if (likely(slot != NULL)) {
998 PyObject *x = slot(coerced1, coerced2);
1000 Py_DECREF(coerced1);
1001 Py_DECREF(coerced2);
1004 goto exit_inplace_result_object;
1009 Py_DECREF(coerced1);
1010 Py_DECREF(coerced2);
1016 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for <<=: 'int' and '%s'", type2->tp_name);
1017 goto exit_inplace_exception;
1020exit_inplace_result_object:
1021 if (unlikely(obj_result == NULL)) {
1026 Py_DECREF(*operand1);
1030 *operand1 = obj_result;
1034exit_inplace_exception:
1037static inline bool _INPLACE_OPERATION_LSHIFT_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
1040 CHECK_OBJECT(*operand1);
1041 assert(PyInt_CheckExact(*operand1));
1042 CHECK_OBJECT(operand2);
1044 PyTypeObject *type2 = Py_TYPE(operand2);
1046 if (&PyInt_Type == type2) {
1050#if defined(_MSC_VER)
1051#pragma warning(push)
1052#pragma warning(disable : 4101)
1054 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1055 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1056 NUITKA_MAY_BE_UNUSED
long clong_result;
1057 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1058#if defined(_MSC_VER)
1062 CHECK_OBJECT(*operand1);
1063 assert(PyInt_CheckExact(*operand1));
1064 CHECK_OBJECT(operand2);
1065 assert(PyInt_CheckExact(operand2));
1067 const long a = PyInt_AS_LONG(*operand1);
1068 const long b = PyInt_AS_LONG(operand2);
1070 if (unlikely(b < 0)) {
1071 PyThreadState *tstate = PyThreadState_GET();
1073 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1074 goto exit_result_exception;
1077 if (a == 0 || b == 0) {
1078 goto exit_result_ok_left;
1079 }
else if (b >= LONG_BIT) {
1080 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1081 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1084 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
1086 Py_DECREF(operand1_long);
1087 Py_DECREF(operand2_long);
1090 goto exit_result_object;
1094 if (a != Py_ARITHMETIC_RIGHT_SHIFT(
long, c, b)) {
1095 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1096 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1099 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
1101 Py_DECREF(operand1_long);
1102 Py_DECREF(operand2_long);
1105 goto exit_result_object;
1108 goto exit_result_ok_clong;
1112 exit_result_ok_clong:
1115 Py_DECREF(*operand1);
1119 *operand1 = Nuitka_PyInt_FromLong(clong_result);
1120 goto exit_result_ok;
1122 exit_result_ok_left:
1123 goto exit_result_ok;
1126 if (unlikely(obj_result == NULL)) {
1127 goto exit_result_exception;
1130 Py_DECREF(*operand1);
1132 *operand1 = obj_result;
1133 goto exit_result_ok;
1138 exit_result_exception:
1142 return __INPLACE_OPERATION_LSHIFT_INT_OBJECT(operand1, operand2);
1145bool INPLACE_OPERATION_LSHIFT_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
1146 return _INPLACE_OPERATION_LSHIFT_INT_OBJECT(operand1, operand2);
1150#if PYTHON_VERSION < 0x300
1152static inline bool _INPLACE_OPERATION_LSHIFT_LONG_INT(PyObject **operand1, PyObject *operand2) {
1155 CHECK_OBJECT(*operand1);
1156 assert(PyLong_CheckExact(*operand1));
1157 CHECK_OBJECT(operand2);
1158 assert(PyInt_CheckExact(operand2));
1160#if defined(_MSC_VER)
1161#pragma warning(push)
1162#pragma warning(disable : 4101)
1164 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1165 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1166#if defined(_MSC_VER)
1173 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_lshift;
1176 if (slot1 != NULL) {
1177 PyObject *x = slot1(*operand1, operand2);
1179 if (x != Py_NotImplemented) {
1181 goto exit_inplace_result_object;
1184 Py_DECREF_IMMORTAL(x);
1189 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for <<=: 'long' and 'int'");
1190 goto exit_inplace_exception;
1193exit_inplace_result_object:
1194 if (unlikely(obj_result == NULL)) {
1199 Py_DECREF(*operand1);
1203 *operand1 = obj_result;
1207exit_inplace_exception:
1211bool INPLACE_OPERATION_LSHIFT_LONG_INT(PyObject **operand1, PyObject *operand2) {
1212 return _INPLACE_OPERATION_LSHIFT_LONG_INT(operand1, operand2);
1216#if PYTHON_VERSION < 0x300
1218static inline bool _INPLACE_OPERATION_LSHIFT_INT_LONG(PyObject **operand1, PyObject *operand2) {
1221 CHECK_OBJECT(*operand1);
1222 assert(PyInt_CheckExact(*operand1));
1223 CHECK_OBJECT(operand2);
1224 assert(PyLong_CheckExact(operand2));
1226#if defined(_MSC_VER)
1227#pragma warning(push)
1228#pragma warning(disable : 4101)
1230 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1231 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1232#if defined(_MSC_VER)
1240 binaryfunc slot2 = NULL;
1245 slot2 = PyLong_Type.tp_as_number->nb_lshift;
1248 if (slot2 != NULL) {
1249 PyObject *x = slot2(*operand1, operand2);
1251 if (x != Py_NotImplemented) {
1253 goto exit_inplace_result_object;
1256 Py_DECREF_IMMORTAL(x);
1261 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for <<=: 'int' and 'long'");
1262 goto exit_inplace_exception;
1265exit_inplace_result_object:
1266 if (unlikely(obj_result == NULL)) {
1271 Py_DECREF(*operand1);
1275 *operand1 = obj_result;
1279exit_inplace_exception:
1283bool INPLACE_OPERATION_LSHIFT_INT_LONG(PyObject **operand1, PyObject *operand2) {
1284 return _INPLACE_OPERATION_LSHIFT_INT_LONG(operand1, operand2);
1289static inline bool _INPLACE_OPERATION_LSHIFT_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
1292 CHECK_OBJECT(*operand1);
1293 CHECK_OBJECT(operand2);
1295#if PYTHON_VERSION < 0x300
1296 if (PyInt_CheckExact(*operand1) && PyInt_CheckExact(operand2)) {
1299#if defined(_MSC_VER)
1300#pragma warning(push)
1301#pragma warning(disable : 4101)
1303 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1304 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1305 NUITKA_MAY_BE_UNUSED
long clong_result;
1306 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1307#if defined(_MSC_VER)
1311 CHECK_OBJECT(*operand1);
1312 assert(PyInt_CheckExact(*operand1));
1313 CHECK_OBJECT(operand2);
1314 assert(PyInt_CheckExact(operand2));
1316 const long a = PyInt_AS_LONG(*operand1);
1317 const long b = PyInt_AS_LONG(operand2);
1319 if (unlikely(b < 0)) {
1320 PyThreadState *tstate = PyThreadState_GET();
1322 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ValueError,
"negative shift count");
1323 goto exit_result_exception;
1326 if (a == 0 || b == 0) {
1327 goto exit_result_ok_left;
1328 }
else if (b >= LONG_BIT) {
1329 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1330 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1333 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
1335 Py_DECREF(operand1_long);
1336 Py_DECREF(operand2_long);
1339 goto exit_result_object;
1343 if (a != Py_ARITHMETIC_RIGHT_SHIFT(
long, c, b)) {
1344 PyObject *operand1_long = Nuitka_PyLong_FromLong(a);
1345 PyObject *operand2_long = Nuitka_PyLong_FromLong(b);
1348 PyObject *r = _BINARY_OPERATION_LSHIFT_OBJECT_LONG_LONG(operand1_long, operand2_long);
1350 Py_DECREF(operand1_long);
1351 Py_DECREF(operand2_long);
1354 goto exit_result_object;
1357 goto exit_result_ok_clong;
1361 exit_result_ok_clong:
1364 Py_DECREF(*operand1);
1368 *operand1 = Nuitka_PyInt_FromLong(clong_result);
1369 goto exit_result_ok;
1371 exit_result_ok_left:
1372 goto exit_result_ok;
1375 if (unlikely(obj_result == NULL)) {
1376 goto exit_result_exception;
1379 Py_DECREF(*operand1);
1381 *operand1 = obj_result;
1382 goto exit_result_ok;
1387 exit_result_exception:
1392 if (Py_TYPE(*operand1) == Py_TYPE(operand2)) {
1393#if PYTHON_VERSION >= 0x300
1394 if (PyLong_CheckExact(operand2)) {
1395 return _INPLACE_OPERATION_LSHIFT_LONG_LONG(operand1, operand2);
1400 PyTypeObject *type1 = Py_TYPE(*operand1);
1401 PyTypeObject *type2 = Py_TYPE(operand2);
1403#if defined(_MSC_VER)
1404#pragma warning(push)
1405#pragma warning(disable : 4101)
1407 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1408 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1409#if defined(_MSC_VER)
1414 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_inplace_lshift : NULL;
1416 if (islot != NULL) {
1417 PyObject *x = islot(*operand1, operand2);
1419 if (x != Py_NotImplemented) {
1421 goto exit_inplace_result_object;
1424 Py_DECREF_IMMORTAL(x);
1429 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_lshift : NULL;
1430 binaryfunc slot2 = NULL;
1432 if (!(type1 == type2)) {
1436 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_lshift : NULL;
1438 if (slot1 == slot2) {
1443 if (slot1 != NULL) {
1444 if (slot2 != NULL) {
1445 if (Nuitka_Type_IsSubtype(type2, type1)) {
1446 PyObject *x = slot2(*operand1, operand2);
1448 if (x != Py_NotImplemented) {
1450 goto exit_inplace_result_object;
1453 Py_DECREF_IMMORTAL(x);
1458 PyObject *x = slot1(*operand1, operand2);
1460 if (x != Py_NotImplemented) {
1462 goto exit_inplace_result_object;
1465 Py_DECREF_IMMORTAL(x);
1468 if (slot2 != NULL) {
1469 PyObject *x = slot2(*operand1, operand2);
1471 if (x != Py_NotImplemented) {
1473 goto exit_inplace_result_object;
1476 Py_DECREF_IMMORTAL(x);
1479#if PYTHON_VERSION < 0x300
1480 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
1482 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1485 PyObject *coerced1 = *operand1;
1486 PyObject *coerced2 = operand2;
1488 int err = c1(&coerced1, &coerced2);
1490 if (unlikely(err < 0)) {
1491 goto exit_inplace_exception;
1495 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1497 if (likely(mv == NULL)) {
1498 binaryfunc slot = mv->nb_lshift;
1500 if (likely(slot != NULL)) {
1501 PyObject *x = slot(coerced1, coerced2);
1503 Py_DECREF(coerced1);
1504 Py_DECREF(coerced2);
1507 goto exit_inplace_result_object;
1512 Py_DECREF(coerced1);
1513 Py_DECREF(coerced2);
1517 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1520 PyObject *coerced1 = *operand1;
1521 PyObject *coerced2 = operand2;
1523 int err = c2(&coerced2, &coerced1);
1525 if (unlikely(err < 0)) {
1526 goto exit_inplace_exception;
1530 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1532 if (likely(mv == NULL)) {
1533 binaryfunc slot = mv->nb_lshift;
1535 if (likely(slot != NULL)) {
1536 PyObject *x = slot(coerced1, coerced2);
1538 Py_DECREF(coerced1);
1539 Py_DECREF(coerced2);
1542 goto exit_inplace_result_object;
1547 Py_DECREF(coerced1);
1548 Py_DECREF(coerced2);
1554 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for <<=: '%s' and '%s'", type1->tp_name,
1556 goto exit_inplace_exception;
1559exit_inplace_result_object:
1560 if (unlikely(obj_result == NULL)) {
1565 Py_DECREF(*operand1);
1569 *operand1 = obj_result;
1573exit_inplace_exception:
1577bool INPLACE_OPERATION_LSHIFT_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
1578 return _INPLACE_OPERATION_LSHIFT_OBJECT_OBJECT(operand1, operand2);