This commit is contained in:
blueloveTH 2023-06-10 12:33:12 +08:00
parent a484879b14
commit d0453ab15f
2 changed files with 40 additions and 25 deletions

View File

@ -470,7 +470,8 @@ __NEXT_STEP:;
PUSH(_0); PUSH(_0);
DISPATCH(); DISPATCH();
TARGET(CALL_TP) TARGET(CALL_TP)
// [callable, <self>, args: tuple, kwargs: dict] // [callable, <self>, args: tuple, kwargs: dict | NULL]
if(byte.arg){
_2 = POPX(); _2 = POPX();
_1 = POPX(); _1 = POPX();
for(PyObject* obj: _CAST(Tuple&, _1)) PUSH(obj); for(PyObject* obj: _CAST(Tuple&, _1)) PUSH(obj);
@ -483,6 +484,16 @@ __NEXT_STEP:;
_CAST(Dict&, _2).size(), // KWARGC _CAST(Dict&, _2).size(), // KWARGC
true true
); );
}else{
// no **kwargs
_1 = POPX();
for(PyObject* obj: _CAST(Tuple&, _1)) PUSH(obj);
_0 = vectorcall(
_CAST(Tuple&, _1).size(), // ARGC
0, // KWARGC
true
);
}
if(_0 == PY_OP_CALL) DISPATCH_OP_CALL(); if(_0 == PY_OP_CALL) DISPATCH_OP_CALL();
PUSH(_0); PUSH(_0);
DISPATCH(); DISPATCH();

View File

@ -686,6 +686,7 @@ struct CallExpr: Expr{
for(auto& item: args) item->emit(ctx); for(auto& item: args) item->emit(ctx);
ctx->emit(OP_BUILD_TUPLE_UNPACK, (int)args.size(), line); ctx->emit(OP_BUILD_TUPLE_UNPACK, (int)args.size(), line);
if(!kwargs.empty()){
for(auto& item: kwargs){ for(auto& item: kwargs){
if(item.second->is_starred()){ if(item.second->is_starred()){
if(item.second->star_level() != 2) FATAL_ERROR(); if(item.second->star_level() != 2) FATAL_ERROR();
@ -699,7 +700,10 @@ struct CallExpr: Expr{
} }
} }
ctx->emit(OP_BUILD_DICT_UNPACK, (int)kwargs.size(), line); ctx->emit(OP_BUILD_DICT_UNPACK, (int)kwargs.size(), line);
ctx->emit(OP_CALL_TP, BC_NOARG, line); ctx->emit(OP_CALL_TP, 1, line);
}else{
ctx->emit(OP_CALL_TP, 0, line);
}
}else{ }else{
// vectorcall protocal // vectorcall protocal
for(auto& item: args) item->emit(ctx); for(auto& item: args) item->emit(ctx);