diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 04eaeecd..f780d505 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -221,9 +221,6 @@ public: PyObject* new_type_object(PyObject* mod, StrName name, Type base, bool subclass_enabled=true); Type _new_type_object(StrName name, Type base=0, bool subclass_enabled=false); - PyObject* _find_type_object(const Str& type); - - Type _type(const Str& type); PyTypeInfo* _type_info(Type type); const PyTypeInfo* _inst_type_info(PyObject* obj); diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index 1cd9a9f5..c034dc7b 100644 --- a/src/pocketpy.cpp +++ b/src/pocketpy.cpp @@ -347,7 +347,7 @@ void init_builtins(VM* _vm) { _vm->bind__iter__(VM::tp_range, [](VM* vm, PyObject* obj) { return VAR_T(RangeIter, PK_OBJ_GET(Range, obj)); }); // tp_nonetype - _vm->bind__repr__(_vm->_type("NoneType"), [](VM* vm, PyObject* obj) { + _vm->bind__repr__(_vm->_tp(_vm->None), [](VM* vm, PyObject* obj) { return VAR("None"); }); @@ -951,10 +951,10 @@ void init_builtins(VM* _vm) { }); // tp_ellipsis / tp_NotImplementedType - _vm->bind__repr__(_vm->_type("ellipsis"), [](VM* vm, PyObject* self) { + _vm->bind__repr__(_vm->_tp(_vm->Ellipsis), [](VM* vm, PyObject* self) { return VAR("..."); }); - _vm->bind__repr__(_vm->_type("NotImplementedType"), [](VM* vm, PyObject* self) { + _vm->bind__repr__(_vm->_tp(_vm->NotImplemented), [](VM* vm, PyObject* self) { return VAR("NotImplemented"); }); diff --git a/src/vm.cpp b/src/vm.cpp index 4d9732ba..28f12009 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -219,22 +219,6 @@ namespace pkpy{ return PK_OBJ_GET(Type, obj); } - PyObject* VM::_find_type_object(const Str& type){ - PyObject* obj = builtins->attr().try_get_likely_found(type); - if(obj == nullptr){ - for(auto& t: _all_types) if(t.name == type) return t.obj; - throw std::runtime_error(fmt("type not found: ", type).str()); - } - check_non_tagged_type(obj, tp_type); - return obj; - } - - - Type VM::_type(const Str& type){ - PyObject* obj = _find_type_object(type); - return PK_OBJ_GET(Type, obj); - } - PyTypeInfo* VM::_type_info(Type type){ return &_all_types[type]; }