Sha256: a71f644d70f0668161f1402165d72418c8ea148e034b9a957ef0130368d18e03

Contents?: true

Size: 802 Bytes

Versions: 5

Compression:

Stored size: 802 Bytes

Contents

require "pp"

unless ARGV[0]
  puts "usage: #$0 /path/to/ruby/trunk/insns.def"
  exit
end

r = %r(
  ^DEFINE_INSN\n
  (?<name>\w+)\n
  \((?<operands>.*)\)\n
  \((?<inputs>.*)\)\n
  \((?<outputs>.*)\)\n
  (?://(?<inc>.*)\n)?
)x

INSN_TABLE = {}
Insn = Struct.new(:operands, :inputs, :outputs)
File.read(ARGV[0]).scan(r) do
  name, operands, _inputs, _outputs, _inc =
    $~[:name], $~[:operands], $~[:inputs], $~[:outputs], $~[:inc]
  next if name.start_with?("opt_")
  next if name == "bitblt" || name == "answer"
  operands = operands.split(",").map {|s| s.strip }.map do |s|
    s.split(" ").map {|s| s.strip }[0]
  end
  INSN_TABLE[name.to_sym] = operands
end
target = File.join(__dir__, "../lib/type-profiler/insns-def.rb")
File.write(target, "TypeProf::INSN_TABLE = " + INSN_TABLE.pretty_inspect)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
typeprof-0.1.4 tools/setup-insns-def.rb
typeprof-0.1.3 tools/setup-insns-def.rb
typeprof-0.1.2 tools/setup-insns-def.rb
typeprof-0.1.1 tools/setup-insns-def.rb
typeprof-0.1.0 tools/setup-insns-def.rb