diff options
Diffstat (limited to 'gen.rb')
-rwxr-xr-x | gen.rb | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -7,7 +7,17 @@ require 'erb' DATA = YAML.load_file(File.join(__dir__, 'ops.yaml')) switches = Hash.new { |h, k| h[k] = [] } +op_meta = [] DATA['ops'].each do |set_id, ops| + op_meta += ops.map { |op| + '{ "%s", %d }, /* 0x%02x + 0x%s */' % [ + op['id'], + op['len'] || 0, + (set_id == 'main') ? 0 : 255, + op['hex'].to_s(16).upcase.rjust(2, '0'), + ] + } + switches[set_id] = ops.select { |op| op['op'] != 'PREFIX' }.map { |op| @@ -63,5 +73,8 @@ DATA['ops'].each do |set_id, ops| }.join("\n") end +# build complete ops list +ops = op_meta.join("\n") + t = ERB.new(DATA['templates']['main']) puts t.run(binding) |