summaryrefslogtreecommitdiff
path: root/ext/coverage/lib/coverage.rb
blob: 7a6ef0e100274b4b92fbfbab10d85bf404319e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
require "coverage.so"

module Coverage
  def self.line_stub(file)
    lines = File.foreach(file).map { nil }
    iseqs = [RubyVM::InstructionSequence.compile_file(file)]
    until iseqs.empty?
      iseq = iseqs.pop
      iseq.trace_points.each {|n, _| lines[n - 1] = 0 }
      iseq.each_child {|child| iseqs << child }
    end
    lines
  end
end