Skip to content

Commit

Permalink
Fix node search in bindgen
Browse files Browse the repository at this point in the history
This is to fix a weird bindgen behavior on Matt's branch:
ruby#7393
  • Loading branch information
k0kubun committed Mar 8, 2023
1 parent cc54e1c commit 309dd50
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tool/rjit/bindgen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,14 @@ def generate(nodes)
end

# TODO: Support nested declarations
nodes_index = nodes.group_by(&:spelling).transform_values(&:last)
nodes_index = nodes.group_by(&:spelling).transform_values do |values|
# Try to search a declaration with definitions
node_with_children = values.find { |v| !v.children.empty? }
next node_with_children if node_with_children

# Otherwise, assume the last one is the main declaration
values.last
end

# Define types
@types.each do |type|
Expand Down

0 comments on commit 309dd50

Please sign in to comment.