blueloveTH 1 год назад
Родитель
Сommit
9943516d79
2 измененных файлов с 5 добавлено и 8 удалено
  1. 5 3
      include/pocketpy/vm.h
  2. 0 5
      src/vm.cpp

+ 5 - 3
include/pocketpy/vm.h

@@ -356,10 +356,12 @@ public:
     bool issubclass(Type cls, Type base);
     bool issubclass(Type cls, Type base);
     void check_type(PyObject* obj, Type type){ if(!is_type(obj, type)) TypeError(type, _tp(obj)); }
     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)); }
     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; }
     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
 #endif
 
 
 #if PK_REGION("User Type Registration")
 #if PK_REGION("User Type Registration")

+ 0 - 5
src/vm.cpp

@@ -212,11 +212,6 @@ namespace pkpy{
         return obj;
         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){
     bool VM::py_eq(PyObject* lhs, PyObject* rhs){
         if(lhs == rhs) return true;
         if(lhs == rhs) return true;
         const PyTypeInfo* ti = _tp_info(lhs);
         const PyTypeInfo* ti = _tp_info(lhs);