some rename

This commit is contained in:
blueloveTH 2024-05-10 16:37:30 +08:00
parent 4ef2e9d156
commit 36b73e1ce7
7 changed files with 22 additions and 22 deletions

View File

@ -65,8 +65,8 @@ struct CodeObject {
std::vector<int> iblocks; // block index for each bytecode
std::vector<LineInfo> lines;
small_vector_no_copy_and_move<PyObject*, 8> consts; // constants
small_vector_no_copy_and_move<StrName, 8> varnames; // local variables
small_vector_2<PyObject*, 8> consts; // constants
small_vector_2<StrName, 8> varnames; // local variables
NameDictInt varnames_inv;
std::vector<CodeBlock> blocks;
@ -100,8 +100,8 @@ struct FuncDecl {
};
CodeObject_ code; // code object of this function
small_vector_no_copy_and_move<int, 6> args; // indices in co->varnames
small_vector_no_copy_and_move<KwArg, 6> kwargs; // indices in co->varnames
small_vector_2<int, 6> args; // indices in co->varnames
small_vector_2<KwArg, 6> 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

View File

@ -100,7 +100,7 @@ struct Lexer {
const char* curr_char;
int current_line = 1;
std::vector<Token> nexts;
stack_no_copy<int, small_vector_no_copy_and_move<int, 8>> indents;
stack_no_copy<int, small_vector_2<int, 8>> indents;
int brackets_level = 0;
char peekchar() const{ return *curr_char; }

View File

@ -112,15 +112,10 @@ struct PyObject{
}
virtual void _obj_gc_mark() = 0;
virtual ~PyObject();
PyObject(Type type) : gc_enabled(true), gc_marked(false), type(type), _attr(nullptr) {}
virtual ~PyObject(){
if(_attr == nullptr) return;
_attr->~NameDict();
pool128_dealloc(_attr);
}
void _enable_instance_dict() {
_attr = new(pool128_alloc<NameDict>()) NameDict();
}

View File

@ -394,16 +394,14 @@ namespace pkpy
}
};
// small_vector_no_copy_and_move
template<typename T, std::size_t N>
class small_vector_no_copy_and_move: public small_vector<T, N>
class small_vector_2: public small_vector<T, N>
{
public:
small_vector_no_copy_and_move() = default;
small_vector_no_copy_and_move(const small_vector_no_copy_and_move& other) = delete;
small_vector_no_copy_and_move& operator=(const small_vector_no_copy_and_move& other) = delete;
small_vector_no_copy_and_move(small_vector_no_copy_and_move&& other) = delete;
small_vector_no_copy_and_move& operator=(small_vector_no_copy_and_move&& other) = delete;
small_vector_2() = default;
small_vector_2(const small_vector_2& other) = delete;
small_vector_2& operator=(const small_vector_2& other) = delete;
small_vector_2(small_vector_2&& other) = delete;
small_vector_2& operator=(small_vector_2&& other) = delete;
};
} // namespace pkpy

View File

@ -704,9 +704,10 @@ __EAT_DOTS_END:
void Compiler::compile_try_except() {
ctx()->enter_block(CodeBlockType::TRY_EXCEPT);
compile_block_body();
pod_vector<int> patches = {
small_vector_2<int, 6> patches;
patches.push_back(
ctx()->emit_(OP_JUMP_ABSOLUTE, BC_NOARG, BC_KEEPLINE)
};
);
ctx()->exit_block();
int finally_entry = -1;

View File

@ -204,7 +204,7 @@ static bool is_unicode_Lo_char(uint32_t c) {
Str Lexer::eat_string_until(char quote, bool raw) {
bool quote3 = match_n_chars(2, quote);
pod_vector<char> buff;
small_vector_2<char, 32> buff;
while (true) {
char c = eatchar_include_newline();
if (c == quote){

View File

@ -47,4 +47,10 @@ namespace pkpy{
return {p, size};
}
PyObject::~PyObject(){
if(_attr == nullptr) return;
_attr->~NameDict();
pool128_dealloc(_attr);
}
} // namespace pkpy