Class: Readapt::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/readapt/frame.rb,
ext/readapt/frame.c

Constant Summary collapse

NULL_FRAME =
Frame.new("", 0, nil)

Instance Method Summary collapse

Constructor Details

#initialize(file, line, binding) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/readapt/frame.rb', line 11

class Frame
  def evaluate code
    frame_binding.eval(code).inspect
  rescue StandardError => e
    "[#{e.class}] #{e.message}"
  end

  def local_id
    frame_binding.object_id
  end

  def locals
    return [] if frame_binding.nil?
    result = []
    frame_binding.local_variables.sort.each do |sym|
      var = frame_binding.local_variable_get(sym)
      result.push Variable.new(sym, var)
    end
    result.push Variable.new(:self, frame_binding.receiver)
    result
  end

  def local sym
    return frame_binding.receiver if sym == :self
    frame_binding.local_variable_get sym
  end

  NULL_FRAME = Frame.new("", 0, nil)
end

Instance Method Details

#binding_idInteger

Returns:

  • (Integer)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/readapt/frame.rb', line 11

class Frame
  def evaluate code
    frame_binding.eval(code).inspect
  rescue StandardError => e
    "[#{e.class}] #{e.message}"
  end

  def local_id
    frame_binding.object_id
  end

  def locals
    return [] if frame_binding.nil?
    result = []
    frame_binding.local_variables.sort.each do |sym|
      var = frame_binding.local_variable_get(sym)
      result.push Variable.new(sym, var)
    end
    result.push Variable.new(:self, frame_binding.receiver)
    result
  end

  def local sym
    return frame_binding.receiver if sym == :self
    frame_binding.local_variable_get sym
  end

  NULL_FRAME = Frame.new("", 0, nil)
end

#evaluate(code) ⇒ Object



12
13
14
15
16
# File 'lib/readapt/frame.rb', line 12

def evaluate code
  frame_binding.eval(code).inspect
rescue StandardError => e
  "[#{e.class}] #{e.message}"
end

#fileString

Returns:

  • (String)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/readapt/frame.rb', line 11

class Frame
  def evaluate code
    frame_binding.eval(code).inspect
  rescue StandardError => e
    "[#{e.class}] #{e.message}"
  end

  def local_id
    frame_binding.object_id
  end

  def locals
    return [] if frame_binding.nil?
    result = []
    frame_binding.local_variables.sort.each do |sym|
      var = frame_binding.local_variable_get(sym)
      result.push Variable.new(sym, var)
    end
    result.push Variable.new(:self, frame_binding.receiver)
    result
  end

  def local sym
    return frame_binding.receiver if sym == :self
    frame_binding.local_variable_get sym
  end

  NULL_FRAME = Frame.new("", 0, nil)
end

#frame_bindingObject



122
123
124
125
126
127
# File 'ext/readapt/frame.c', line 122

VALUE frame_binding_m(VALUE self)
{
    frame_t *data;
    TypedData_Get_Struct(self, frame_t, &frame_type, data);
    return data->binding;
}

#lineInteger

Returns:

  • (Integer)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/readapt/frame.rb', line 11

class Frame
  def evaluate code
    frame_binding.eval(code).inspect
  rescue StandardError => e
    "[#{e.class}] #{e.message}"
  end

  def local_id
    frame_binding.object_id
  end

  def locals
    return [] if frame_binding.nil?
    result = []
    frame_binding.local_variables.sort.each do |sym|
      var = frame_binding.local_variable_get(sym)
      result.push Variable.new(sym, var)
    end
    result.push Variable.new(:self, frame_binding.receiver)
    result
  end

  def local sym
    return frame_binding.receiver if sym == :self
    frame_binding.local_variable_get sym
  end

  NULL_FRAME = Frame.new("", 0, nil)
end

#local(sym) ⇒ Object



33
34
35
36
# File 'lib/readapt/frame.rb', line 33

def local sym
  return frame_binding.receiver if sym == :self
  frame_binding.local_variable_get sym
end

#local_idObject



18
19
20
# File 'lib/readapt/frame.rb', line 18

def local_id
  frame_binding.object_id
end

#localsObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/readapt/frame.rb', line 22

def locals
  return [] if frame_binding.nil?
  result = []
  frame_binding.local_variables.sort.each do |sym|
    var = frame_binding.local_variable_get(sym)
    result.push Variable.new(sym, var)
  end
  result.push Variable.new(:self, frame_binding.receiver)
  result
end