mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 13:00:17 +00:00
...
This commit is contained in:
parent
f8490cbf4e
commit
69676d5876
@ -373,7 +373,7 @@ __NEXT_STEP:;
|
|||||||
PUSH(_py_begin_call);
|
PUSH(_py_begin_call);
|
||||||
DISPATCH();
|
DISPATCH();
|
||||||
TARGET(CALL)
|
TARGET(CALL)
|
||||||
_0 = _vectorcall(
|
_0 = vectorcall(
|
||||||
byte.arg & 0xFFFF, // ARGC
|
byte.arg & 0xFFFF, // ARGC
|
||||||
(byte.arg>>16) & 0xFFFF, // KWARGC
|
(byte.arg>>16) & 0xFFFF, // KWARGC
|
||||||
true
|
true
|
||||||
|
14
src/vm.h
14
src/vm.h
@ -219,7 +219,7 @@ public:
|
|||||||
PUSH(_py_null);
|
PUSH(_py_null);
|
||||||
int ARGC = sizeof...(args);
|
int ARGC = sizeof...(args);
|
||||||
_push_varargs(ARGC, args...);
|
_push_varargs(ARGC, args...);
|
||||||
return _vectorcall(ARGC);
|
return vectorcall(ARGC);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
@ -228,7 +228,7 @@ public:
|
|||||||
PUSH(self);
|
PUSH(self);
|
||||||
int ARGC = sizeof...(args);
|
int ARGC = sizeof...(args);
|
||||||
_push_varargs(ARGC, args...);
|
_push_varargs(ARGC, args...);
|
||||||
return _vectorcall(ARGC);
|
return vectorcall(ARGC);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
@ -371,7 +371,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _log_s_data(const char* title = nullptr);
|
void _log_s_data(const char* title = nullptr);
|
||||||
PyObject* _vectorcall(int ARGC, int KWARGC=0, bool op_call=false);
|
PyObject* vectorcall(int ARGC, int KWARGC=0, bool op_call=false);
|
||||||
CodeObject_ compile(Str source, Str filename, CompileMode mode, bool unknown_global_scope=false);
|
CodeObject_ compile(Str source, Str filename, CompileMode mode, bool unknown_global_scope=false);
|
||||||
PyObject* num_negated(PyObject* obj);
|
PyObject* num_negated(PyObject* obj);
|
||||||
f64 num_to_float(PyObject* obj);
|
f64 num_to_float(PyObject* obj);
|
||||||
@ -766,7 +766,7 @@ inline void VM::init_builtin_types(){
|
|||||||
for(auto [k, v]: _modules.items()) v->attr()._try_perfect_rehash();
|
for(auto [k, v]: _modules.items()) v->attr()._try_perfect_rehash();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PyObject* VM::_vectorcall(int ARGC, int KWARGC, bool op_call){
|
inline PyObject* VM::vectorcall(int ARGC, int KWARGC, bool op_call){
|
||||||
bool is_varargs = ARGC == 0xFFFF;
|
bool is_varargs = ARGC == 0xFFFF;
|
||||||
PyObject** p0;
|
PyObject** p0;
|
||||||
PyObject** p1 = s_data._sp - KWARGC*2;
|
PyObject** p1 = s_data._sp - KWARGC*2;
|
||||||
@ -829,7 +829,7 @@ inline PyObject* VM::_vectorcall(int ARGC, int KWARGC, bool op_call){
|
|||||||
PUSH(_py_null);
|
PUSH(_py_null);
|
||||||
for(PyObject* obj: args) PUSH(obj);
|
for(PyObject* obj: args) PUSH(obj);
|
||||||
for(PyObject* obj: kwargs) PUSH(obj);
|
for(PyObject* obj: kwargs) PUSH(obj);
|
||||||
obj = _vectorcall(ARGC, KWARGC);
|
obj = vectorcall(ARGC, KWARGC);
|
||||||
if(!isinstance(obj, OBJ_GET(Type, callable))) return obj;
|
if(!isinstance(obj, OBJ_GET(Type, callable))) return obj;
|
||||||
}else{
|
}else{
|
||||||
obj = heap.gcnew<DummyInstance>(OBJ_GET(Type, callable), {});
|
obj = heap.gcnew<DummyInstance>(OBJ_GET(Type, callable), {});
|
||||||
@ -841,7 +841,7 @@ inline PyObject* VM::_vectorcall(int ARGC, int KWARGC, bool op_call){
|
|||||||
p1[-(ARGC + 2)] = callable;
|
p1[-(ARGC + 2)] = callable;
|
||||||
p1[-(ARGC + 1)] = self;
|
p1[-(ARGC + 1)] = self;
|
||||||
// [init_f, self, args..., kwargs...]
|
// [init_f, self, args..., kwargs...]
|
||||||
_vectorcall(ARGC, KWARGC);
|
vectorcall(ARGC, KWARGC);
|
||||||
// We just discard the return value of `__init__`
|
// We just discard the return value of `__init__`
|
||||||
// in cpython it raises a TypeError if the return value is not None
|
// in cpython it raises a TypeError if the return value is not None
|
||||||
}else{
|
}else{
|
||||||
@ -858,7 +858,7 @@ inline PyObject* VM::_vectorcall(int ARGC, int KWARGC, bool op_call){
|
|||||||
p1[-(ARGC + 2)] = call_f;
|
p1[-(ARGC + 2)] = call_f;
|
||||||
p1[-(ARGC + 1)] = self;
|
p1[-(ARGC + 1)] = self;
|
||||||
// [call_f, self, args..., kwargs...]
|
// [call_f, self, args..., kwargs...]
|
||||||
return _vectorcall(ARGC, KWARGC, false);
|
return vectorcall(ARGC, KWARGC, false);
|
||||||
}
|
}
|
||||||
TypeError(OBJ_NAME(_t(callable)).escape() + " object is not callable");
|
TypeError(OBJ_NAME(_t(callable)).escape() + " object is not callable");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user