Class: ShadowStack

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

Overview

SHADOW STACK

Track the executions in a 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

#displayObject



45
46
47
# File 'lib/ShadowStack.rb', line 45

def display
  display_execution_tree(@bottom)
end

#display_execution_tree(execution) ⇒ Object



49
50
51
52
53
54
# File 'lib/ShadowStack.rb', line 49

def display_execution_tree(execution)
  p execution
  unless execution.parent == nil
    display_execution_tree(execution.parent)
  end
end

#peekObject



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

def peek()
  @top
end

#push(execution) ⇒ Object

Push Execution.

Parameters:

  • object
    • The object being executed.

  • args
    • The arguments being executed.

Returns:

  • Execution - The new execution.



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

def push(execution)

  # Reference previous execution.
  if @bottom.nil?
    @bottom = execution
  else
    execution.child = @top
    @top.parent = execution
  end

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

end