diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2020-06-13 23:45:24 -0700 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2020-06-13 23:48:34 -0700 |
commit | 997133d5959d73663988814704b2e390a75ea718 (patch) | |
tree | 9f43712b89785f32155556969ce4d38b922671c3 /tool/mk_builtin_loader.rb | |
parent | 454e8120dbd4216f6da641e0b4d996710ad2ebc6 (diff) |
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.
Diffstat (limited to 'tool/mk_builtin_loader.rb')
-rw-r--r-- | tool/mk_builtin_loader.rb | 19 |
1 files changed, 17 insertions, 2 deletions
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 |