This commit is contained in:
blueloveTH 2024-02-19 00:00:34 +08:00
parent 472c64323c
commit 95720b965f
4 changed files with 10 additions and 15 deletions

View File

@ -72,9 +72,9 @@ struct CodeObject {
std::vector<LineInfo> lines; std::vector<LineInfo> lines;
List consts; List consts;
small_vector<StrName, 16> varnames; // local variables pod_vector<StrName> varnames; // local variables
NameDictInt varnames_inv; NameDictInt varnames_inv;
small_vector<CodeBlock, 4> blocks; std::vector<CodeBlock> blocks;
NameDictInt labels; NameDictInt labels;
std::vector<FuncDecl_> func_decls; std::vector<FuncDecl_> func_decls;
@ -96,8 +96,8 @@ struct FuncDecl {
PyObject* value; // default value PyObject* value; // default value
}; };
CodeObject_ code; // code object of this function CodeObject_ code; // code object of this function
small_vector<int, 4> args; // indices in co->varnames pod_vector<int> args; // indices in co->varnames
small_vector<KwArg, 4> kwargs; // indices in co->varnames pod_vector<KwArg> kwargs; // indices in co->varnames
int starred_arg = -1; // index in co->varnames, -1 if no *arg int starred_arg = -1; // index in co->varnames, -1 if no *arg
int starred_kwarg = -1; // index in co->varnames, -1 if no **kwarg int starred_kwarg = -1; // index in co->varnames, -1 if no **kwarg
bool nested = false; // whether this function is nested bool nested = false; // whether this function is nested

View File

@ -126,7 +126,7 @@ struct Frame {
} }
}; };
using CallstackContainer = small_vector<Frame, 8>; using CallstackContainer = std::vector<Frame>;
struct FrameId{ struct FrameId{
CallstackContainer* data; CallstackContainer* data;

View File

@ -104,7 +104,7 @@ struct Lexer {
const char* curr_char; const char* curr_char;
int current_line = 1; int current_line = 1;
std::vector<Token> nexts; std::vector<Token> nexts;
stack_no_copy<int, small_vector<int, 6>> indents; stack_no_copy<int, pod_vector<int>> indents;
int brackets_level = 0; int brackets_level = 0;
bool used = false; bool used = false;

View File

@ -69,17 +69,12 @@ namespace pkpy{
VM::VM(bool enable_os) : heap(this), enable_os(enable_os) { VM::VM(bool enable_os) : heap(this), enable_os(enable_os) {
this->vm = this; this->vm = this;
this->_c.error = nullptr; this->_c.error = nullptr;
_stdout = [](const char* buf, int size) { this->callstack.reserve(8);
std::cout.write(buf, size); _stdout = [](const char* buf, int size) { std::cout.write(buf, size); };
}; _stderr = [](const char* buf, int size) { std::cerr.write(buf, size); };
_stderr = [](const char* buf, int size) {
std::cerr.write(buf, size);
};
_main = nullptr; _main = nullptr;
_last_exception = nullptr; _last_exception = nullptr;
_import_handler = [](const char* name_p, int name_size, int* out_size) -> unsigned char*{ _import_handler = [](const char* name_p, int name_size, int* out_size) -> unsigned char*{ return nullptr; };
return nullptr;
};
init_builtin_types(); init_builtin_types();
} }