From 30798f101c46d2743d374a29ead06a53fda33e71 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 28 Jan 2023 03:19:26 +0800 Subject: [PATCH] up --- scripts/run_tests.py | 7 +++++-- src/safestl.h | 9 +++++++++ src/vm.h | 12 +++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scripts/run_tests.py b/scripts/run_tests.py index 6d29bf5e..f3ced97b 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -1,8 +1,11 @@ import os +import sys def test_file(filepath): - return os.system("./pocketpy " + filepath) == 0 - #return os.system("python3 " + filepath) == 0 + if sys.platform == 'win32': + return os.system("pocketpy.exe " + filepath) == 0 + else: + return os.system("./pocketpy " + filepath) == 0 def test_dir(path): has_error = False diff --git a/src/safestl.h b/src/safestl.h index 93bfedab..23be4619 100644 --- a/src/safestl.h +++ b/src/safestl.h @@ -128,6 +128,15 @@ namespace pkpy { return ret; } + ArgList move_extended_self(const PyVar& self){ + static_assert(std::is_standard_layout_v); + pkpy::ArgList ret(size()+1); + ret[0] = self; + memcpy(ret._args+1, _args, sizeof(PyVar)*size()); + memset(_args, 0, sizeof(PyVar)*size()); + return ret; + } + ~ArgList(){ __tryRelease(); } diff --git a/src/vm.h b/src/vm.h index 6f9b0f23..a77b8249 100644 --- a/src/vm.h +++ b/src/vm.h @@ -449,12 +449,14 @@ public: const PyVar* callable = &_callable; if((*callable)->is_type(_tp_bounded_method)){ auto& bm = PyBoundedMethod_AS_C((*callable)); + callable = &bm.method; // get unbound method + // TODO: avoid insertion here, bad performance - pkpy::ArgList new_args(args.size()+1); - new_args[0] = bm.obj; - for(int i=0; iis_type(_tp_native_function)){