This commit is contained in:
blueloveTH 2023-04-17 19:53:50 +08:00
parent ff98646064
commit c002999ad8

View File

@ -655,12 +655,22 @@ inline Str VM::disassemble(CodeObject_ co){
} }
inline void VM::_log_s_data(const char* title) { inline void VM::_log_s_data(const char* title) {
if(callstack.empty()) return;
std::stringstream ss; std::stringstream ss;
if(title) ss << title << " | "; if(title) ss << title << " | ";
std::vector<PyObject**> sp_bases;
for(Frame& f: callstack.data()){
sp_bases.push_back(f._sp_base);
}
std::reverse(sp_bases.begin(), sp_bases.end());
FrameId frame = top_frame(); FrameId frame = top_frame();
int line = frame->co->lines[frame->_ip]; int line = frame->co->lines[frame->_ip];
ss << frame->co->name << ":" << line << " ["; ss << frame->co->name << ":" << line << " [";
for(PyObject* obj: s_data){ for(PyObject*& obj: s_data){
if(&obj == sp_bases.back()){
ss << "| ";
sp_bases.pop_back();
}
if(obj == nullptr) ss << "(nil)"; if(obj == nullptr) ss << "(nil)";
else if(obj == _py_begin_call) ss << "BEGIN_CALL"; else if(obj == _py_begin_call) ss << "BEGIN_CALL";
else if(obj == _py_null) ss << "NULL"; else if(obj == _py_null) ss << "NULL";
@ -756,7 +766,6 @@ inline PyObject* VM::_vectorcall(int ARGC, int KWARGC, bool op_call){
PyObject* callable = p1[-(ARGC + 2)]; PyObject* callable = p1[-(ARGC + 2)];
bool method_call = p1[-(ARGC + 1)] != _py_null; bool method_call = p1[-(ARGC + 1)] != _py_null;
ArgsView args(p1 - ARGC - int(method_call), p1);
// handle boundmethod, do a patch // handle boundmethod, do a patch
if(is_non_tagged_type(callable, tp_bound_method)){ if(is_non_tagged_type(callable, tp_bound_method)){
@ -765,9 +774,12 @@ inline PyObject* VM::_vectorcall(int ARGC, int KWARGC, bool op_call){
callable = bm.method; // get unbound method callable = bm.method; // get unbound method
p1[-(ARGC + 2)] = bm.method; p1[-(ARGC + 2)] = bm.method;
p1[-(ARGC + 1)] = bm.obj; p1[-(ARGC + 1)] = bm.obj;
method_call = true;
// [unbound, self, args..., kwargs...] // [unbound, self, args..., kwargs...]
} }
ArgsView args(p1 - ARGC - int(method_call), p1);
if(is_non_tagged_type(callable, tp_native_func)){ if(is_non_tagged_type(callable, tp_native_func)){
const auto& f = OBJ_GET(NativeFunc, callable); const auto& f = OBJ_GET(NativeFunc, callable);
if(KWARGC != 0) TypeError("native_func does not accept keyword arguments"); if(KWARGC != 0) TypeError("native_func does not accept keyword arguments");