Class: Rubinius::Debugger::Frame

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(debugger, number, loc) ⇒ Frame

Returns a new instance of Frame.



3
4
5
6
7
# File 'lib/rubinius/debugger/frame.rb', line 3

def initialize(debugger, number, loc)
  @debugger = debugger
  @number = number
  @location = loc
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



9
10
11
# File 'lib/rubinius/debugger/frame.rb', line 9

def location
  @location
end

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/rubinius/debugger/frame.rb', line 9

def number
  @number
end

Instance Method Details

#bindingObject



15
16
17
18
19
20
# File 'lib/rubinius/debugger/frame.rb', line 15

def binding
  @binding ||= Binding.setup(
                 @location.variables,
                 @location.method,
                 @location.constant_scope)
end

#describeObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/rubinius/debugger/frame.rb', line 42

def describe
  if method.required_args > 0
    locals = []
    0.upto(method.required_args-1) do |arg|
      locals << method.local_names[arg].to_s
    end

    arg_str = locals.join(", ")
  else
    arg_str = ""
  end

  loc = @location

  if loc.is_block
    if arg_str.empty?
      recv = "{ } in #{loc.describe_receiver}#{loc.name}"
    else
      recv = "{|#{arg_str}| } in #{loc.describe_receiver}#{loc.name}"
    end
  else
    if arg_str.empty?
      recv = loc.describe
    else
      recv = "#{loc.describe}(#{arg_str})"
    end
  end

  str = "#{recv} at #{loc.method.active_path}:#{loc.line} (#{loc.ip})"
  if @debugger.variables[:show_ip]
    str << " (+#{loc.ip})"
  end

  str
end

#ipObject



30
31
32
# File 'lib/rubinius/debugger/frame.rb', line 30

def ip
  @location.ip
end

#lineObject



26
27
28
# File 'lib/rubinius/debugger/frame.rb', line 26

def line
  @location.line
end

#local_variablesObject



38
39
40
# File 'lib/rubinius/debugger/frame.rb', line 38

def local_variables
  method.local_names
end

#methodObject



22
23
24
# File 'lib/rubinius/debugger/frame.rb', line 22

def method
  @location.method
end

#run(code) ⇒ Object



11
12
13
# File 'lib/rubinius/debugger/frame.rb', line 11

def run(code)
  eval(code, binding)
end

#variablesObject



34
35
36
# File 'lib/rubinius/debugger/frame.rb', line 34

def variables
  @location.variables
end