[前][次][番号順一覧][スレッド一覧]

ruby-changes:63392

From: Nobuyoshi <ko1@a...>
Date: Tue, 20 Oct 2020 23:59:03 +0900 (JST)
Subject: [ruby-changes:63392] 081cc4eb28 (master): Dump FrozenCore specially

https://git.ruby-lang.org/ruby.git/commit/?id=081cc4eb28

From 081cc4eb283cb01ddffb364397e5175dbfacab66 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 20 Oct 2020 19:32:10 +0900
Subject: Dump FrozenCore specially


diff --git a/iseq.c b/iseq.c
index 2f10cd6..85ced12 100644
--- a/iseq.c
+++ b/iseq.c
@@ -1861,6 +1861,7 @@ local_var_name(const rb_iseq_t *diseq, VALUE level, VALUE op) https://github.com/ruby/ruby/blob/trunk/iseq.c#L1861
 }
 
 int rb_insn_unified_local_var_level(VALUE);
+VALUE rb_dump_literal(VALUE lit);
 
 VALUE
 rb_insn_operand_intern(const rb_iseq_t *iseq,
@@ -1936,7 +1937,7 @@ rb_insn_operand_intern(const rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/iseq.c#L1937
 		break;
 	    }
 	}
-	ret = rb_inspect(op);
+	ret = rb_dump_literal(op);
 	if (CLASS_OF(op) == rb_cISeq) {
 	    if (child) {
 		rb_ary_push(child, op);
diff --git a/node.c b/node.c
index 9360437..b68d9c1 100644
--- a/node.c
+++ b/node.c
@@ -26,7 +26,7 @@ https://github.com/ruby/ruby/blob/trunk/node.c#L26
 #define A_ID(id) add_id(buf, (id))
 #define A_INT(val) rb_str_catf(buf, "%d", (val))
 #define A_LONG(val) rb_str_catf(buf, "%ld", (val))
-#define A_LIT(lit) AR(rb_inspect(lit))
+#define A_LIT(lit) AR(rb_dump_literal(lit))
 #define A_NODE_HEADER(node, term) \
     rb_str_catf(buf, "@ %s (line: %d, location: (%d,%d)-(%d,%d))%s"term, \
 		ruby_node_name(nd_type(node)), nd_line(node), \
@@ -79,6 +79,25 @@ https://github.com/ruby/ruby/blob/trunk/node.c#L79
 
 #define LAST_NODE (next_indent = "    ")
 
+VALUE
+rb_dump_literal(VALUE lit)
+{
+    if (!RB_SPECIAL_CONST_P(lit)) {
+        VALUE str;
+        switch (RB_BUILTIN_TYPE(lit)) {
+          case T_CLASS: case T_MODULE: case T_ICLASS:
+            str = rb_class_path(lit);
+            if (FL_TEST(lit, FL_SINGLETON)) {
+                str = rb_sprintf("<%"PRIsVALUE">", str);
+            }
+            return str;
+          default:
+            break;
+        }
+    }
+    return rb_inspect(lit);
+}
+
 static void
 add_indent(VALUE buf, VALUE indent)
 {
diff --git a/vm.c b/vm.c
index ada33ae..1f3d97b 100644
--- a/vm.c
+++ b/vm.c
@@ -3123,6 +3123,7 @@ Init_VM(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L3123
 
     /* FrozenCore (hidden) */
     fcore = rb_class_new(rb_cBasicObject);
+    rb_set_class_path(fcore, rb_cRubyVM, "FrozenCore");
     RBASIC(fcore)->flags = T_ICLASS;
     klass = rb_singleton_class(fcore);
     rb_define_method_id(klass, id_core_set_method_alias, m_core_set_method_alias, 3);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]