This commit is contained in:
blueloveTH 2024-03-16 18:22:10 +08:00
parent c821a08f91
commit a99b5ee381
2 changed files with 7 additions and 2 deletions

View File

@ -594,7 +594,12 @@ namespace pkpy{
// vectorcall protocol // vectorcall protocol
for(auto& item: args) item->emit_(ctx); for(auto& item: args) item->emit_(ctx);
for(auto& item: kwargs){ 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); ctx->emit_(OP_LOAD_INTEGER, index, line);
item.second->emit_(ctx); item.second->emit_(ctx);
} }

View File

@ -837,7 +837,7 @@ void VM::_prepare_py_call(PyObject** buffer, ArgsView args, ArgsView kwargs, con
} }
for(int j=0; j<kwargs.size(); j+=2){ for(int j=0; j<kwargs.size(); j+=2){
StrName key(_CAST(int, kwargs[j])); StrName key(_CAST(uint16_t, kwargs[j]));
int index = decl->kw_to_index.try_get_likely_found(key); int index = decl->kw_to_index.try_get_likely_found(key);
// if key is an explicit key, set as local variable // if key is an explicit key, set as local variable
if(index >= 0){ if(index >= 0){