7#include "nuitka/prelude.h"
12#if PYTHON_VERSION < 0x300
14static inline bool _INPLACE_OPERATION_FLOORDIV_INT_INT(PyObject **operand1, PyObject *operand2) {
17 CHECK_OBJECT(*operand1);
18 assert(PyInt_CheckExact(*operand1));
19 CHECK_OBJECT(operand2);
20 assert(PyInt_CheckExact(operand2));
25#pragma warning(disable : 4101)
27 NUITKA_MAY_BE_UNUSED
bool cbool_result;
28 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
29 NUITKA_MAY_BE_UNUSED
long clong_result;
30 NUITKA_MAY_BE_UNUSED
double cfloat_result;
35 CHECK_OBJECT(*operand1);
36 assert(PyInt_CheckExact(*operand1));
37 CHECK_OBJECT(operand2);
38 assert(PyInt_CheckExact(operand2));
40 const long a = PyInt_AS_LONG(*operand1);
41 const long b = PyInt_AS_LONG(operand2);
43 if (unlikely(b == 0)) {
44 PyThreadState *tstate = PyThreadState_GET();
46 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
47 goto exit_result_exception;
56 if (likely(b != -1 || !UNARY_NEG_WOULD_OVERFLOW(a))) {
58 long a_mod_b = (long)(a - (
unsigned long)a_div_b * b);
60 if (a_mod_b && (b ^ a_mod_b) < 0) {
65 clong_result = a_div_b;
66 goto exit_result_ok_clong;
70 PyObject *operand1_object = *operand1;
71 PyObject *operand2_object = operand2;
73 PyObject *r = PyLong_Type.tp_as_number->nb_floor_divide(operand1_object, operand2_object);
74 assert(r != Py_NotImplemented);
77 goto exit_result_object;
87 *operand1 = Nuitka_PyInt_FromLong(clong_result);
91 if (unlikely(obj_result == NULL)) {
92 goto exit_result_exception;
97 *operand1 = obj_result;
103exit_result_exception:
107bool INPLACE_OPERATION_FLOORDIV_INT_INT(PyObject **operand1, PyObject *operand2) {
108 return _INPLACE_OPERATION_FLOORDIV_INT_INT(operand1, operand2);
112#if PYTHON_VERSION < 0x300
114static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_FLOORDIV_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
115 PyTypeObject *type1 = Py_TYPE(*operand1);
119#pragma warning(disable : 4101)
121 NUITKA_MAY_BE_UNUSED
bool cbool_result;
122 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
127 binaryfunc islot = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1))
128 ? type1->tp_as_number->nb_inplace_floor_divide
132 PyObject *x = islot(*operand1, operand2);
134 if (x != Py_NotImplemented) {
136 goto exit_inplace_result_object;
139 Py_DECREF_IMMORTAL(x);
144 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_floor_divide : NULL;
145 binaryfunc slot2 = NULL;
147 if (!(type1 == &PyInt_Type)) {
150 slot2 = PyInt_Type.tp_as_number->nb_floor_divide;
152 if (slot1 == slot2) {
158 PyObject *x = slot1(*operand1, operand2);
160 if (x != Py_NotImplemented) {
162 goto exit_inplace_result_object;
165 Py_DECREF_IMMORTAL(x);
169 PyObject *x = slot2(*operand1, operand2);
171 if (x != Py_NotImplemented) {
173 goto exit_inplace_result_object;
176 Py_DECREF_IMMORTAL(x);
179#if PYTHON_VERSION < 0x300
180 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
182 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
185 PyObject *coerced1 = *operand1;
186 PyObject *coerced2 = operand2;
188 int err = c1(&coerced1, &coerced2);
190 if (unlikely(err < 0)) {
191 goto exit_inplace_exception;
195 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
197 if (likely(mv == NULL)) {
198 binaryfunc slot = mv->nb_floor_divide;
200 if (likely(slot != NULL)) {
201 PyObject *x = slot(coerced1, coerced2);
207 goto exit_inplace_result_object;
216 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
219 PyObject *coerced1 = *operand1;
220 PyObject *coerced2 = operand2;
222 int err = c2(&coerced2, &coerced1);
224 if (unlikely(err < 0)) {
225 goto exit_inplace_exception;
229 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
231 if (likely(mv == NULL)) {
232 binaryfunc slot = mv->nb_floor_divide;
234 if (likely(slot != NULL)) {
235 PyObject *x = slot(coerced1, coerced2);
241 goto exit_inplace_result_object;
253 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: '%s' and 'int'", type1->tp_name);
254 goto exit_inplace_exception;
257exit_inplace_result_object:
258 if (unlikely(obj_result == NULL)) {
263 Py_DECREF(*operand1);
267 *operand1 = obj_result;
271exit_inplace_exception:
274static inline bool _INPLACE_OPERATION_FLOORDIV_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
277 CHECK_OBJECT(*operand1);
278 CHECK_OBJECT(operand2);
279 assert(PyInt_CheckExact(operand2));
281 PyTypeObject *type1 = Py_TYPE(*operand1);
283 if (type1 == &PyInt_Type) {
289#pragma warning(disable : 4101)
291 NUITKA_MAY_BE_UNUSED
bool cbool_result;
292 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
293 NUITKA_MAY_BE_UNUSED
long clong_result;
294 NUITKA_MAY_BE_UNUSED
double cfloat_result;
299 CHECK_OBJECT(*operand1);
300 assert(PyInt_CheckExact(*operand1));
301 CHECK_OBJECT(operand2);
302 assert(PyInt_CheckExact(operand2));
304 const long a = PyInt_AS_LONG(*operand1);
305 const long b = PyInt_AS_LONG(operand2);
307 if (unlikely(b == 0)) {
308 PyThreadState *tstate = PyThreadState_GET();
310 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
311 goto exit_result_exception;
320 if (likely(b != -1 || !UNARY_NEG_WOULD_OVERFLOW(a))) {
321 long a_div_b = a / b;
322 long a_mod_b = (long)(a - (
unsigned long)a_div_b * b);
324 if (a_mod_b && (b ^ a_mod_b) < 0) {
329 clong_result = a_div_b;
330 goto exit_result_ok_clong;
334 PyObject *operand1_object = *operand1;
335 PyObject *operand2_object = operand2;
337 PyObject *r = PyLong_Type.tp_as_number->nb_floor_divide(operand1_object, operand2_object);
338 assert(r != Py_NotImplemented);
341 goto exit_result_object;
344 exit_result_ok_clong:
347 Py_DECREF(*operand1);
351 *operand1 = Nuitka_PyInt_FromLong(clong_result);
355 if (unlikely(obj_result == NULL)) {
356 goto exit_result_exception;
359 Py_DECREF(*operand1);
361 *operand1 = obj_result;
367 exit_result_exception:
371 return __INPLACE_OPERATION_FLOORDIV_OBJECT_INT(operand1, operand2);
374bool INPLACE_OPERATION_FLOORDIV_OBJECT_INT(PyObject **operand1, PyObject *operand2) {
375 return _INPLACE_OPERATION_FLOORDIV_OBJECT_INT(operand1, operand2);
379#if PYTHON_VERSION < 0x300
381static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_FLOORDIV_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
382 PyTypeObject *type2 = Py_TYPE(operand2);
386#pragma warning(disable : 4101)
388 NUITKA_MAY_BE_UNUSED
bool cbool_result;
389 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
397 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_floor_divide;
398 binaryfunc slot2 = NULL;
400 if (!(&PyInt_Type == type2)) {
403 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_floor_divide
406 if (slot1 == slot2) {
413 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
414 PyObject *x = slot2(*operand1, operand2);
416 if (x != Py_NotImplemented) {
418 goto exit_inplace_result_object;
421 Py_DECREF_IMMORTAL(x);
426 PyObject *x = slot1(*operand1, operand2);
428 if (x != Py_NotImplemented) {
430 goto exit_inplace_result_object;
433 Py_DECREF_IMMORTAL(x);
437 PyObject *x = slot2(*operand1, operand2);
439 if (x != Py_NotImplemented) {
441 goto exit_inplace_result_object;
444 Py_DECREF_IMMORTAL(x);
447#if PYTHON_VERSION < 0x300
448 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
449 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
452 PyObject *coerced1 = *operand1;
453 PyObject *coerced2 = operand2;
455 int err = c1(&coerced1, &coerced2);
457 if (unlikely(err < 0)) {
458 goto exit_inplace_exception;
462 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
464 if (likely(mv == NULL)) {
465 binaryfunc slot = mv->nb_floor_divide;
467 if (likely(slot != NULL)) {
468 PyObject *x = slot(coerced1, coerced2);
474 goto exit_inplace_result_object;
484 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
487 PyObject *coerced1 = *operand1;
488 PyObject *coerced2 = operand2;
490 int err = c2(&coerced2, &coerced1);
492 if (unlikely(err < 0)) {
493 goto exit_inplace_exception;
497 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
499 if (likely(mv == NULL)) {
500 binaryfunc slot = mv->nb_floor_divide;
502 if (likely(slot != NULL)) {
503 PyObject *x = slot(coerced1, coerced2);
509 goto exit_inplace_result_object;
521 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'int' and '%s'", type2->tp_name);
522 goto exit_inplace_exception;
525exit_inplace_result_object:
526 if (unlikely(obj_result == NULL)) {
531 Py_DECREF(*operand1);
535 *operand1 = obj_result;
539exit_inplace_exception:
542static inline bool _INPLACE_OPERATION_FLOORDIV_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
545 CHECK_OBJECT(*operand1);
546 assert(PyInt_CheckExact(*operand1));
547 CHECK_OBJECT(operand2);
549 PyTypeObject *type2 = Py_TYPE(operand2);
551 if (&PyInt_Type == type2) {
557#pragma warning(disable : 4101)
559 NUITKA_MAY_BE_UNUSED
bool cbool_result;
560 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
561 NUITKA_MAY_BE_UNUSED
long clong_result;
562 NUITKA_MAY_BE_UNUSED
double cfloat_result;
567 CHECK_OBJECT(*operand1);
568 assert(PyInt_CheckExact(*operand1));
569 CHECK_OBJECT(operand2);
570 assert(PyInt_CheckExact(operand2));
572 const long a = PyInt_AS_LONG(*operand1);
573 const long b = PyInt_AS_LONG(operand2);
575 if (unlikely(b == 0)) {
576 PyThreadState *tstate = PyThreadState_GET();
578 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
579 goto exit_result_exception;
588 if (likely(b != -1 || !UNARY_NEG_WOULD_OVERFLOW(a))) {
589 long a_div_b = a / b;
590 long a_mod_b = (long)(a - (
unsigned long)a_div_b * b);
592 if (a_mod_b && (b ^ a_mod_b) < 0) {
597 clong_result = a_div_b;
598 goto exit_result_ok_clong;
602 PyObject *operand1_object = *operand1;
603 PyObject *operand2_object = operand2;
605 PyObject *r = PyLong_Type.tp_as_number->nb_floor_divide(operand1_object, operand2_object);
606 assert(r != Py_NotImplemented);
609 goto exit_result_object;
612 exit_result_ok_clong:
615 Py_DECREF(*operand1);
619 *operand1 = Nuitka_PyInt_FromLong(clong_result);
623 if (unlikely(obj_result == NULL)) {
624 goto exit_result_exception;
627 Py_DECREF(*operand1);
629 *operand1 = obj_result;
635 exit_result_exception:
639 return __INPLACE_OPERATION_FLOORDIV_INT_OBJECT(operand1, operand2);
642bool INPLACE_OPERATION_FLOORDIV_INT_OBJECT(PyObject **operand1, PyObject *operand2) {
643 return _INPLACE_OPERATION_FLOORDIV_INT_OBJECT(operand1, operand2);
648static inline bool _INPLACE_OPERATION_FLOORDIV_LONG_LONG(PyObject **operand1, PyObject *operand2) {
651 CHECK_OBJECT(*operand1);
652 assert(PyLong_CheckExact(*operand1));
653 CHECK_OBJECT(operand2);
654 assert(PyLong_CheckExact(operand2));
659#pragma warning(disable : 4101)
661 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
662 NUITKA_MAY_BE_UNUSED
long clong_result;
667 PyObject *x = PyLong_Type.tp_as_number->nb_floor_divide(*operand1, operand2);
668 assert(x != Py_NotImplemented);
671 goto exit_result_object;
674 if (unlikely(obj_result == NULL)) {
675 goto exit_result_exception;
678 Py_DECREF(*operand1);
679 *operand1 = obj_result;
685exit_result_exception:
689bool INPLACE_OPERATION_FLOORDIV_LONG_LONG(PyObject **operand1, PyObject *operand2) {
690 return _INPLACE_OPERATION_FLOORDIV_LONG_LONG(operand1, operand2);
694static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_FLOORDIV_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
695 PyTypeObject *type1 = Py_TYPE(*operand1);
699#pragma warning(disable : 4101)
701 NUITKA_MAY_BE_UNUSED
bool cbool_result;
702 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
707 binaryfunc islot = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1))
708 ? type1->tp_as_number->nb_inplace_floor_divide
712 PyObject *x = islot(*operand1, operand2);
714 if (x != Py_NotImplemented) {
716 goto exit_inplace_result_object;
719 Py_DECREF_IMMORTAL(x);
724 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_floor_divide : NULL;
725 binaryfunc slot2 = NULL;
727 if (!(type1 == &PyLong_Type)) {
730 slot2 = PyLong_Type.tp_as_number->nb_floor_divide;
732 if (slot1 == slot2) {
738 PyObject *x = slot1(*operand1, operand2);
740 if (x != Py_NotImplemented) {
742 goto exit_inplace_result_object;
745 Py_DECREF_IMMORTAL(x);
749 PyObject *x = slot2(*operand1, operand2);
751 if (x != Py_NotImplemented) {
753 goto exit_inplace_result_object;
756 Py_DECREF_IMMORTAL(x);
759#if PYTHON_VERSION < 0x300
760 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
762 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
765 PyObject *coerced1 = *operand1;
766 PyObject *coerced2 = operand2;
768 int err = c1(&coerced1, &coerced2);
770 if (unlikely(err < 0)) {
771 goto exit_inplace_exception;
775 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
777 if (likely(mv == NULL)) {
778 binaryfunc slot = mv->nb_floor_divide;
780 if (likely(slot != NULL)) {
781 PyObject *x = slot(coerced1, coerced2);
787 goto exit_inplace_result_object;
796 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
799 PyObject *coerced1 = *operand1;
800 PyObject *coerced2 = operand2;
802 int err = c2(&coerced2, &coerced1);
804 if (unlikely(err < 0)) {
805 goto exit_inplace_exception;
809 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
811 if (likely(mv == NULL)) {
812 binaryfunc slot = mv->nb_floor_divide;
814 if (likely(slot != NULL)) {
815 PyObject *x = slot(coerced1, coerced2);
821 goto exit_inplace_result_object;
833#if PYTHON_VERSION < 0x300
834 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: '%s' and 'long'", type1->tp_name);
836 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: '%s' and 'int'", type1->tp_name);
838 goto exit_inplace_exception;
841exit_inplace_result_object:
842 if (unlikely(obj_result == NULL)) {
847 Py_DECREF(*operand1);
851 *operand1 = obj_result;
855exit_inplace_exception:
858static inline bool _INPLACE_OPERATION_FLOORDIV_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
861 CHECK_OBJECT(*operand1);
862 CHECK_OBJECT(operand2);
863 assert(PyLong_CheckExact(operand2));
865 PyTypeObject *type1 = Py_TYPE(*operand1);
867 if (type1 == &PyLong_Type) {
873#pragma warning(disable : 4101)
875 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
876 NUITKA_MAY_BE_UNUSED
long clong_result;
881 PyObject *x = PyLong_Type.tp_as_number->nb_floor_divide(*operand1, operand2);
882 assert(x != Py_NotImplemented);
885 goto exit_result_object;
888 if (unlikely(obj_result == NULL)) {
889 goto exit_result_exception;
892 Py_DECREF(*operand1);
893 *operand1 = obj_result;
899 exit_result_exception:
903 return __INPLACE_OPERATION_FLOORDIV_OBJECT_LONG(operand1, operand2);
906bool INPLACE_OPERATION_FLOORDIV_OBJECT_LONG(PyObject **operand1, PyObject *operand2) {
907 return _INPLACE_OPERATION_FLOORDIV_OBJECT_LONG(operand1, operand2);
911static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_FLOORDIV_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
912 PyTypeObject *type2 = Py_TYPE(operand2);
916#pragma warning(disable : 4101)
918 NUITKA_MAY_BE_UNUSED
bool cbool_result;
919 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
927 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_floor_divide;
928 binaryfunc slot2 = NULL;
930 if (!(&PyLong_Type == type2)) {
933 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_floor_divide
936 if (slot1 == slot2) {
943 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
944 PyObject *x = slot2(*operand1, operand2);
946 if (x != Py_NotImplemented) {
948 goto exit_inplace_result_object;
951 Py_DECREF_IMMORTAL(x);
956 PyObject *x = slot1(*operand1, operand2);
958 if (x != Py_NotImplemented) {
960 goto exit_inplace_result_object;
963 Py_DECREF_IMMORTAL(x);
967 PyObject *x = slot2(*operand1, operand2);
969 if (x != Py_NotImplemented) {
971 goto exit_inplace_result_object;
974 Py_DECREF_IMMORTAL(x);
977#if PYTHON_VERSION < 0x300
978 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
979 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
982 PyObject *coerced1 = *operand1;
983 PyObject *coerced2 = operand2;
985 int err = c1(&coerced1, &coerced2);
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_floor_divide;
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);
1014 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1017 PyObject *coerced1 = *operand1;
1018 PyObject *coerced2 = operand2;
1020 int err = c2(&coerced2, &coerced1);
1022 if (unlikely(err < 0)) {
1023 goto exit_inplace_exception;
1027 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1029 if (likely(mv == NULL)) {
1030 binaryfunc slot = mv->nb_floor_divide;
1032 if (likely(slot != NULL)) {
1033 PyObject *x = slot(coerced1, coerced2);
1035 Py_DECREF(coerced1);
1036 Py_DECREF(coerced2);
1039 goto exit_inplace_result_object;
1044 Py_DECREF(coerced1);
1045 Py_DECREF(coerced2);
1051#if PYTHON_VERSION < 0x300
1052 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'long' and '%s'", type2->tp_name);
1054 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'int' and '%s'", type2->tp_name);
1056 goto exit_inplace_exception;
1059exit_inplace_result_object:
1060 if (unlikely(obj_result == NULL)) {
1065 Py_DECREF(*operand1);
1069 *operand1 = obj_result;
1073exit_inplace_exception:
1076static inline bool _INPLACE_OPERATION_FLOORDIV_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1079 CHECK_OBJECT(*operand1);
1080 assert(PyLong_CheckExact(*operand1));
1081 CHECK_OBJECT(operand2);
1083 PyTypeObject *type2 = Py_TYPE(operand2);
1085 if (&PyLong_Type == type2) {
1089#if defined(_MSC_VER)
1090#pragma warning(push)
1091#pragma warning(disable : 4101)
1093 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1094 NUITKA_MAY_BE_UNUSED
long clong_result;
1095#if defined(_MSC_VER)
1099 PyObject *x = PyLong_Type.tp_as_number->nb_floor_divide(*operand1, operand2);
1100 assert(x != Py_NotImplemented);
1103 goto exit_result_object;
1106 if (unlikely(obj_result == NULL)) {
1107 goto exit_result_exception;
1110 Py_DECREF(*operand1);
1111 *operand1 = obj_result;
1112 goto exit_result_ok;
1117 exit_result_exception:
1121 return __INPLACE_OPERATION_FLOORDIV_LONG_OBJECT(operand1, operand2);
1124bool INPLACE_OPERATION_FLOORDIV_LONG_OBJECT(PyObject **operand1, PyObject *operand2) {
1125 return _INPLACE_OPERATION_FLOORDIV_LONG_OBJECT(operand1, operand2);
1129static inline bool _INPLACE_OPERATION_FLOORDIV_FLOAT_FLOAT(PyObject **operand1, PyObject *operand2) {
1132 CHECK_OBJECT(*operand1);
1133 assert(PyFloat_CheckExact(*operand1));
1134 CHECK_OBJECT(operand2);
1135 assert(PyFloat_CheckExact(operand2));
1137#if defined(_MSC_VER)
1138#pragma warning(push)
1139#pragma warning(disable : 4101)
1142 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1143 NUITKA_MAY_BE_UNUSED
long clong_result;
1144 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1145#if defined(_MSC_VER)
1149 CHECK_OBJECT(*operand1);
1150 assert(PyFloat_CheckExact(*operand1));
1151 CHECK_OBJECT(operand2);
1152 assert(PyFloat_CheckExact(operand2));
1154 const double a = PyFloat_AS_DOUBLE(*operand1);
1155 const double b = PyFloat_AS_DOUBLE(operand2);
1157 if (unlikely(b == 0)) {
1158 PyThreadState *tstate = PyThreadState_GET();
1160 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
1161 goto exit_result_exception;
1165 double mod = fmod(a, b);
1166 double div = (a - mod) / b;
1169 if ((a < 0) != (mod < 0)) {
1176 floordiv = floor(div);
1177 if (div - floordiv > 0.5) {
1181 floordiv = copysign(0.0, a / b);
1184 cfloat_result = floordiv;
1185 goto exit_result_ok_cfloat;
1188exit_result_ok_cfloat:
1189 if (Py_REFCNT(*operand1) == 1) {
1190 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
1193 Py_DECREF(*operand1);
1195 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
1197 goto exit_result_ok;
1202exit_result_exception:
1206bool INPLACE_OPERATION_FLOORDIV_FLOAT_FLOAT(PyObject **operand1, PyObject *operand2) {
1207 return _INPLACE_OPERATION_FLOORDIV_FLOAT_FLOAT(operand1, operand2);
1211static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_FLOORDIV_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
1212 PyTypeObject *type1 = Py_TYPE(*operand1);
1214#if defined(_MSC_VER)
1215#pragma warning(push)
1216#pragma warning(disable : 4101)
1218 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1219 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1220#if defined(_MSC_VER)
1224 binaryfunc islot = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1))
1225 ? type1->tp_as_number->nb_inplace_floor_divide
1228 if (islot != NULL) {
1229 PyObject *x = islot(*operand1, operand2);
1231 if (x != Py_NotImplemented) {
1233 goto exit_inplace_result_object;
1236 Py_DECREF_IMMORTAL(x);
1241 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_floor_divide : NULL;
1242 binaryfunc slot2 = NULL;
1244 if (!(type1 == &PyFloat_Type)) {
1247 slot2 = PyFloat_Type.tp_as_number->nb_floor_divide;
1249 if (slot1 == slot2) {
1254 if (slot1 != NULL) {
1255 PyObject *x = slot1(*operand1, operand2);
1257 if (x != Py_NotImplemented) {
1259 goto exit_inplace_result_object;
1262 Py_DECREF_IMMORTAL(x);
1265 if (slot2 != NULL) {
1266 PyObject *x = slot2(*operand1, operand2);
1268 if (x != Py_NotImplemented) {
1270 goto exit_inplace_result_object;
1273 Py_DECREF_IMMORTAL(x);
1276#if PYTHON_VERSION < 0x300
1277 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1279 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1282 PyObject *coerced1 = *operand1;
1283 PyObject *coerced2 = operand2;
1285 int err = c1(&coerced1, &coerced2);
1287 if (unlikely(err < 0)) {
1288 goto exit_inplace_exception;
1292 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1294 if (likely(mv == NULL)) {
1295 binaryfunc slot = mv->nb_floor_divide;
1297 if (likely(slot != NULL)) {
1298 PyObject *x = slot(coerced1, coerced2);
1300 Py_DECREF(coerced1);
1301 Py_DECREF(coerced2);
1304 goto exit_inplace_result_object;
1309 Py_DECREF(coerced1);
1310 Py_DECREF(coerced2);
1313 coercion c2 = PyFloat_Type.tp_as_number->nb_coerce;
1316 PyObject *coerced1 = *operand1;
1317 PyObject *coerced2 = operand2;
1319 int err = c2(&coerced2, &coerced1);
1321 if (unlikely(err < 0)) {
1322 goto exit_inplace_exception;
1326 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1328 if (likely(mv == NULL)) {
1329 binaryfunc slot = mv->nb_floor_divide;
1331 if (likely(slot != NULL)) {
1332 PyObject *x = slot(coerced1, coerced2);
1334 Py_DECREF(coerced1);
1335 Py_DECREF(coerced2);
1338 goto exit_inplace_result_object;
1343 Py_DECREF(coerced1);
1344 Py_DECREF(coerced2);
1350 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: '%s' and 'float'", type1->tp_name);
1351 goto exit_inplace_exception;
1354exit_inplace_result_object:
1355 if (unlikely(obj_result == NULL)) {
1360 Py_DECREF(*operand1);
1364 *operand1 = obj_result;
1368exit_inplace_exception:
1371static inline bool _INPLACE_OPERATION_FLOORDIV_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
1374 CHECK_OBJECT(*operand1);
1375 CHECK_OBJECT(operand2);
1376 assert(PyFloat_CheckExact(operand2));
1378 PyTypeObject *type1 = Py_TYPE(*operand1);
1380 if (type1 == &PyFloat_Type) {
1383#if defined(_MSC_VER)
1384#pragma warning(push)
1385#pragma warning(disable : 4101)
1388 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1389 NUITKA_MAY_BE_UNUSED
long clong_result;
1390 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1391#if defined(_MSC_VER)
1395 CHECK_OBJECT(*operand1);
1396 assert(PyFloat_CheckExact(*operand1));
1397 CHECK_OBJECT(operand2);
1398 assert(PyFloat_CheckExact(operand2));
1400 const double a = PyFloat_AS_DOUBLE(*operand1);
1401 const double b = PyFloat_AS_DOUBLE(operand2);
1403 if (unlikely(b == 0)) {
1404 PyThreadState *tstate = PyThreadState_GET();
1406 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
1407 goto exit_result_exception;
1411 double mod = fmod(a, b);
1412 double div = (a - mod) / b;
1415 if ((a < 0) != (mod < 0)) {
1422 floordiv = floor(div);
1423 if (div - floordiv > 0.5) {
1427 floordiv = copysign(0.0, a / b);
1430 cfloat_result = floordiv;
1431 goto exit_result_ok_cfloat;
1434 exit_result_ok_cfloat:
1435 if (Py_REFCNT(*operand1) == 1) {
1436 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
1439 Py_DECREF(*operand1);
1441 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
1443 goto exit_result_ok;
1448 exit_result_exception:
1452 return __INPLACE_OPERATION_FLOORDIV_OBJECT_FLOAT(operand1, operand2);
1455bool INPLACE_OPERATION_FLOORDIV_OBJECT_FLOAT(PyObject **operand1, PyObject *operand2) {
1456 return _INPLACE_OPERATION_FLOORDIV_OBJECT_FLOAT(operand1, operand2);
1460static HEDLEY_NEVER_INLINE
bool __INPLACE_OPERATION_FLOORDIV_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
1461 PyTypeObject *type2 = Py_TYPE(operand2);
1463#if defined(_MSC_VER)
1464#pragma warning(push)
1465#pragma warning(disable : 4101)
1467 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1468 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1469#if defined(_MSC_VER)
1476 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_floor_divide;
1477 binaryfunc slot2 = NULL;
1479 if (!(&PyFloat_Type == type2)) {
1482 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_floor_divide
1485 if (slot1 == slot2) {
1490 if (slot1 != NULL) {
1491 if (slot2 != NULL) {
1492 if (Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
1493 PyObject *x = slot2(*operand1, operand2);
1495 if (x != Py_NotImplemented) {
1497 goto exit_inplace_result_object;
1500 Py_DECREF_IMMORTAL(x);
1505 PyObject *x = slot1(*operand1, operand2);
1507 if (x != Py_NotImplemented) {
1509 goto exit_inplace_result_object;
1512 Py_DECREF_IMMORTAL(x);
1515 if (slot2 != NULL) {
1516 PyObject *x = slot2(*operand1, operand2);
1518 if (x != Py_NotImplemented) {
1520 goto exit_inplace_result_object;
1523 Py_DECREF_IMMORTAL(x);
1526#if PYTHON_VERSION < 0x300
1527 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1528 coercion c1 = PyFloat_Type.tp_as_number->nb_coerce;
1531 PyObject *coerced1 = *operand1;
1532 PyObject *coerced2 = operand2;
1534 int err = c1(&coerced1, &coerced2);
1536 if (unlikely(err < 0)) {
1537 goto exit_inplace_exception;
1541 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1543 if (likely(mv == NULL)) {
1544 binaryfunc slot = mv->nb_floor_divide;
1546 if (likely(slot != NULL)) {
1547 PyObject *x = slot(coerced1, coerced2);
1549 Py_DECREF(coerced1);
1550 Py_DECREF(coerced2);
1553 goto exit_inplace_result_object;
1558 Py_DECREF(coerced1);
1559 Py_DECREF(coerced2);
1563 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1566 PyObject *coerced1 = *operand1;
1567 PyObject *coerced2 = operand2;
1569 int err = c2(&coerced2, &coerced1);
1571 if (unlikely(err < 0)) {
1572 goto exit_inplace_exception;
1576 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1578 if (likely(mv == NULL)) {
1579 binaryfunc slot = mv->nb_floor_divide;
1581 if (likely(slot != NULL)) {
1582 PyObject *x = slot(coerced1, coerced2);
1584 Py_DECREF(coerced1);
1585 Py_DECREF(coerced2);
1588 goto exit_inplace_result_object;
1593 Py_DECREF(coerced1);
1594 Py_DECREF(coerced2);
1600 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'float' and '%s'", type2->tp_name);
1601 goto exit_inplace_exception;
1604exit_inplace_result_object:
1605 if (unlikely(obj_result == NULL)) {
1610 Py_DECREF(*operand1);
1614 *operand1 = obj_result;
1618exit_inplace_exception:
1621static inline bool _INPLACE_OPERATION_FLOORDIV_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
1624 CHECK_OBJECT(*operand1);
1625 assert(PyFloat_CheckExact(*operand1));
1626 CHECK_OBJECT(operand2);
1628 PyTypeObject *type2 = Py_TYPE(operand2);
1630 if (&PyFloat_Type == type2) {
1633#if defined(_MSC_VER)
1634#pragma warning(push)
1635#pragma warning(disable : 4101)
1638 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1639 NUITKA_MAY_BE_UNUSED
long clong_result;
1640 NUITKA_MAY_BE_UNUSED
double cfloat_result;
1641#if defined(_MSC_VER)
1645 CHECK_OBJECT(*operand1);
1646 assert(PyFloat_CheckExact(*operand1));
1647 CHECK_OBJECT(operand2);
1648 assert(PyFloat_CheckExact(operand2));
1650 const double a = PyFloat_AS_DOUBLE(*operand1);
1651 const double b = PyFloat_AS_DOUBLE(operand2);
1653 if (unlikely(b == 0)) {
1654 PyThreadState *tstate = PyThreadState_GET();
1656 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
1657 goto exit_result_exception;
1661 double mod = fmod(a, b);
1662 double div = (a - mod) / b;
1665 if ((a < 0) != (mod < 0)) {
1672 floordiv = floor(div);
1673 if (div - floordiv > 0.5) {
1677 floordiv = copysign(0.0, a / b);
1680 cfloat_result = floordiv;
1681 goto exit_result_ok_cfloat;
1684 exit_result_ok_cfloat:
1685 if (Py_REFCNT(*operand1) == 1) {
1686 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
1689 Py_DECREF(*operand1);
1691 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
1693 goto exit_result_ok;
1698 exit_result_exception:
1702 return __INPLACE_OPERATION_FLOORDIV_FLOAT_OBJECT(operand1, operand2);
1705bool INPLACE_OPERATION_FLOORDIV_FLOAT_OBJECT(PyObject **operand1, PyObject *operand2) {
1706 return _INPLACE_OPERATION_FLOORDIV_FLOAT_OBJECT(operand1, operand2);
1710static inline bool _INPLACE_OPERATION_FLOORDIV_FLOAT_LONG(PyObject **operand1, PyObject *operand2) {
1713 CHECK_OBJECT(*operand1);
1714 assert(PyFloat_CheckExact(*operand1));
1715 CHECK_OBJECT(operand2);
1716 assert(PyLong_CheckExact(operand2));
1718#if defined(_MSC_VER)
1719#pragma warning(push)
1720#pragma warning(disable : 4101)
1722 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1723 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1724#if defined(_MSC_VER)
1731 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_floor_divide;
1734 if (slot1 != NULL) {
1735 PyObject *x = slot1(*operand1, operand2);
1737 if (x != Py_NotImplemented) {
1739 goto exit_inplace_result_object;
1742 Py_DECREF_IMMORTAL(x);
1747#if PYTHON_VERSION < 0x300
1748 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'float' and 'long'");
1750 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'float' and 'int'");
1752 goto exit_inplace_exception;
1755exit_inplace_result_object:
1756 if (unlikely(obj_result == NULL)) {
1761 Py_DECREF(*operand1);
1765 *operand1 = obj_result;
1769exit_inplace_exception:
1773bool INPLACE_OPERATION_FLOORDIV_FLOAT_LONG(PyObject **operand1, PyObject *operand2) {
1774 return _INPLACE_OPERATION_FLOORDIV_FLOAT_LONG(operand1, operand2);
1778static inline bool _INPLACE_OPERATION_FLOORDIV_LONG_FLOAT(PyObject **operand1, PyObject *operand2) {
1781 CHECK_OBJECT(*operand1);
1782 assert(PyLong_CheckExact(*operand1));
1783 CHECK_OBJECT(operand2);
1784 assert(PyFloat_CheckExact(operand2));
1786#if defined(_MSC_VER)
1787#pragma warning(push)
1788#pragma warning(disable : 4101)
1790 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1791 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1792#if defined(_MSC_VER)
1800 binaryfunc slot2 = NULL;
1805 slot2 = PyFloat_Type.tp_as_number->nb_floor_divide;
1808 if (slot2 != NULL) {
1809 PyObject *x = slot2(*operand1, operand2);
1811 if (x != Py_NotImplemented) {
1813 goto exit_inplace_result_object;
1816 Py_DECREF_IMMORTAL(x);
1821#if PYTHON_VERSION < 0x300
1822 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'long' and 'float'");
1824 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'int' and 'float'");
1826 goto exit_inplace_exception;
1829exit_inplace_result_object:
1830 if (unlikely(obj_result == NULL)) {
1835 Py_DECREF(*operand1);
1839 *operand1 = obj_result;
1843exit_inplace_exception:
1847bool INPLACE_OPERATION_FLOORDIV_LONG_FLOAT(PyObject **operand1, PyObject *operand2) {
1848 return _INPLACE_OPERATION_FLOORDIV_LONG_FLOAT(operand1, operand2);
1851#if PYTHON_VERSION < 0x300
1853static inline bool _INPLACE_OPERATION_FLOORDIV_FLOAT_INT(PyObject **operand1, PyObject *operand2) {
1856 CHECK_OBJECT(*operand1);
1857 assert(PyFloat_CheckExact(*operand1));
1858 CHECK_OBJECT(operand2);
1859 assert(PyInt_CheckExact(operand2));
1861#if defined(_MSC_VER)
1862#pragma warning(push)
1863#pragma warning(disable : 4101)
1865 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1866 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1867#if defined(_MSC_VER)
1874 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_floor_divide;
1877 if (slot1 != NULL) {
1878 PyObject *x = slot1(*operand1, operand2);
1880 if (x != Py_NotImplemented) {
1882 goto exit_inplace_result_object;
1885 Py_DECREF_IMMORTAL(x);
1890 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'float' and 'int'");
1891 goto exit_inplace_exception;
1894exit_inplace_result_object:
1895 if (unlikely(obj_result == NULL)) {
1900 Py_DECREF(*operand1);
1904 *operand1 = obj_result;
1908exit_inplace_exception:
1912bool INPLACE_OPERATION_FLOORDIV_FLOAT_INT(PyObject **operand1, PyObject *operand2) {
1913 return _INPLACE_OPERATION_FLOORDIV_FLOAT_INT(operand1, operand2);
1917#if PYTHON_VERSION < 0x300
1919static inline bool _INPLACE_OPERATION_FLOORDIV_INT_FLOAT(PyObject **operand1, PyObject *operand2) {
1922 CHECK_OBJECT(*operand1);
1923 assert(PyInt_CheckExact(*operand1));
1924 CHECK_OBJECT(operand2);
1925 assert(PyFloat_CheckExact(operand2));
1927#if defined(_MSC_VER)
1928#pragma warning(push)
1929#pragma warning(disable : 4101)
1931 NUITKA_MAY_BE_UNUSED
bool cbool_result;
1932 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1933#if defined(_MSC_VER)
1941 binaryfunc slot2 = NULL;
1946 slot2 = PyFloat_Type.tp_as_number->nb_floor_divide;
1949 if (slot2 != NULL) {
1950 PyObject *x = slot2(*operand1, operand2);
1952 if (x != Py_NotImplemented) {
1954 goto exit_inplace_result_object;
1957 Py_DECREF_IMMORTAL(x);
1962 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'int' and 'float'");
1963 goto exit_inplace_exception;
1966exit_inplace_result_object:
1967 if (unlikely(obj_result == NULL)) {
1972 Py_DECREF(*operand1);
1976 *operand1 = obj_result;
1980exit_inplace_exception:
1984bool INPLACE_OPERATION_FLOORDIV_INT_FLOAT(PyObject **operand1, PyObject *operand2) {
1985 return _INPLACE_OPERATION_FLOORDIV_INT_FLOAT(operand1, operand2);
1989#if PYTHON_VERSION < 0x300
1991static inline bool _INPLACE_OPERATION_FLOORDIV_LONG_INT(PyObject **operand1, PyObject *operand2) {
1994 CHECK_OBJECT(*operand1);
1995 assert(PyLong_CheckExact(*operand1));
1996 CHECK_OBJECT(operand2);
1997 assert(PyInt_CheckExact(operand2));
1999#if defined(_MSC_VER)
2000#pragma warning(push)
2001#pragma warning(disable : 4101)
2003 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2004 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2005#if defined(_MSC_VER)
2012 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_floor_divide;
2015 if (slot1 != NULL) {
2016 PyObject *x = slot1(*operand1, operand2);
2018 if (x != Py_NotImplemented) {
2020 goto exit_inplace_result_object;
2023 Py_DECREF_IMMORTAL(x);
2028 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'long' and 'int'");
2029 goto exit_inplace_exception;
2032exit_inplace_result_object:
2033 if (unlikely(obj_result == NULL)) {
2038 Py_DECREF(*operand1);
2042 *operand1 = obj_result;
2046exit_inplace_exception:
2050bool INPLACE_OPERATION_FLOORDIV_LONG_INT(PyObject **operand1, PyObject *operand2) {
2051 return _INPLACE_OPERATION_FLOORDIV_LONG_INT(operand1, operand2);
2055#if PYTHON_VERSION < 0x300
2057static inline bool _INPLACE_OPERATION_FLOORDIV_INT_LONG(PyObject **operand1, PyObject *operand2) {
2060 CHECK_OBJECT(*operand1);
2061 assert(PyInt_CheckExact(*operand1));
2062 CHECK_OBJECT(operand2);
2063 assert(PyLong_CheckExact(operand2));
2065#if defined(_MSC_VER)
2066#pragma warning(push)
2067#pragma warning(disable : 4101)
2069 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2070 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2071#if defined(_MSC_VER)
2079 binaryfunc slot2 = NULL;
2084 slot2 = PyLong_Type.tp_as_number->nb_floor_divide;
2087 if (slot2 != NULL) {
2088 PyObject *x = slot2(*operand1, operand2);
2090 if (x != Py_NotImplemented) {
2092 goto exit_inplace_result_object;
2095 Py_DECREF_IMMORTAL(x);
2100 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: 'int' and 'long'");
2101 goto exit_inplace_exception;
2104exit_inplace_result_object:
2105 if (unlikely(obj_result == NULL)) {
2110 Py_DECREF(*operand1);
2114 *operand1 = obj_result;
2118exit_inplace_exception:
2122bool INPLACE_OPERATION_FLOORDIV_INT_LONG(PyObject **operand1, PyObject *operand2) {
2123 return _INPLACE_OPERATION_FLOORDIV_INT_LONG(operand1, operand2);
2127#if PYTHON_VERSION < 0x300
2129static inline bool _INPLACE_OPERATION_FLOORDIV_INT_CLONG(PyObject **operand1,
long operand2) {
2132 CHECK_OBJECT(*operand1);
2133 assert(PyInt_CheckExact(*operand1));
2136#if defined(_MSC_VER)
2137#pragma warning(push)
2138#pragma warning(disable : 4101)
2140 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2141 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2142 NUITKA_MAY_BE_UNUSED
long clong_result;
2143 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2144#if defined(_MSC_VER)
2148 CHECK_OBJECT(*operand1);
2149 assert(PyInt_CheckExact(*operand1));
2151 const long a = PyInt_AS_LONG(*operand1);
2152 const long b = operand2;
2154 if (unlikely(b == 0)) {
2155 PyThreadState *tstate = PyThreadState_GET();
2157 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
2158 goto exit_result_exception;
2167 if (likely(b != -1 || !UNARY_NEG_WOULD_OVERFLOW(a))) {
2168 long a_div_b = a / b;
2169 long a_mod_b = (long)(a - (
unsigned long)a_div_b * b);
2171 if (a_mod_b && (b ^ a_mod_b) < 0) {
2176 clong_result = a_div_b;
2177 goto exit_result_ok_clong;
2181 PyObject *operand1_object = *operand1;
2182 PyObject *operand2_object = Nuitka_PyLong_FromLong(operand2);
2184 PyObject *r = PyLong_Type.tp_as_number->nb_floor_divide(operand1_object, operand2_object);
2185 assert(r != Py_NotImplemented);
2187 Py_DECREF(operand2_object);
2190 goto exit_result_object;
2193exit_result_ok_clong:
2196 Py_DECREF(*operand1);
2200 *operand1 = Nuitka_PyInt_FromLong(clong_result);
2201 goto exit_result_ok;
2204 if (unlikely(obj_result == NULL)) {
2205 goto exit_result_exception;
2208 Py_DECREF(*operand1);
2210 *operand1 = obj_result;
2211 goto exit_result_ok;
2216exit_result_exception:
2220bool INPLACE_OPERATION_FLOORDIV_INT_CLONG(PyObject **operand1,
long operand2) {
2221 return _INPLACE_OPERATION_FLOORDIV_INT_CLONG(operand1, operand2);
2226static inline bool _INPLACE_OPERATION_FLOORDIV_FLOAT_CFLOAT(PyObject **operand1,
double operand2) {
2229 CHECK_OBJECT(*operand1);
2230 assert(PyFloat_CheckExact(*operand1));
2232#if defined(_MSC_VER)
2233#pragma warning(push)
2234#pragma warning(disable : 4101)
2237 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2238 NUITKA_MAY_BE_UNUSED
long clong_result;
2239 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2240#if defined(_MSC_VER)
2244 CHECK_OBJECT(*operand1);
2245 assert(PyFloat_CheckExact(*operand1));
2247 const double a = PyFloat_AS_DOUBLE(*operand1);
2248 const double b = operand2;
2250 if (unlikely(b == 0)) {
2251 PyThreadState *tstate = PyThreadState_GET();
2253 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
2254 goto exit_result_exception;
2258 double mod = fmod(a, b);
2259 double div = (a - mod) / b;
2262 if ((a < 0) != (mod < 0)) {
2269 floordiv = floor(div);
2270 if (div - floordiv > 0.5) {
2274 floordiv = copysign(0.0, a / b);
2277 cfloat_result = floordiv;
2278 goto exit_result_ok_cfloat;
2281exit_result_ok_cfloat:
2282 if (Py_REFCNT(*operand1) == 1) {
2283 PyFloat_SET_DOUBLE(*operand1, cfloat_result);
2286 Py_DECREF(*operand1);
2288 *operand1 = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
2290 goto exit_result_ok;
2295exit_result_exception:
2299bool INPLACE_OPERATION_FLOORDIV_FLOAT_CFLOAT(PyObject **operand1,
double operand2) {
2300 return _INPLACE_OPERATION_FLOORDIV_FLOAT_CFLOAT(operand1, operand2);
2304static inline bool _INPLACE_OPERATION_FLOORDIV_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
2307 CHECK_OBJECT(*operand1);
2308 CHECK_OBJECT(operand2);
2310#if PYTHON_VERSION < 0x300
2311 if (PyInt_CheckExact(*operand1) && PyInt_CheckExact(operand2)) {
2314#if defined(_MSC_VER)
2315#pragma warning(push)
2316#pragma warning(disable : 4101)
2318 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2319 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2320 NUITKA_MAY_BE_UNUSED
long clong_result;
2321 NUITKA_MAY_BE_UNUSED
double cfloat_result;
2322#if defined(_MSC_VER)
2326 CHECK_OBJECT(*operand1);
2327 assert(PyInt_CheckExact(*operand1));
2328 CHECK_OBJECT(operand2);
2329 assert(PyInt_CheckExact(operand2));
2331 const long a = PyInt_AS_LONG(*operand1);
2332 const long b = PyInt_AS_LONG(operand2);
2334 if (unlikely(b == 0)) {
2335 PyThreadState *tstate = PyThreadState_GET();
2337 SET_CURRENT_EXCEPTION_TYPE0_STR(tstate, PyExc_ZeroDivisionError,
"integer division or modulo by zero");
2338 goto exit_result_exception;
2347 if (likely(b != -1 || !UNARY_NEG_WOULD_OVERFLOW(a))) {
2348 long a_div_b = a / b;
2349 long a_mod_b = (long)(a - (
unsigned long)a_div_b * b);
2351 if (a_mod_b && (b ^ a_mod_b) < 0) {
2356 clong_result = a_div_b;
2357 goto exit_result_ok_clong;
2361 PyObject *operand1_object = *operand1;
2362 PyObject *operand2_object = operand2;
2364 PyObject *r = PyLong_Type.tp_as_number->nb_floor_divide(operand1_object, operand2_object);
2365 assert(r != Py_NotImplemented);
2368 goto exit_result_object;
2371 exit_result_ok_clong:
2374 Py_DECREF(*operand1);
2378 *operand1 = Nuitka_PyInt_FromLong(clong_result);
2379 goto exit_result_ok;
2382 if (unlikely(obj_result == NULL)) {
2383 goto exit_result_exception;
2386 Py_DECREF(*operand1);
2388 *operand1 = obj_result;
2389 goto exit_result_ok;
2394 exit_result_exception:
2399 if (Py_TYPE(*operand1) == Py_TYPE(operand2)) {
2400 if (PyFloat_CheckExact(operand2)) {
2401 return _INPLACE_OPERATION_FLOORDIV_FLOAT_FLOAT(operand1, operand2);
2403#if PYTHON_VERSION >= 0x300
2404 if (PyLong_CheckExact(operand2)) {
2405 return _INPLACE_OPERATION_FLOORDIV_LONG_LONG(operand1, operand2);
2410 PyTypeObject *type1 = Py_TYPE(*operand1);
2411 PyTypeObject *type2 = Py_TYPE(operand2);
2413#if defined(_MSC_VER)
2414#pragma warning(push)
2415#pragma warning(disable : 4101)
2417 NUITKA_MAY_BE_UNUSED
bool cbool_result;
2418 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2419#if defined(_MSC_VER)
2423 binaryfunc islot = (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1))
2424 ? type1->tp_as_number->nb_inplace_floor_divide
2427 if (islot != NULL) {
2428 PyObject *x = islot(*operand1, operand2);
2430 if (x != Py_NotImplemented) {
2432 goto exit_inplace_result_object;
2435 Py_DECREF_IMMORTAL(x);
2440 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_floor_divide : NULL;
2441 binaryfunc slot2 = NULL;
2443 if (!(type1 == type2)) {
2446 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_floor_divide
2449 if (slot1 == slot2) {
2454 if (slot1 != NULL) {
2455 if (slot2 != NULL) {
2456 if (Nuitka_Type_IsSubtype(type2, type1)) {
2457 PyObject *x = slot2(*operand1, operand2);
2459 if (x != Py_NotImplemented) {
2461 goto exit_inplace_result_object;
2464 Py_DECREF_IMMORTAL(x);
2469 PyObject *x = slot1(*operand1, operand2);
2471 if (x != Py_NotImplemented) {
2473 goto exit_inplace_result_object;
2476 Py_DECREF_IMMORTAL(x);
2479 if (slot2 != NULL) {
2480 PyObject *x = slot2(*operand1, operand2);
2482 if (x != Py_NotImplemented) {
2484 goto exit_inplace_result_object;
2487 Py_DECREF_IMMORTAL(x);
2490#if PYTHON_VERSION < 0x300
2491 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
2493 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2496 PyObject *coerced1 = *operand1;
2497 PyObject *coerced2 = operand2;
2499 int err = c1(&coerced1, &coerced2);
2501 if (unlikely(err < 0)) {
2502 goto exit_inplace_exception;
2506 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2508 if (likely(mv == NULL)) {
2509 binaryfunc slot = mv->nb_floor_divide;
2511 if (likely(slot != NULL)) {
2512 PyObject *x = slot(coerced1, coerced2);
2514 Py_DECREF(coerced1);
2515 Py_DECREF(coerced2);
2518 goto exit_inplace_result_object;
2523 Py_DECREF(coerced1);
2524 Py_DECREF(coerced2);
2528 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2531 PyObject *coerced1 = *operand1;
2532 PyObject *coerced2 = operand2;
2534 int err = c2(&coerced2, &coerced1);
2536 if (unlikely(err < 0)) {
2537 goto exit_inplace_exception;
2541 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2543 if (likely(mv == NULL)) {
2544 binaryfunc slot = mv->nb_floor_divide;
2546 if (likely(slot != NULL)) {
2547 PyObject *x = slot(coerced1, coerced2);
2549 Py_DECREF(coerced1);
2550 Py_DECREF(coerced2);
2553 goto exit_inplace_result_object;
2558 Py_DECREF(coerced1);
2559 Py_DECREF(coerced2);
2565 PyErr_Format(PyExc_TypeError,
"unsupported operand type(s) for //=: '%s' and '%s'", type1->tp_name,
2567 goto exit_inplace_exception;
2570exit_inplace_result_object:
2571 if (unlikely(obj_result == NULL)) {
2576 Py_DECREF(*operand1);
2580 *operand1 = obj_result;
2584exit_inplace_exception:
2588bool INPLACE_OPERATION_FLOORDIV_OBJECT_OBJECT(PyObject **operand1, PyObject *operand2) {
2589 return _INPLACE_OPERATION_FLOORDIV_OBJECT_OBJECT(operand1, operand2);