Class: VariableScope

Inherits:
Hash
  • Object
show all
Defined in:
lib/zombie_killer/variable_scope.rb

Overview

Tracks state for local variables visible at certain point. Keys are symbols, values are VariableState

Instance Method Summary collapse

Constructor Details

#initializeVariableScope

Returns a new instance of VariableScope.



9
10
11
12
13
# File 'lib/zombie_killer/variable_scope.rb', line 9

def initialize
  super do |hash, key|
    hash[key] = VariableState.new
  end
end

Instance Method Details

#[](varname) ⇒ VariableState

Returns state.

Returns:



25
26
27
# File 'lib/zombie_killer/variable_scope.rb', line 25

def [](varname)
  super
end

#[]=(varname, state) ⇒ Object

Set state for a variable



30
31
32
# File 'lib/zombie_killer/variable_scope.rb', line 30

def []=(varname, state)
  super
end

#dupObject

Deep copy the VariableState values



16
17
18
19
20
21
22
# File 'lib/zombie_killer/variable_scope.rb', line 16

def dup
  copy = self.class.new
  each do |k, v|
    copy[k] = v.dup
  end
  copy
end