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
24 25 26 27 28 |
# File 'lib/syntax_tree/visitor/environment.rb', line 24 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
18 19 20 |
# File 'lib/syntax_tree/visitor/environment.rb', line 18 def definitions @definitions end |
#type ⇒ Object (readonly)
- Symbol
-
The type of the local (e.g. :argument, :variable)
14 15 16 |
# File 'lib/syntax_tree/visitor/environment.rb', line 14 def type @type end |
#usages ⇒ Object (readonly)
- Array
-
The locations of all usages of this local
21 22 23 |
# File 'lib/syntax_tree/visitor/environment.rb', line 21 def usages @usages end |
Instance Method Details
#add_definition(location) ⇒ Object
add_definition: (Location location) -> void
31 32 33 |
# File 'lib/syntax_tree/visitor/environment.rb', line 31 def add_definition(location) @definitions << location end |
#add_usage(location) ⇒ Object
add_usage: (Location location) -> void
36 37 38 |
# File 'lib/syntax_tree/visitor/environment.rb', line 36 def add_usage(location) @usages << location end |