This commit is contained in:
blueloveTH 2023-01-29 05:38:42 +08:00
parent e61eb15a62
commit 57c8f9ede4
2 changed files with 9 additions and 15 deletions

View File

@ -26,7 +26,9 @@ _Code VM::compile(_Str source, _Str filename, CompileMode mode) {
#define BIND_NUM_LOGICAL_OPT(name, op, is_eq) \
_vm->bindMethodMulti<1>({"int","float"}, #name, [](VM* vm, const pkpy::ArgList& args){ \
if(!vm->is_int_or_float(args[0], args[1])){ \
bool _0 = args[0]->is_type(vm->_tp_int) || args[0]->is_type(vm->_tp_float); \
bool _1 = args[1]->is_type(vm->_tp_int) || args[1]->is_type(vm->_tp_float); \
if(!_0 || !_1){ \
if constexpr(is_eq) return vm->PyBool(args[0] == args[1]); \
vm->typeError("unsupported operand type(s) for " #op ); \
} \

View File

@ -686,14 +686,6 @@ public:
bindFunc<ARGC>(builtins, funcName, fn);
}
inline bool is_int_or_float(const PyVar& obj) const{
return obj->is_type(_tp_int) || obj->is_type(_tp_float);
}
inline bool is_int_or_float(const PyVar& obj1, const PyVar& obj2) const{
return is_int_or_float(obj1) && is_int_or_float(obj2);
}
inline f64 num_to_float(const PyVar& obj){
if (obj->is_type(_tp_int)){
return (f64)PyInt_AS_C(obj);