This commit is contained in:
blueloveTH 2024-08-05 17:16:58 +08:00
parent 4e8920b280
commit 9fbaca3b13
3 changed files with 4 additions and 8 deletions

View File

@ -339,11 +339,6 @@ bool py_isidentical(py_Ref, py_Ref);
/// The result will be set to `py_retval()`. /// The result will be set to `py_retval()`.
/// The stack remains unchanged after the operation. /// The stack remains unchanged after the operation.
bool py_call(py_Ref f, int argc, py_Ref argv) PY_RAISE; bool py_call(py_Ref f, int argc, py_Ref argv) PY_RAISE;
/// Call a non-magic method.
/// It prepares the stack and then performs a `vectorcall(argc+1, 0, false)`.
/// The result will be set to `py_retval()`.
/// The stack remains unchanged after the operation.
bool py_callmethod(py_Ref self, py_Name name, int argc, py_Ref argv) PY_RAISE;
bool py_str(py_Ref val) PY_RAISE; bool py_str(py_Ref val) PY_RAISE;
bool py_repr(py_Ref val) PY_RAISE; bool py_repr(py_Ref val) PY_RAISE;

View File

@ -476,7 +476,10 @@ FrameResult VM__run_top_frame(VM* self) {
py_push(py_retval()); // empty set py_push(py_retval()); // empty set
py_Name id_add = py_name("add"); py_Name id_add = py_name("add");
for(int i = 0; i < byte.arg; i++) { for(int i = 0; i < byte.arg; i++) {
if(!py_callmethod(TOP(), id_add, 1, begin + i)) goto __ERROR; py_push(TOP());
py_pushmethod(id_add);
py_push(begin + i);
if(!py_vectorcall(1, 0)) goto __ERROR;
} }
py_TValue tmp = *TOP(); py_TValue tmp = *TOP();
SP() = begin; SP() = begin;

View File

@ -115,8 +115,6 @@ bool py_call(py_Ref f, int argc, py_Ref argv) {
} }
} }
bool py_callmethod(py_Ref self, py_Name name, int argc, py_Ref argv) { return -1; }
bool py_vectorcall(uint16_t argc, uint16_t kwargc) { bool py_vectorcall(uint16_t argc, uint16_t kwargc) {
VM* vm = pk_current_vm; VM* vm = pk_current_vm;
return VM__vectorcall(vm, argc, kwargc, false) != RES_ERROR; return VM__vectorcall(vm, argc, kwargc, false) != RES_ERROR;