Class: SyntaxTree::Environment::Local
- Inherits:
-
Object
- Object
- SyntaxTree::Environment::Local
- Defined in:
- lib/syntax_tree/visitor/environment.rb
Overview
This class tracks the occurrences of a local variable or argument
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
- Array
-
The locations of all definitions and assignments of this local.
-
#type ⇒ Object
readonly
- Symbol
-
The type of the local (e.g. :argument, :variable).
-
#usages ⇒ Object
readonly
- Array
-
The locations of all usages of this local.
Instance Method Summary collapse
-
#add_definition(location) ⇒ Object
add_definition: (Location location) -> void.
-
#add_usage(location) ⇒ Object
add_usage: (Location location) -> void.
-
#initialize(type) ⇒ Local
constructor
initialize: (Symbol type) -> void.
Constructor Details
#initialize(type) ⇒ Local
initialize: (Symbol type) -> void
20 21 22 23 24 |
# File 'lib/syntax_tree/visitor/environment.rb', line 20 def initialize(type) @type = type @definitions = [] @usages = [] end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
- Array
-
The locations of all definitions and assignments of
this local
14 15 16 |
# File 'lib/syntax_tree/visitor/environment.rb', line 14 def definitions @definitions end |
#type ⇒ Object (readonly)
- Symbol
-
The type of the local (e.g. :argument, :variable)
10 11 12 |
# File 'lib/syntax_tree/visitor/environment.rb', line 10 def type @type end |
#usages ⇒ Object (readonly)
- Array
-
The locations of all usages of this local
17 18 19 |
# File 'lib/syntax_tree/visitor/environment.rb', line 17 def usages @usages end |
Instance Method Details
#add_definition(location) ⇒ Object
add_definition: (Location location) -> void
27 28 29 |
# File 'lib/syntax_tree/visitor/environment.rb', line 27 def add_definition(location) @definitions << location end |
#add_usage(location) ⇒ Object
add_usage: (Location location) -> void
32 33 34 |
# File 'lib/syntax_tree/visitor/environment.rb', line 32 def add_usage(location) @usages << location end |