mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some move
This commit is contained in:
parent
8b8552d54b
commit
23d7b56c86
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user