summaryrefslogtreecommitdiff
path: root/tool/rjit/bindgen.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-03-18 21:14:35 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2023-03-18 21:15:22 -0700
commit9f8e914943f812a5036d92648386169079daf51b (patch)
tree777a818d58cd1ebe97b6c675d9365c02da1ed2f9 /tool/rjit/bindgen.rb
parent67dd52d59cde0d2f1ebb3e299b605ed239b59f5b (diff)
downloadruby-9f8e914943f812a5036d92648386169079daf51b.tar.gz
RJIT: Implement checkkeyword
Diffstat (limited to 'tool/rjit/bindgen.rb')
-rwxr-xr-xtool/rjit/bindgen.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/tool/rjit/bindgen.rb b/tool/rjit/bindgen.rb
index bcc4ee954a..ad2e5f9e1e 100755
--- a/tool/rjit/bindgen.rb
+++ b/tool/rjit/bindgen.rb
@@ -156,8 +156,8 @@ class BindingGenerator
println
end
- # TODO: Support nested declarations
- nodes_index = nodes.group_by(&:spelling).transform_values do |values|
+ # Build a hash table for type lookup by name
+ nodes_index = flatten_nodes(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
@@ -169,7 +169,7 @@ class BindingGenerator
# Define types
@types.each do |type|
unless definition = generate_node(nodes_index[type])
- raise "Failed to generate type: #{type}"
+ raise "Failed to find or generate type: #{type}"
end
println " def C.#{type}"
println "@#{type} ||= #{definition}".gsub(/^/, " ").chomp
@@ -201,6 +201,18 @@ class BindingGenerator
private
+ # Make an array that includes all top-level and nested nodes
+ def flatten_nodes(nodes)
+ result = []
+ nodes.each do |node|
+ unless node.children.empty?
+ result.concat(flatten_nodes(node.children))
+ end
+ end
+ result.concat(nodes) # prioritize top-level nodes
+ result
+ end
+
# Return code before BINDGEN_BEG and code after BINDGEN_END
def split_ambles(src_path)
lines = File.read(src_path).lines
@@ -573,6 +585,7 @@ generator = BindingGenerator.new(
rb_shape_t
rb_thread_struct
rb_jit_func_t
+ rb_iseq_param_keyword
rjit_options
],
# #ifdef-dependent immediate types, which need Primitive.cexpr! for type detection