mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
add PREDICT_INT_DIV_OP
This commit is contained in:
parent
07116877b7
commit
44c61a8c3a
@ -8,6 +8,13 @@ namespace pkpy{
|
|||||||
DISPATCH() \
|
DISPATCH() \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define PREDICT_INT_DIV_OP(op) \
|
||||||
|
if(is_small_int(_0) && is_small_int(_1)){ \
|
||||||
|
if(_1 == VAR(0)) ZeroDivisionError(); \
|
||||||
|
TOP() = VAR((i64)(PK_BITS(_0)>>2) op (i64)(PK_BITS(_1)>>2)); \
|
||||||
|
DISPATCH() \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define BINARY_F_COMPARE(func, op, rfunc) \
|
#define BINARY_F_COMPARE(func, op, rfunc) \
|
||||||
PyObject* ret; \
|
PyObject* ret; \
|
||||||
@ -419,6 +426,7 @@ __NEXT_STEP:;
|
|||||||
TARGET(BINARY_FLOORDIV){
|
TARGET(BINARY_FLOORDIV){
|
||||||
PyObject* _1 = POPX();
|
PyObject* _1 = POPX();
|
||||||
PyObject* _0 = TOP();
|
PyObject* _0 = TOP();
|
||||||
|
PREDICT_INT_DIV_OP(/)
|
||||||
const PyTypeInfo* _ti;
|
const PyTypeInfo* _ti;
|
||||||
BINARY_OP_SPECIAL(__floordiv__);
|
BINARY_OP_SPECIAL(__floordiv__);
|
||||||
if(TOP() == NotImplemented) BinaryOptError("//", _0, _1);
|
if(TOP() == NotImplemented) BinaryOptError("//", _0, _1);
|
||||||
@ -426,6 +434,7 @@ __NEXT_STEP:;
|
|||||||
TARGET(BINARY_MOD){
|
TARGET(BINARY_MOD){
|
||||||
PyObject* _1 = POPX();
|
PyObject* _1 = POPX();
|
||||||
PyObject* _0 = TOP();
|
PyObject* _0 = TOP();
|
||||||
|
PREDICT_INT_DIV_OP(%)
|
||||||
const PyTypeInfo* _ti;
|
const PyTypeInfo* _ti;
|
||||||
BINARY_OP_SPECIAL(__mod__);
|
BINARY_OP_SPECIAL(__mod__);
|
||||||
if(TOP() == NotImplemented) BinaryOptError("%", _0, _1);
|
if(TOP() == NotImplemented) BinaryOptError("%", _0, _1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user