mirror of
https://github.com/pocketpy/pocketpy
synced 2026-02-04 06:30:17 +00:00
fix abs name
This commit is contained in:
parent
45f18f8431
commit
82bd2838ce
@ -16,6 +16,7 @@ OPCODE(LOAD_TRUE)
|
||||
OPCODE(LOAD_FALSE)
|
||||
/**************************/
|
||||
OPCODE(LOAD_SMALL_INT)
|
||||
OPCODE(LOAD_NAME_AS_INT)
|
||||
/**************************/
|
||||
OPCODE(LOAD_ELLIPSIS)
|
||||
OPCODE(LOAD_FUNCTION)
|
||||
|
||||
@ -77,6 +77,7 @@ static int Ctx__enter_block(Ctx* self, CodeBlockType type);
|
||||
static void Ctx__exit_block(Ctx* self);
|
||||
static int Ctx__emit_(Ctx* self, Opcode opcode, uint16_t arg, int line);
|
||||
static int Ctx__emit_int(Ctx* self, int64_t value, int line);
|
||||
static int Ctx__emit_name(Ctx* self, py_Name name, int line);
|
||||
static void Ctx__patch_jump(Ctx* self, int index);
|
||||
static void Ctx__emit_jump(Ctx* self, int target, int line);
|
||||
static int Ctx__add_varname(Ctx* self, py_Name name);
|
||||
@ -1070,7 +1071,7 @@ void CallExpr__emit_(Expr* self_, Ctx* ctx) {
|
||||
|
||||
c11__foreach(Expr*, &self->args, e) { vtemit_(*e, ctx); }
|
||||
c11__foreach(CallExprKwArg, &self->kwargs, e) {
|
||||
Ctx__emit_int(ctx, (uintptr_t)e->key, self->line);
|
||||
Ctx__emit_name(ctx, e->key, self->line);
|
||||
vtemit_(e->val, ctx);
|
||||
}
|
||||
int KWARGC = self->kwargs.length;
|
||||
@ -1196,6 +1197,12 @@ static int Ctx__emit_int(Ctx* self, int64_t value, int line) {
|
||||
}
|
||||
}
|
||||
|
||||
static int Ctx__emit_name(Ctx* self, py_Name name, int line) {
|
||||
int index = Ctx__add_name(self, name);
|
||||
assert(index <= UINT16_MAX);
|
||||
return Ctx__emit_(self, OP_LOAD_NAME_AS_INT, (uint16_t)index, line);
|
||||
}
|
||||
|
||||
static void Ctx__patch_jump(Ctx* self, int index) {
|
||||
Bytecode* co_codes = (Bytecode*)self->co->codes.data;
|
||||
int target = self->co->codes.length;
|
||||
|
||||
@ -189,6 +189,11 @@ __NEXT_STEP:
|
||||
py_newint(SP()++, (int16_t)byte.arg);
|
||||
DISPATCH();
|
||||
}
|
||||
case OP_LOAD_NAME_AS_INT: {
|
||||
py_Name name = co_names[byte.arg];
|
||||
py_newint(SP()++, (uintptr_t)name);
|
||||
DISPATCH();
|
||||
}
|
||||
/*****************************************/
|
||||
case OP_LOAD_ELLIPSIS: {
|
||||
py_newellipsis(SP()++);
|
||||
|
||||
@ -72,7 +72,7 @@ static bool disassemble(CodeObject* co) {
|
||||
pk_sprintf(&ss, " (%q)", py_tosv(path));
|
||||
break;
|
||||
}
|
||||
case OP_LOAD_NAME:
|
||||
case OP_LOAD_NAME: case OP_LOAD_NAME_AS_INT:
|
||||
case OP_LOAD_GLOBAL:
|
||||
case OP_LOAD_NONLOCAL:
|
||||
case OP_STORE_GLOBAL:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user