Module: Optimize::Demo::DisasmNormalizer
- Defined in:
- lib/optimize/demo/disasm_normalizer.rb
Constant Summary collapse
- HEADER_RE =
/\A==\s+disasm:\s+#<ISeq:(?<label>[^>]+)>/- DROPPED_RE =
/\A(?:local table|\(catch table|\|\s|\s*$)/- PC_RE =
/\A\d{4}\s+/- SUFFIX_RE =
/\s*\(\s*\d+\)\[[A-Za-z]+\]\s*\z/
Class Method Summary collapse
Class Method Details
.normalize(raw) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/optimize/demo/disasm_normalizer.rb', line 14 def normalize(raw) out = [] first_header = true raw.each_line do |line| line = line.chomp if (m = line.match(HEADER_RE)) if first_header first_header = false next else out << "== block: #{m[:label]}" next end end next if DROPPED_RE.match?(line) stripped = line.sub(PC_RE, "").sub(SUFFIX_RE, "").rstrip next if stripped.empty? out << stripped end out.join("\n") + "\n" end |