some move

This commit is contained in:
blueloveTH 2024-06-23 02:14:22 +08:00
parent 8b8552d54b
commit 23d7b56c86
3 changed files with 11 additions and 12 deletions

View File

@ -64,13 +64,13 @@ Error* Compiler::pop_context() noexcept{
}
// pre-compute LOOP_BREAK and LOOP_CONTINUE
for(int i = 0; i < codes.count; i++) {
Bytecode bc = c11__getitem(Bytecode, &codes, i);
if(bc.op == OP_LOOP_CONTINUE) {
CodeBlock* block = c11__at(CodeBlock, &ctx()->co->blocks, bc.arg);
Bytecode__set_signed_arg(&bc, block->start - i);
} else if(bc.op == OP_LOOP_BREAK) {
CodeBlock* block = c11__at(CodeBlock, &ctx()->co->blocks, bc.arg);
Bytecode__set_signed_arg(&bc, (block->end2 != -1 ? block->end2 : block->end) - i);
Bytecode* bc = c11__at(Bytecode, &codes, i);
if(bc->op == OP_LOOP_CONTINUE) {
CodeBlock* block = c11__at(CodeBlock, &ctx()->co->blocks, bc->arg);
Bytecode__set_signed_arg(bc, block->start - i);
} else if(bc->op == OP_LOOP_BREAK) {
CodeBlock* block = c11__at(CodeBlock, &ctx()->co->blocks, bc->arg);
Bytecode__set_signed_arg(bc, (block->end2 != -1 ? block->end2 : block->end) - i);
}
}
// pre-compute func->is_simple

View File

@ -54,8 +54,7 @@ int Frame::_exit_block(ValueStack* _s, int i) {
void Frame::prepare_jump_break(ValueStack* _s, int target) {
int i = c11__at(BytecodeEx, &co->codes_ex, ip())->iblock;
if(target >= co->codes.count) {
while(i >= 0)
i = _exit_block(_s, i);
while(i >= 0) i = _exit_block(_s, i);
} else {
// BUG (solved)
// for i in range(4):

View File

@ -858,7 +858,7 @@ void VM::__log_s_data(const char* title) {
});
Frame* frame = &callstack.top();
int line = frame->curr_lineno();
ss << frame->co->name << ":" << line << " [";
ss << pkpy_Str__data(&frame->co->name) << ":" << line << " [";
for(PyVar* p = s_data.begin(); p != s_data.end(); p++) {
ss << std::string(sp_bases[p], '|');
if(sp_bases[p] > 0) ss << " ";
@ -869,9 +869,9 @@ void VM::__log_s_data(const char* title) {
case tp_none_type: ss << "None"; break;
case tp_int: ss << _CAST(i64, *p); break;
case tp_float: ss << _CAST(f64, *p); break;
case tp_bool: ss << (p->_bool ? "True" : "False"); break;
case tp_bool: ss << (p->extra ? "True" : "False"); break;
case tp_str: ss << _CAST(Str, *p).escape(); break;
case tp_function: ss << p->obj_get<Function>().decl->code->name << "()"; break;
case tp_function: ss << pkpy_Str__data(&p->obj_get<Function>().decl->code->name) << "()"; break;
case tp_type: ss << "<class " + _type_name(this, p->obj_get<Type>()).escape() + ">"; break;
case tp_list: ss << "list(size=" << p->obj_get<List>().size() << ")"; break;
case tp_tuple: ss << "tuple(size=" << p->obj_get<Tuple>().size() << ")"; break;