2019-11-07 02:58:00 -05:00
|
|
|
#
|
|
|
|
# make builtin_binary.inc file.
|
|
|
|
#
|
|
|
|
|
|
|
|
def dump_bin iseq
|
|
|
|
bin = iseq.to_binary
|
|
|
|
bin.each_byte.with_index{|b, index|
|
2019-11-08 10:20:42 -05:00
|
|
|
print "\n " if (index%20) == 0
|
|
|
|
print " 0x#{'%02x' % b.ord},"
|
2019-11-07 02:58:00 -05:00
|
|
|
}
|
2019-11-08 10:20:42 -05:00
|
|
|
print "\n"
|
2019-11-07 02:58:00 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
$stdout = open('builtin_binary.inc', 'wb')
|
|
|
|
|
2019-11-08 02:37:42 -05:00
|
|
|
puts <<H
|
|
|
|
// -*- c -*-
|
|
|
|
// DO NOT MODIFY THIS FILE DIRECTLY.
|
|
|
|
// auto-generated file by #{File.basename(__FILE__)}
|
|
|
|
|
|
|
|
H
|
|
|
|
|
2019-12-10 21:22:27 -05:00
|
|
|
if ARGV.include?('--cross=yes')
|
2019-12-10 03:39:04 -05:00
|
|
|
# do nothing
|
|
|
|
else
|
|
|
|
ary = []
|
|
|
|
RubyVM::each_builtin{|feature, iseq|
|
|
|
|
ary << [feature, iseq]
|
|
|
|
}
|
2019-11-07 02:58:00 -05:00
|
|
|
|
2019-12-10 03:39:04 -05:00
|
|
|
ary.each{|feature, iseq|
|
|
|
|
print "\n""static const unsigned char #{feature}_bin[] = {"
|
|
|
|
dump_bin(iseq)
|
|
|
|
puts "};"
|
|
|
|
}
|
2019-11-07 02:58:00 -05:00
|
|
|
|
2019-12-10 03:39:04 -05:00
|
|
|
print "\n""static const struct builtin_binary builtin_binary[] = {\n"
|
|
|
|
ary.each{|feature, iseq|
|
|
|
|
puts " {#{feature.dump}, #{feature}_bin, sizeof(#{feature}_bin)},"
|
|
|
|
}
|
|
|
|
puts " {NULL}," # dummy sentry
|
|
|
|
puts "};"
|
|
|
|
puts "#define BUILTIN_BINARY_SIZE #{ary.size}"
|
|
|
|
end
|