Prettify builtin_binary format

This commit is contained in:
Nobuyoshi Nakada 2019-11-09 00:20:42 +09:00
Родитель cd706c5216
Коммит 88b9a0f7fe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BC7D6DF58D8DF60
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -5,9 +5,10 @@
def dump_bin iseq def dump_bin iseq
bin = iseq.to_binary bin = iseq.to_binary
bin.each_byte.with_index{|b, index| bin.each_byte.with_index{|b, index|
print "\n " if (index%20) == 0 print "\n " if (index%20) == 0
print "0x#{'%02x' % b.ord}, " print " 0x#{'%02x' % b.ord},"
} }
print "\n"
end end
ary = [] ary = []
@ -25,12 +26,12 @@ puts <<H
H H
ary.each{|feature, iseq| ary.each{|feature, iseq|
puts "static const unsigned char #{feature}_bin[] = {" print "\n""static const unsigned char #{feature}_bin[] = {"
dump_bin(iseq) dump_bin(iseq)
puts "};" puts "};"
} }
puts "static const struct builtin_binary builtin_binary[] = {" print "\n""static const struct builtin_binary builtin_binary[] = {\n"
ary.each{|feature, iseq| ary.each{|feature, iseq|
puts " {#{feature.dump}, #{feature}_bin, sizeof(#{feature}_bin)}," puts " {#{feature.dump}, #{feature}_bin, sizeof(#{feature}_bin)},"
} }