Class: SyntaxTree::WithScope::Scope::Local
- Inherits:
-
Object
- Object
- SyntaxTree::WithScope::Scope::Local
- Defined in:
- lib/syntax_tree/with_scope.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_usage(location) ⇒ Object
-
#initialize(type) ⇒ Local
constructor
A new instance of Local.
Constructor Details
#initialize(type) ⇒ Local
Returns a new instance of Local.
43 44 45 46 47 |
# File 'lib/syntax_tree/with_scope.rb', line 43 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
38 39 40 |
# File 'lib/syntax_tree/with_scope.rb', line 38 def definitions @definitions end |
#type ⇒ Object (readonly)
- Symbol
-
The type of the local (e.g. :argument, :variable)
34 35 36 |
# File 'lib/syntax_tree/with_scope.rb', line 34 def type @type end |
#usages ⇒ Object (readonly)
- Array
-
The locations of all usages of this local
41 42 43 |
# File 'lib/syntax_tree/with_scope.rb', line 41 def usages @usages end |
Instance Method Details
#add_definition(location) ⇒ Object
49 50 51 |
# File 'lib/syntax_tree/with_scope.rb', line 49 def add_definition(location) @definitions << location end |
#add_usage(location) ⇒ Object
53 54 55 |
# File 'lib/syntax_tree/with_scope.rb', line 53 def add_usage(location) @usages << location end |