blueloveTH hace 2 años
padre
commit
3362c23e53
Se han modificado 3 ficheros con 3 adiciones y 22 borrados
  1. 0 3
      include/pocketpy/vm.h
  2. 3 3
      src/pocketpy.cpp
  3. 0 16
      src/vm.cpp

+ 0 - 3
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);
 

+ 3 - 3
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");
     });
 

+ 0 - 16
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];
     }