Class: ShadowStack

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

Overview

Track the executions in a shadow call stack.

Instance Method Summary collapse

Constructor Details

#initializeShadowStack

Returns a new instance of ShadowStack.



9
10
11
12
# File 'lib/ShadowStack.rb', line 9

def initialize()
  @bottom = nil
  @top = nil
end

Instance Method Details

#baseObject



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

def base()
  @bottom
end

#peekObject



14
15
16
# File 'lib/ShadowStack.rb', line 14

def peek()
  @top
end

#push(execution) ⇒ Execution

Place Execution at the top of stack.

Parameters:

  • execution (Execution)

    The execution to place.

Returns:



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

def push(execution)

  # Place first execution at bottom of stack.
  if @bottom.nil?
    @bottom = execution
  # Connect subsequent executions to each other.
  else
    @top.parent = execution
    execution.child = @top
  end

  # Place execution at top of stack.
  @top = execution

end