Leave a comment about the limitation of Primitive

and adjust some code styling from that PR.
This commit is contained in:
Takashi Kokubun 2024-01-23 14:37:22 -08:00
parent 7ac74f5c77
commit 996776e936
2 changed files with 13 additions and 6 deletions

View File

@ -1541,13 +1541,17 @@ module RubyVM::RJIT # :nodoc: all
end end
def C.VALUE def C.VALUE
@VALUE ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(VALUE)"), @VALUE ||= CType::Immediate.find(
Primitive.cexpr!("SIGNED_TYPE_P(VALUE)")) Primitive.cexpr!("SIZEOF(VALUE)"),
Primitive.cexpr!("SIGNED_TYPE_P(VALUE)"),
)
end end
def C.shape_id_t def C.shape_id_t
@shape_id_t ||= CType::Immediate.find(Primitive.cexpr!("SIZEOF(shape_id_t)"), @shape_id_t ||= CType::Immediate.find(
Primitive.cexpr!("SIGNED_TYPE_P(shape_id_t)")) Primitive.cexpr!("SIZEOF(shape_id_t)"),
Primitive.cexpr!("SIGNED_TYPE_P(shape_id_t)"),
)
end end
def C.rb_id_table def C.rb_id_table

View File

@ -182,9 +182,12 @@ class BindingGenerator
unless generate_node(nodes_index[type])&.start_with?('CType::Immediate') unless generate_node(nodes_index[type])&.start_with?('CType::Immediate')
raise "Non-immediate type is given to dynamic_types: #{type}" raise "Non-immediate type is given to dynamic_types: #{type}"
end end
# Only one Primitive.cexpr! is allowed for each line: https://github.com/ruby/ruby/pull/9612
println " def C.#{type}" println " def C.#{type}"
println " @#{type} ||= CType::Immediate.find(Primitive.cexpr!(\"SIZEOF(#{type})\")," println " @#{type} ||= CType::Immediate.find("
println " Primitive.cexpr!(\"SIGNED_TYPE_P(#{type})\"))" println " Primitive.cexpr!(\"SIZEOF(#{type})\"),"
println " Primitive.cexpr!(\"SIGNED_TYPE_P(#{type})\"),"
println " )"
println " end" println " end"
println println
end end