add EVAL_CONST

This commit is contained in:
blueloveTH 2023-12-08 22:10:18 +08:00
parent 814bd3e640
commit b8100bcce5
3 changed files with 5 additions and 5 deletions

View File

@ -90,7 +90,7 @@ OPCODE(LOOP_CONTINUE)
OPCODE(LOOP_BREAK)
OPCODE(GOTO)
/**************************/
OPCODE(EVAL)
OPCODE(EVAL_CONST)
OPCODE(REPR)
OPCODE(CALL)
OPCODE(CALL_TP)

View File

@ -568,9 +568,10 @@ __NEXT_STEP:;
frame->jump_abs_break(index);
} DISPATCH();
/*****************************************/
TARGET(EVAL){
TARGET(EVAL_CONST){
PyObject* _0 = builtins->attr(pk_id_eval);
TOP() = call(_0, TOP());
PyObject* _1 = co_consts[byte.arg];
PUSH(call(_0, _1));
} DISPATCH();
TARGET(REPR)
TOP() = py_repr(TOP());

View File

@ -392,8 +392,7 @@ namespace pkpy{
}
}else{
int index = ctx->add_const(py_var(ctx->vm, expr));
ctx->emit_(OP_LOAD_CONST, index, line);
ctx->emit_(OP_EVAL, BC_NOARG, line);
ctx->emit_(OP_EVAL_CONST, index, line);
}
if(repr){
ctx->emit_(OP_REPR, BC_NOARG, line);