diff --git a/3rd/cjson/src/cJSONw.cpp b/3rd/cjson/src/cJSONw.cpp index d8a699ee..f445c513 100644 --- a/3rd/cjson/src/cJSONw.cpp +++ b/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(_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() } diff --git a/3rd/lua_bridge/src/lua_bridge.cpp b/3rd/lua_bridge/src/lua_bridge.cpp index e374b7e0..46c66418 100644 --- a/3rd/lua_bridge/src/lua_bridge.cpp +++ b/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) { diff --git a/include/pocketpy/obj.h b/include/pocketpy/obj.h index 10ed2d69..32a9b6ee 100644 --- a/include/pocketpy/obj.h +++ b/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("") diff --git a/src/gc.cpp b/src/gc.cpp index 1e1699ce..207e1975 100644 --- a/src/gc.cpp +++ b/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(); diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index dc127216..941dbce6 100644 --- a/src/pocketpy.cpp +++ b/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(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(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) { diff --git a/src/vm.cpp b/src/vm.cpp index bdc99a78..a49444ed 100644 --- a/src/vm.cpp +++ b/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; }