Class: Rubinius::Coverage::CFG::BasicBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/rubinius/coverage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(enter_ip) ⇒ BasicBlock

Returns a new instance of BasicBlock.



110
111
112
113
114
# File 'lib/rubinius/coverage.rb', line 110

def initialize(enter_ip)
  @enter_ip = @exit_ip = enter_ip
  @lines = []
  @count = 0
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



108
109
110
# File 'lib/rubinius/coverage.rb', line 108

def count
  @count
end

#enter_ipObject

Returns the value of attribute enter_ip.



108
109
110
# File 'lib/rubinius/coverage.rb', line 108

def enter_ip
  @enter_ip
end

#exit_ipObject

Returns the value of attribute exit_ip.



108
109
110
# File 'lib/rubinius/coverage.rb', line 108

def exit_ip
  @exit_ip
end

#leftObject

Returns the value of attribute left.



108
109
110
# File 'lib/rubinius/coverage.rb', line 108

def left
  @left
end

#linesObject

Returns the value of attribute lines.



108
109
110
# File 'lib/rubinius/coverage.rb', line 108

def lines
  @lines
end

#rightObject

Returns the value of attribute right.



108
109
110
# File 'lib/rubinius/coverage.rb', line 108

def right
  @right
end

Instance Method Details

#coverage(code, call_sites) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/rubinius/coverage.rb', line 116

def coverage(code, call_sites)
  total = code.lines.size - 2
  i = 0

  while i < total
    if (@enter_ip < code.lines[i+2] and @exit_ip >= code.lines[i]) or
       (code.lines[i+2] == 0 and @enter_ip == 0)
      line = code.lines[i+1]
      @lines << line unless @lines.include? line
    end

    i += 2
  end

  call_sites.each do |cs|
    if cs.ip >= @enter_ip and cs.ip <= @exit_ip
      cs_count = cs.invokes + cs.hits + cs.misses
      @count = cs_count if cs_count > @count
    end
  end
end