summaryrefslogtreecommitdiff
path: root/gen.rb
diff options
context:
space:
mode:
Diffstat (limited to 'gen.rb')
-rwxr-xr-xgen.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/gen.rb b/gen.rb
index 4b468d5..bc8db44 100755
--- a/gen.rb
+++ b/gen.rb
@@ -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)