Class: IRScopeRegistry

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

Overview

Registry for IRScopes, to access them by key without nesting of scopes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_scope) ⇒ IRScopeRegistry

Returns a new instance of IRScopeRegistry.



27
28
29
30
# File 'lib/jruby_visualizer/ir_scope_registry.rb', line 27

def initialize(root_scope)
  @scopes = {}
  fill_registry(root_scope)
end

Instance Attribute Details

#scopesObject (readonly)

Returns the value of attribute scopes.



25
26
27
# File 'lib/jruby_visualizer/ir_scope_registry.rb', line 25

def scopes
  @scopes
end

Instance Method Details

#clearObject



37
38
39
# File 'lib/jruby_visualizer/ir_scope_registry.rb', line 37

def clear
  @scopes = {}
end

#fill_registry(ir_scope) ⇒ Object



32
33
34
35
# File 'lib/jruby_visualizer/ir_scope_registry.rb', line 32

def fill_registry(ir_scope)
  @scopes[ir_scope.key] = ir_scope
  ir_scope.lexical_scopes.each { |lex_scope| fill_registry(lex_scope) }
end