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

ruby-changes:61709

From: Takashi <ko1@a...>
Date: Sun, 14 Jun 2020 15:48:58 +0900 (JST)
Subject: [ruby-changes:61709] 997133d595 (master): Make __builtin_cexpr! and __builtin_cstmt! work again

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

From 997133d5959d73663988814704b2e390a75ea718 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sat, 13 Jun 2020 23:45:24 -0700
Subject: Make __builtin_cexpr! and __builtin_cstmt! work again

with Ripper.

a3e6f52c17061f012c4e638b3343b57752ed7603 introduced __builtin_cexpr! and
__builtin_cstmt!, but nobody has used them and then they broke on
79292b30884ebcd8be028a7f3c9ccafd7759f2ae by undefined `params`.

This patch fixes the undefined `params`, but still we're not using them
yet.

diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb
index 8f9eb7c..db2224c 100644
--- a/tool/mk_builtin_loader.rb
+++ b/tool/mk_builtin_loader.rb
@@ -49,11 +49,26 @@ def make_cfunc_name inlines, name, lineno https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L49
   end
 end
 
-def collect_builtin base, tree, name, bs, inlines
+def collect_params tree
+  while tree
+    case tree.first
+    when :params
+      idents = (tree[1] || []) + (tree[2] || []).map(&:first)
+      return idents.map { |ident| ident[1].to_sym }
+    when :paren
+      tree = tree[1]
+    else
+      raise "unknown sexp: #{tree.first}"
+    end
+  end
+end
+
+def collect_builtin base, tree, name, bs, inlines, params = nil
   while tree
     call = sep = mid = args = nil
     case tree.first
     when :def
+      params = collect_params(tree[2])
       tree = tree[3]
       next
     when :defs
@@ -126,7 +141,7 @@ def collect_builtin base, tree, name, bs, inlines https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L141
     end
 
     tree.each do |t|
-      collect_builtin base, t, name, bs, inlines if Array === t
+      collect_builtin base, t, name, bs, inlines, params if Array === t
     end
     break
   end
-- 
cgit v0.10.2


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

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