Class: SyntaxTree::WithScope::Scope::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/with_scope.rb

Overview

This class tracks the occurrences of a local variable or argument.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#definitionsObject (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

#typeObject (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

#usagesObject (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