From 3a888398a661d7dc3cbcc21b8983809905b07adb Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 21 Jan 2021 09:45:11 +0100 Subject: objspace_dump.c: tag singleton classes and reference the superclass --- ext/objspace/objspace_dump.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'ext/objspace/objspace_dump.c') diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 544d11e254..c3619a9656 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -419,14 +419,37 @@ dump_object(VALUE obj, struct dump_config *dc) dump_append(dc, ", \"embedded\":true"); break; + case T_ICLASS: + if (rb_class_get_superclass(obj)) { + dump_append(dc, ", \"superclass\":"); + dump_append_ref(dc, rb_class_get_superclass(obj)); + } + break; + case T_CLASS: case T_MODULE: + if (rb_class_get_superclass(obj)) { + dump_append(dc, ", \"superclass\":"); + dump_append_ref(dc, rb_class_get_superclass(obj)); + } + if (dc->cur_obj_klass) { VALUE mod_name = rb_mod_name(obj); if (!NIL_P(mod_name)) { dump_append(dc, ", \"name\":\""); dump_append(dc, RSTRING_PTR(mod_name)); dump_append(dc, "\""); + } else { + VALUE real_mod_name = rb_mod_name(rb_class_real(obj)); + if (RTEST(real_mod_name)) { + dump_append(dc, ", \"real_class_name\":\""); + dump_append(dc, RSTRING_PTR(real_mod_name)); + dump_append(dc, "\""); + } + } + + if (FL_TEST(obj, FL_SINGLETON)) { + dump_append(dc, ", \"singleton\":true"); } } break; -- cgit v1.2.3