mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
up
This commit is contained in:
parent
07f8c6fc06
commit
0d99fbb947
@ -128,8 +128,9 @@ void __initializeBuiltinFunctions(VM* _vm) {
|
||||
return vm->PyStr(s);
|
||||
});
|
||||
|
||||
_vm->bindMethod<1>("object", "__eq__", CPP_LAMBDA(vm->PyBool(args[0] == args[1])));
|
||||
|
||||
_vm->bindStaticMethod<1>("type", "__new__", CPP_LAMBDA(args[0]->_type));
|
||||
_vm->bindMethod<1>("type", "__eq__", CPP_LAMBDA(vm->PyBool(args[0] == args[1])));
|
||||
|
||||
_vm->bindStaticMethod<-1>("range", "__new__", [](VM* vm, const pkpy::ArgList& args) {
|
||||
_Range r;
|
||||
@ -148,7 +149,6 @@ void __initializeBuiltinFunctions(VM* _vm) {
|
||||
|
||||
_vm->bindMethod<0>("NoneType", "__repr__", CPP_LAMBDA(vm->PyStr("None")));
|
||||
_vm->bindMethod<0>("NoneType", "__json__", CPP_LAMBDA(vm->PyStr("null")));
|
||||
_vm->bindMethod<1>("NoneType", "__eq__", CPP_LAMBDA(vm->PyBool(args[0] == args[1])));
|
||||
|
||||
_vm->bindMethodMulti<1>({"int", "float"}, "__truediv__", [](VM* vm, const pkpy::ArgList& args) {
|
||||
f64 rhs = vm->num_to_float(args[1]);
|
||||
@ -292,7 +292,7 @@ void __initializeBuiltinFunctions(VM* _vm) {
|
||||
_vm->bindMethod<1>("str", "__eq__", [](VM* vm, const pkpy::ArgList& args) {
|
||||
if(args[0]->is_type(vm->_tp_str) && args[1]->is_type(vm->_tp_str))
|
||||
return vm->PyBool(vm->PyStr_AS_C(args[0]) == vm->PyStr_AS_C(args[1]));
|
||||
return vm->PyBool(args[0] == args[1]); // fallback
|
||||
return vm->PyBool(args[0] == args[1]);
|
||||
});
|
||||
|
||||
_vm->bindMethod<1>("str", "__getitem__", [](VM* vm, const pkpy::ArgList& args) {
|
||||
@ -478,10 +478,6 @@ void __initializeBuiltinFunctions(VM* _vm) {
|
||||
return vm->PyStr(val ? "true" : "false");
|
||||
});
|
||||
|
||||
_vm->bindMethod<1>("bool", "__eq__", [](VM* vm, const pkpy::ArgList& args) {
|
||||
return vm->PyBool(args[0] == args[1]);
|
||||
});
|
||||
|
||||
_vm->bindMethod<1>("bool", "__xor__", [](VM* vm, const pkpy::ArgList& args) {
|
||||
bool _self = vm->PyBool_AS_C(args[0]);
|
||||
bool _obj = vm->PyBool_AS_C(args[1]);
|
||||
|
@ -118,7 +118,7 @@ namespace pkpy {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void extended_self(const PyVar& self){
|
||||
void extend_self(const PyVar& self){
|
||||
static_assert(std::is_standard_layout_v<PyVar>);
|
||||
PyVar* old_args = _args;
|
||||
uint8_t old_size = _size;
|
||||
@ -126,8 +126,8 @@ namespace pkpy {
|
||||
_args[0] = self;
|
||||
if(old_size == 0) return;
|
||||
|
||||
memcpy(_args+1, old_args, sizeof(PyVar)*old_size);
|
||||
memset(old_args, 0, sizeof(PyVar)*old_size);
|
||||
memcpy((void*)(_args+1), (void*)old_args, sizeof(PyVar)*old_size);
|
||||
memset((void*)old_args, 0, sizeof(PyVar)*old_size);
|
||||
if(old_size >= MAX_POOLING_N || _poolArgList[old_size].size() > 32){
|
||||
delete[] old_args;
|
||||
}else{
|
||||
|
Loading…
x
Reference in New Issue
Block a user