class Recursivar::Heap

Attributes

heap[R]

Public Class Methods

new(stack) click to toggle source
# File lib/recursivar/heap.rb, line 39
def initialize(stack)
  @heap = {}

  stack.each_with_index do |callor, idx|
    local_values = {}
    callor.lv.each_pair do |name, obj|
      local_values[name] = ref(obj)
    end

    callor_v = wrap_caller(callor)
    callor_v.values.merge!(local_values)

    callee = stack[idx - 1]
    link_callee(callor_v, callee, "#{idx} #{callee.frame_env}") if idx > 0
  end
end

Public Instance Methods

each() { |v| ... } click to toggle source
# File lib/recursivar/heap.rb, line 74
def each
  @heap.each_pair{ |_, v| yield(v) }
end
ref(obj) click to toggle source
# File lib/recursivar/heap.rb, line 66
def ref(obj)
  v = (@heap[obj.object_id] ||= Value.new(obj))
  v.ref_instance_variables(self)
  v
end
wrap_caller(callor) click to toggle source
# File lib/recursivar/heap.rb, line 61
def wrap_caller(callor)
  callor_obj = callor.send(:binding_self)
  ref(callor_obj)
end