mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
some fix
This commit is contained in:
parent
2d3abde352
commit
79ae2cdc28
@ -380,6 +380,8 @@ public:
|
||||
const PyTypeInfo* _tp_info(Type type) { return &_all_types[type]; }
|
||||
PyVar _t(PyVar obj){ return _all_types[_tp(obj)].obj; }
|
||||
PyVar _t(Type type){ return _all_types[type].obj; }
|
||||
|
||||
static bool is_not_implemented(PyVar obj){ return obj.type == tp_not_implemented; }
|
||||
#endif
|
||||
|
||||
#if PK_REGION("User Type Registration")
|
||||
|
@ -27,12 +27,12 @@ namespace pkpy{
|
||||
if(_2 != nullptr) ret = call_method(self, _2, _1); \
|
||||
else ret = NotImplemented; \
|
||||
} \
|
||||
if(ret == NotImplemented){ \
|
||||
if(is_not_implemented(ret)){ \
|
||||
PyVar self; \
|
||||
PyVar _2 = get_unbound_method(_1, rfunc, &self, false); \
|
||||
if(_2 != nullptr) ret = call_method(self, _2, _0); \
|
||||
else BinaryOptError(op, _0, _1); \
|
||||
if(ret == NotImplemented) BinaryOptError(op, _0, _1); \
|
||||
if(is_not_implemented(ret)) BinaryOptError(op, _0, _1); \
|
||||
}
|
||||
|
||||
|
||||
@ -465,12 +465,12 @@ __NEXT_STEP:
|
||||
}
|
||||
|
||||
#define BINARY_OP_RSPECIAL(op, func) \
|
||||
if(TOP() == NotImplemented){ \
|
||||
if(is_not_implemented(TOP())){ \
|
||||
PyVar self; \
|
||||
PyVar _2 = get_unbound_method(_1, func, &self, false); \
|
||||
if(_2 != nullptr) TOP() = call_method(self, _2, _0); \
|
||||
else BinaryOptError(op, _0, _1); \
|
||||
if(TOP() == NotImplemented) BinaryOptError(op, _0, _1); \
|
||||
if(is_not_implemented(TOP())) BinaryOptError(op, _0, _1); \
|
||||
}
|
||||
|
||||
case OP_BINARY_TRUEDIV:{
|
||||
@ -478,14 +478,14 @@ __NEXT_STEP:
|
||||
PyVar _0 = TOP();
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__truediv__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("/", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("/", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BINARY_POW:{
|
||||
PyVar _1 = POPX();
|
||||
PyVar _0 = TOP();
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__pow__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("**", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("**", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BINARY_ADD:{
|
||||
PyVar _1 = POPX();
|
||||
@ -517,7 +517,7 @@ __NEXT_STEP:
|
||||
PREDICT_INT_DIV_OP(/)
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__floordiv__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("//", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("//", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BINARY_MOD:{
|
||||
PyVar _1 = POPX();
|
||||
@ -525,7 +525,7 @@ __NEXT_STEP:
|
||||
PREDICT_INT_DIV_OP(%)
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__mod__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("%", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("%", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_COMPARE_LT:{
|
||||
PyVar _1 = POPX();
|
||||
@ -567,7 +567,7 @@ __NEXT_STEP:
|
||||
PREDICT_INT_OP(<<)
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__lshift__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("<<", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("<<", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BITWISE_RSHIFT:{
|
||||
PyVar _1 = POPX();
|
||||
@ -575,7 +575,7 @@ __NEXT_STEP:
|
||||
PREDICT_INT_OP(>>)
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__rshift__);
|
||||
if(TOP() == NotImplemented) BinaryOptError(">>", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError(">>", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BITWISE_AND:{
|
||||
PyVar _1 = POPX();
|
||||
@ -583,7 +583,7 @@ __NEXT_STEP:
|
||||
PREDICT_INT_OP(&)
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__and__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("&", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("&", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BITWISE_OR:{
|
||||
PyVar _1 = POPX();
|
||||
@ -591,7 +591,7 @@ __NEXT_STEP:
|
||||
PREDICT_INT_OP(|)
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__or__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("|", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("|", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BITWISE_XOR:{
|
||||
PyVar _1 = POPX();
|
||||
@ -599,14 +599,14 @@ __NEXT_STEP:
|
||||
PREDICT_INT_OP(^)
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__xor__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("^", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("^", _0, _1);
|
||||
} DISPATCH()
|
||||
case OP_BINARY_MATMUL:{
|
||||
PyVar _1 = POPX();
|
||||
PyVar _0 = TOP();
|
||||
const PyTypeInfo* _ti;
|
||||
BINARY_OP_SPECIAL(__matmul__);
|
||||
if(TOP() == NotImplemented) BinaryOptError("@", _0, _1);
|
||||
if(is_not_implemented(TOP())) BinaryOptError("@", _0, _1);
|
||||
} DISPATCH()
|
||||
|
||||
#undef BINARY_OP_SPECIAL
|
||||
|
@ -229,18 +229,18 @@ namespace pkpy{
|
||||
PyVar res;
|
||||
if(ti->m__eq__){
|
||||
res = ti->m__eq__(this, lhs, rhs);
|
||||
if(res != vm->NotImplemented) return res == vm->True;
|
||||
if(!is_not_implemented(res)) return res == vm->True;
|
||||
}
|
||||
res = call_method(lhs, __eq__, rhs);
|
||||
if(res != vm->NotImplemented) return res == vm->True;
|
||||
if(!is_not_implemented(res)) return res == vm->True;
|
||||
|
||||
ti = _tp_info(rhs);
|
||||
if(ti->m__eq__){
|
||||
res = ti->m__eq__(this, rhs, lhs);
|
||||
if(res != vm->NotImplemented) return res == vm->True;
|
||||
if(!is_not_implemented(res)) return res == vm->True;
|
||||
}
|
||||
res = call_method(rhs, __eq__, lhs);
|
||||
if(res != vm->NotImplemented) return res == vm->True;
|
||||
if(!is_not_implemented(res)) return res == vm->True;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user