Class: IRWebmachine::Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/irwebmachine/stack.rb

Instance Method Summary collapse

Constructor Details

#initialize(stack = []) ⇒ Stack

Returns a new instance of Stack.



2
3
4
5
6
7
8
# File 'lib/irwebmachine/stack.rb', line 2

def initialize(stack = [])
  @stack = stack
  @index = -1
  @tracer = IRWebmachine::Tracer.new
  @tracer.events = ["call", "return"]
  @tracer.targets =  [Webmachine::Resource::Callbacks]
end

Instance Method Details

#continueObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/irwebmachine/stack.rb', line 28

def continue
  if exhausted?
    if !at_end_of_stack
      @index += 1
    end
  else
    if at_end_of_stack
      @stack << tracer.continue
    end
    @index += 1
  end
  @stack[@index]
end

#exhausted?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/irwebmachine/stack.rb', line 24

def exhausted?
  @tracer.finished?
end

#nextObject



42
43
44
45
46
47
48
49
# File 'lib/irwebmachine/stack.rb', line 42

def next
  frame = nil
  until frame && frame.ruby_call?
    frame = continue
    break if exhausted? && at_end_of_stack
  end
  frame
end

#previousObject



19
20
21
22
# File 'lib/irwebmachine/stack.rb', line 19

def previous
  @index -= 1 if @index > 0
  @stack[@index]
end

#push(*args) ⇒ Object Also known as: <<



10
11
12
# File 'lib/irwebmachine/stack.rb', line 10

def push(*args)
  @stack.push(*args)
end

#tracerObject



15
16
17
# File 'lib/irwebmachine/stack.rb', line 15

def tracer
  @tracer
end