From 818ee2981e19b339c033180790aa188109298159 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 5 Apr 2023 22:43:43 +0800 Subject: [PATCH] up --- scripts/run_tests.py | 6 +++++- src/ceval.h | 7 ++----- src/common.h | 2 +- src/compiler.h | 2 +- src/frame.h | 13 ++++--------- tests/25_rawstring.py | 2 ++ 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/scripts/run_tests.py b/scripts/run_tests.py index 8641d221..f444f235 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -27,7 +27,11 @@ def test_dir(path): print(f' cpython: {_1 - _0:.6f}s (100%)') print(f' pocketpy: {_2 - _1:.6f}s ({(_2 - _1) / (_1 - _0) * 100:.2f}%)') else: - if not test_file(filepath): exit(1) + if not test_file(filepath): + print('-' * 50) + print("TEST FAILED! Press any key to continue...") + input() + if len(sys.argv) == 2: assert 'benchmark' in sys.argv[1] diff --git a/src/ceval.h b/src/ceval.h index fd164d02..0805683b 100644 --- a/src/ceval.h +++ b/src/ceval.h @@ -149,11 +149,8 @@ __NEXT_STEP:; frame->push(VAR(std::move(items))); } DISPATCH(); case OP_BUILD_STRING: { - // asStr() may run extra bytecode - // so we use top_n_reversed() in order to avoid accidental gc - Args items = frame->top_n_reversed(byte.arg); - StrStream ss; - for(int i=0; i=0; i--) ss << CAST(Str&, asStr(frame->top_n(i))); frame->pop_n(byte.arg); frame->push(VAR(ss.str())); } DISPATCH(); diff --git a/src/common.h b/src/common.h index c337e398..205c73a3 100644 --- a/src/common.h +++ b/src/common.h @@ -35,7 +35,7 @@ #define DEBUG_EXTRA_CHECK 1 #define DEBUG_DIS_REPL 0 #define DEBUG_DIS_REPL_MIN 1 -#define DEBUG_FULL_EXCEPTION 1 +#define DEBUG_FULL_EXCEPTION 0 #if (defined(__ANDROID__) && __ANDROID_API__ <= 22) || defined(__EMSCRIPTEN__) #define PK_ENABLE_FILEIO 0 diff --git a/src/compiler.h b/src/compiler.h index 725327ba..5757c458 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -952,7 +952,7 @@ public: match_newlines(); // skip possible leading '\n' if(mode()==EVAL_MODE) { - EXPR_TUPLE(); + EXPR_TUPLE(false); consume(TK("@eof")); ctx()->emit(OP_RETURN_VALUE, BC_NOARG, BC_KEEPLINE); pop_context(); diff --git a/src/frame.h b/src/frame.h index 23d85b60..2b193a07 100644 --- a/src/frame.h +++ b/src/frame.h @@ -85,11 +85,12 @@ struct Frame { return _data[_data.size()-2]; } - PyObject*& top_2(){ + PyObject*& top_n(int n){ + n += 1; #if DEBUG_EXTRA_CHECK - if(_data.size() < 3) throw std::runtime_error("_data.size() < 3"); + if(_data.size() < n) throw std::runtime_error("_data.size() < n"); #endif - return _data[_data.size()-3]; + return _data[_data.size()-n]; } template @@ -142,12 +143,6 @@ struct Frame { return v; } - Args top_n_reversed(int n){ - Args v(n); - for(int i=0; i->{s}<-<- {123} '''