From a99b5ee3819805c208dfc80ec2a67c71dcad5ea4 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 16 Mar 2024 18:22:10 +0800 Subject: [PATCH] some fix --- src/expr.cpp | 7 ++++++- src/vm.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/expr.cpp b/src/expr.cpp index 791e3a8c..ebd88d4a 100644 --- a/src/expr.cpp +++ b/src/expr.cpp @@ -594,7 +594,12 @@ namespace pkpy{ // vectorcall protocol for(auto& item: args) item->emit_(ctx); for(auto& item: kwargs){ - uint16_t index = StrName(item.first.sv()).index; + i64 _val = StrName(item.first.sv()).index; + if(is_imm_int(_val)){ + ctx->emit_(OP_LOAD_INTEGER, (uint16_t)_val, line); + }else{ + ctx->emit_(OP_LOAD_CONST, ctx->add_const(py_var(ctx->vm, _val)), line); + } ctx->emit_(OP_LOAD_INTEGER, index, line); item.second->emit_(ctx); } diff --git a/src/vm.cpp b/src/vm.cpp index ad50a961..a9605ffb 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -837,7 +837,7 @@ void VM::_prepare_py_call(PyObject** buffer, ArgsView args, ArgsView kwargs, con } for(int j=0; jkw_to_index.try_get_likely_found(key); // if key is an explicit key, set as local variable if(index >= 0){