From b8100bcce5c3544ba6ed156c427d8b4ef735a10e Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 8 Dec 2023 22:10:18 +0800 Subject: [PATCH] add `EVAL_CONST` --- include/pocketpy/opcodes.h | 2 +- src/ceval.cpp | 5 +++-- src/expr.cpp | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) 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);