فهرست منبع

rename to `_type_name`

blueloveTH 2 سال پیش
والد
کامیت
123c8a6a92
6فایلهای تغییر یافته به همراه12 افزوده شده و 12 حذف شده
  1. 1 1
      3rd/cjson/src/cJSONw.cpp
  2. 1 1
      3rd/lua_bridge/src/lua_bridge.cpp
  3. 1 1
      include/pocketpy/obj.h
  4. 1 1
      src/gc.cpp
  5. 4 4
      src/pocketpy.cpp
  6. 4 4
      src/vm.cpp

+ 1 - 1
3rd/cjson/src/cJSONw.cpp

@@ -36,7 +36,7 @@ static cJSON* convert_python_object_to_cjson(PyObject* obj, VM* vm){
         case VM::tp_tuple.index: return convert_list_to_cjson<Tuple>(_CAST(Tuple&, obj), vm);
         default: break;
     }
-    vm->TypeError(fmt("unrecognized type ", obj_type_name(vm, obj_t).escape()));
+    vm->TypeError(fmt("unrecognized type ", _type_name(vm, obj_t).escape()));
     PK_UNREACHABLE()
 }
 

+ 1 - 1
3rd/lua_bridge/src/lua_bridge.cpp

@@ -280,7 +280,7 @@ void lua_push_from_python(VM* vm, PyObject* val){
         lua_rawgeti(_L, LUA_REGISTRYINDEX, func.r);
         return;
     }
-    vm->RuntimeError(fmt("unsupported python type: ", obj_type_name(vm, t).escape()));
+    vm->RuntimeError(fmt("unsupported python type: ", _type_name(vm, t).escape()));
 }
 
 PyObject* lua_popx_to_python(VM* vm) {

+ 1 - 1
include/pocketpy/obj.h

@@ -207,7 +207,7 @@ inline void gc_mark_namedict(NameDict& t){
     });
 }
 
-StrName obj_type_name(VM* vm, Type type);
+StrName _type_name(VM* vm, Type type);
 
 #if PK_DEBUG_NO_BUILTINS
 #define OBJ_NAME(obj) Str("<?>")

+ 1 - 1
src/gc.cpp

@@ -25,7 +25,7 @@ namespace pkpy{
 
 #if PK_DEBUG_GC_STATS
         for(auto& [type, count]: deleted){
-            std::cout << "GC: " << obj_type_name(vm, type).sv() << "=" << count << std::endl;
+            std::cout << "GC: " << _type_name(vm, type).sv() << "=" << count << std::endl;
         }
         std::cout << "GC: " << alive.size() << "/" << gen.size() << " (" << freed << " freed)" << std::endl;
         deleted.clear();

+ 4 - 4
src/pocketpy.cpp

@@ -70,8 +70,8 @@ void init_builtins(VM* _vm) {
         vm->check_non_tagged_type(class_arg, vm->tp_type);
         Type type = PK_OBJ_GET(Type, class_arg);
         if(!vm->isinstance(self_arg, type)){
-            StrName _0 = obj_type_name(vm, vm->_tp(self_arg));
-            StrName _1 = obj_type_name(vm, type);
+            StrName _0 = _type_name(vm, vm->_tp(self_arg));
+            StrName _1 = _type_name(vm, type);
             vm->TypeError("super(): " + _0.escape() + " is not an instance of " + _1.escape());
         }
         return vm->heap.gcnew<Super>(vm->tp_super, self_arg, vm->_all_types[type].base);
@@ -1304,7 +1304,7 @@ void init_builtins(VM* _vm) {
     // tp_exception
     _vm->bind_constructor<-1>(_vm->_t(VM::tp_exception), [](VM* vm, ArgsView args){
         Type cls = PK_OBJ_GET(Type, args[0]);
-        StrName cls_name = obj_type_name(vm, cls);
+        StrName cls_name = _type_name(vm, cls);
         PyObject* e_obj = vm->heap.gcnew<Exception>(cls, cls_name);
         e_obj->_enable_instance_dict();
         PK_OBJ_GET(Exception, e_obj)._self = e_obj;
@@ -1323,7 +1323,7 @@ void init_builtins(VM* _vm) {
 
     _vm->bind__repr__(VM::tp_exception, [](VM* vm, PyObject* obj) {
         Exception& self = _CAST(Exception&, obj);
-        return VAR(fmt(obj_type_name(vm, obj->type), '(', self.msg.escape(), ')'));
+        return VAR(fmt(_type_name(vm, obj->type), '(', self.msg.escape(), ')'));
     });
 
     _vm->bind__str__(VM::tp_exception, [](VM* vm, PyObject* obj) {

+ 4 - 4
src/vm.cpp

@@ -27,7 +27,7 @@ namespace pkpy{
                 if(!first) ss << ", ";
                 first = false;
                 if(!is_non_tagged_type(k, vm->tp_str)){
-                    vm->TypeError(fmt("json keys must be string, got ", obj_type_name(vm, vm->_tp(k))));
+                    vm->TypeError(fmt("json keys must be string, got ", _type_name(vm, vm->_tp(k))));
                 }
                 ss << _CAST(Str&, k).escape(false) << ": ";
                 write_object(v);
@@ -56,7 +56,7 @@ namespace pkpy{
             }else if(obj_t == vm->tp_dict){
                 write_dict(_CAST(Dict&, obj));
             }else{
-                vm->TypeError(fmt("unrecognized type ", obj_type_name(vm, obj_t).escape()));
+                vm->TypeError(fmt("unrecognized type ", _type_name(vm, obj_t).escape()));
             }
         }
 
@@ -667,7 +667,7 @@ void VM::_log_s_data(const char* title) {
         } else if(is_type(obj, tp_tuple)){
             auto& t = CAST(Tuple&, obj);
             ss << "tuple(size=" << t.size() << ")";
-        } else ss << "(" << obj_type_name(this, obj->type) << ")";
+        } else ss << "(" << _type_name(this, obj->type) << ")";
         ss << ", ";
     }
     std::string output = ss.str();
@@ -1252,7 +1252,7 @@ void ManagedHeap::mark() {
     if(_gc_marker_ex) _gc_marker_ex(vm);
 }
 
-StrName obj_type_name(VM *vm, Type type){
+StrName _type_name(VM *vm, Type type){
     return vm->_all_types[type].name;
 }