diff --git a/include/pocketpy/opcodes.h b/include/pocketpy/opcodes.h index fab9d2d3..b9884935 100644 --- a/include/pocketpy/opcodes.h +++ b/include/pocketpy/opcodes.h @@ -90,7 +90,7 @@ OPCODE(LOOP_CONTINUE) OPCODE(LOOP_BREAK) OPCODE(GOTO) /**************************/ -OPCODE(EVAL) +OPCODE(EVAL_CONST) OPCODE(REPR) OPCODE(CALL) OPCODE(CALL_TP) diff --git a/src/ceval.cpp b/src/ceval.cpp index 939e972f..77e146bf 100644 --- a/src/ceval.cpp +++ b/src/ceval.cpp @@ -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()); diff --git a/src/expr.cpp b/src/expr.cpp index c863fe08..d21c57d6 100644 --- a/src/expr.cpp +++ b/src/expr.cpp @@ -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);