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;
List consts;
small_vector<StrName, 16> varnames; // local variables
pod_vector<StrName> varnames; // local variables
NameDictInt varnames_inv;
small_vector<CodeBlock, 4> blocks;
std::vector<CodeBlock> blocks;
NameDictInt labels;
std::vector<FuncDecl_> func_decls;
@ -96,8 +96,8 @@ struct FuncDecl {
PyObject* value; // default value
};
CodeObject_ code; // code object of this function
small_vector<int, 4> args; // indices in co->varnames
small_vector<KwArg, 4> kwargs; // indices in co->varnames
pod_vector<int> args; // 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_kwarg = -1; // index in co->varnames, -1 if no **kwarg
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{
CallstackContainer* data;

View File

@ -104,7 +104,7 @@ struct Lexer {
const char* curr_char;
int current_line = 1;
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;
bool used = false;

View File

@ -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();
}