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

ruby-changes:67522

From: Nobuyoshi <ko1@a...>
Date: Wed, 1 Sep 2021 16:17:23 +0900 (JST)
Subject: [ruby-changes:67522] d58143f3b5 (master): Extract compile_colon3 from iseq_compile_each0

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

From d58143f3b501bdb0859435bee7589936aa1fef82 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 12 Mar 2017 23:55:27 +0900
Subject: Extract compile_colon3 from iseq_compile_each0

---
 compile.c | 57 ++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/compile.c b/compile.c
index 30ccb9f..bd2af90 100644
--- a/compile.c
+++ b/compile.c
@@ -8746,6 +8746,36 @@ compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, https://github.com/ruby/ruby/blob/trunk/compile.c#L8746
     return COMPILE_OK;
 }
 
+static int
+compile_colon3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
+{
+    const int line = nd_line(node);
+    LABEL *lend = NEW_LABEL(line);
+    int ic_index = iseq->body->is_size++;
+
+    debugi("colon3#nd_mid", node->nd_mid);
+
+    /* add cache insn */
+    if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
+	ADD_INSN2(ret, node, opt_getinlinecache, lend, INT2FIX(ic_index));
+	ADD_INSN(ret, node, pop);
+    }
+
+    ADD_INSN1(ret, node, putobject, rb_cObject);
+    ADD_INSN1(ret, node, putobject, Qtrue);
+    ADD_INSN1(ret, node, getconstant, ID2SYM(node->nd_mid));
+
+    if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
+	ADD_INSN1(ret, node, opt_setinlinecache, INT2FIX(ic_index));
+	ADD_LABEL(ret, lend);
+    }
+
+    if (popped) {
+	ADD_INSN(ret, node, pop);
+    }
+    return COMPILE_OK;
+}
+
 static int iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped);
 /**
   compile each node
@@ -9354,32 +9384,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no https://github.com/ruby/ruby/blob/trunk/compile.c#L9384
       case NODE_COLON2:
 	CHECK(compile_colon2(iseq, ret, node, popped));
 	break;
-      case NODE_COLON3:{
-	LABEL *lend = NEW_LABEL(line);
-	int ic_index = body->is_size++;
-
-	debugi("colon3#nd_mid", node->nd_mid);
-
-	/* add cache insn */
-	if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
-            ADD_INSN2(ret, node, opt_getinlinecache, lend, INT2FIX(ic_index));
-	    ADD_INSN(ret, node, pop);
-	}
-
-	ADD_INSN1(ret, node, putobject, rb_cObject);
-        ADD_INSN1(ret, node, putobject, Qtrue);
-        ADD_INSN1(ret, node, getconstant, ID2SYM(node->nd_mid));
-
-	if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
-            ADD_INSN1(ret, node, opt_setinlinecache, INT2FIX(ic_index));
-	    ADD_LABEL(ret, lend);
-	}
-
-	if (popped) {
-	    ADD_INSN(ret, node, pop);
-	}
+      case NODE_COLON3:
+	CHECK(compile_colon3(iseq, ret, node, popped));
 	break;
-      }
       case NODE_DOT2:
       case NODE_DOT3:{
 	int excl = type == NODE_DOT3;
-- 
cgit v1.1


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

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