From 95720b965f1766f0840f13a09dd9be24c6228c6b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 19 Feb 2024 00:00:34 +0800 Subject: [PATCH] rollback --- include/pocketpy/codeobject.h | 8 ++++---- include/pocketpy/frame.h | 2 +- include/pocketpy/lexer.h | 2 +- src/vm.cpp | 13 ++++--------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/pocketpy/codeobject.h b/include/pocketpy/codeobject.h index 3ccd4922..6e06731e 100644 --- a/include/pocketpy/codeobject.h +++ b/include/pocketpy/codeobject.h @@ -72,9 +72,9 @@ struct CodeObject { std::vector lines; List consts; - small_vector varnames; // local variables + pod_vector varnames; // local variables NameDictInt varnames_inv; - small_vector blocks; + std::vector blocks; NameDictInt labels; std::vector func_decls; @@ -96,8 +96,8 @@ struct FuncDecl { PyObject* value; // default value }; CodeObject_ code; // code object of this function - small_vector args; // indices in co->varnames - small_vector kwargs; // indices in co->varnames + pod_vector args; // indices in co->varnames + pod_vector kwargs; // indices in co->varnames int starred_arg = -1; // index in co->varnames, -1 if no *arg int starred_kwarg = -1; // index in co->varnames, -1 if no **kwarg bool nested = false; // whether this function is nested diff --git a/include/pocketpy/frame.h b/include/pocketpy/frame.h index 28ef6b9e..b5d84902 100644 --- a/include/pocketpy/frame.h +++ b/include/pocketpy/frame.h @@ -126,7 +126,7 @@ struct Frame { } }; -using CallstackContainer = small_vector; +using CallstackContainer = std::vector; struct FrameId{ CallstackContainer* data; diff --git a/include/pocketpy/lexer.h b/include/pocketpy/lexer.h index 34d0f819..97fed808 100644 --- a/include/pocketpy/lexer.h +++ b/include/pocketpy/lexer.h @@ -104,7 +104,7 @@ struct Lexer { const char* curr_char; int current_line = 1; std::vector nexts; - stack_no_copy> indents; + stack_no_copy> indents; int brackets_level = 0; bool used = false; diff --git a/src/vm.cpp b/src/vm.cpp index 5bf3bb33..5ea4804b 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -69,17 +69,12 @@ namespace pkpy{ VM::VM(bool enable_os) : heap(this), enable_os(enable_os) { this->vm = this; this->_c.error = nullptr; - _stdout = [](const char* buf, int size) { - std::cout.write(buf, size); - }; - _stderr = [](const char* buf, int size) { - std::cerr.write(buf, size); - }; + this->callstack.reserve(8); + _stdout = [](const char* buf, int size) { std::cout.write(buf, size); }; + _stderr = [](const char* buf, int size) { std::cerr.write(buf, size); }; _main = nullptr; _last_exception = nullptr; - _import_handler = [](const char* name_p, int name_size, int* out_size) -> unsigned char*{ - return nullptr; - }; + _import_handler = [](const char* name_p, int name_size, int* out_size) -> unsigned char*{ return nullptr; }; init_builtin_types(); }