From 997133d5959d73663988814704b2e390a75ea718 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun 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. --- tool/mk_builtin_loader.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tool/mk_builtin_loader.rb') diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb index 8f9eb7c886..db2224c1de 100644 --- a/tool/mk_builtin_loader.rb +++ b/tool/mk_builtin_loader.rb @@ -49,11 +49,26 @@ def make_cfunc_name inlines, name, lineno 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 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 v1.2.1