From 9943516d79f16d2fd6d1da441ed131ce9f7bfb00 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 5 May 2024 10:55:51 +0800 Subject: [PATCH] some fix --- include/pocketpy/vm.h | 8 +++++--- src/vm.cpp | 5 ----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 2395bd0a..bb291a1b 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -356,10 +356,12 @@ public: bool issubclass(Type cls, Type base); void check_type(PyObject* obj, Type type){ if(!is_type(obj, type)) TypeError(type, _tp(obj)); } void check_compatible_type(PyObject* obj, Type type){ if(!isinstance(obj, type)) TypeError(type, _tp(obj)); } - PyObject* _t(PyObject* obj){ return _all_types[_tp(obj)].obj; } - PyObject* _t(Type t){ return _all_types[t.index].obj; } + Type _tp(PyObject* obj){ return is_small_int(obj) ? tp_int : obj->type; } - const PyTypeInfo* _tp_info(PyObject* obj); + const PyTypeInfo* _tp_info(PyObject* obj) { return &_all_types[_tp(obj)]; } + const PyTypeInfo* _tp_info(Type type) { return &_all_types[type]; } + PyObject* _t(PyObject* obj){ return _all_types[_tp(obj)].obj; } + PyObject* _t(Type type){ return _all_types[type].obj; } #endif #if PK_REGION("User Type Registration") diff --git a/src/vm.cpp b/src/vm.cpp index 87420749..7c9054a0 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -212,11 +212,6 @@ namespace pkpy{ return obj; } - const PyTypeInfo* VM::_tp_info(PyObject* obj){ - if(is_small_int(obj)) return &_all_types[tp_int]; - return &_all_types[obj->type]; - } - bool VM::py_eq(PyObject* lhs, PyObject* rhs){ if(lhs == rhs) return true; const PyTypeInfo* ti = _tp_info(lhs);