Class: AdLint::Ld::VariableMap
- Inherits:
-
Object
- Object
- AdLint::Ld::VariableMap
- Defined in:
- lib/adlint/ld/object.rb
Instance Attribute Summary collapse
-
#composing_fpaths ⇒ Object
readonly
Returns the value of attribute composing_fpaths.
Instance Method Summary collapse
- #add_variable(var) ⇒ Object
- #add_variable_declaration(var_dcl) ⇒ Object
- #all_variable_declarations ⇒ Object
- #all_variables ⇒ Object
-
#initialize ⇒ VariableMap
constructor
A new instance of VariableMap.
- #lookup_variable_declarations(var_name) ⇒ Object
- #lookup_variables(var_name) ⇒ Object
Constructor Details
#initialize ⇒ VariableMap
Returns a new instance of VariableMap.
108 109 110 111 112 |
# File 'lib/adlint/ld/object.rb', line 108 def initialize @def_index = Hash.new { |hash, key| hash[key] = Set.new } @dcl_index = Hash.new { |hash, key| hash[key] = Set.new } @composing_fpaths = Set.new end |
Instance Attribute Details
#composing_fpaths ⇒ Object (readonly)
Returns the value of attribute composing_fpaths.
114 115 116 |
# File 'lib/adlint/ld/object.rb', line 114 def composing_fpaths @composing_fpaths end |
Instance Method Details
#add_variable(var) ⇒ Object
116 117 118 119 |
# File 'lib/adlint/ld/object.rb', line 116 def add_variable(var) @def_index[var.name].add(var) @composing_fpaths.add(var.location.fpath) end |
#add_variable_declaration(var_dcl) ⇒ Object
121 122 123 124 |
# File 'lib/adlint/ld/object.rb', line 121 def add_variable_declaration(var_dcl) @dcl_index[var_dcl.name].add(var_dcl) @composing_fpaths.add(var_dcl.location.fpath) end |
#all_variable_declarations ⇒ Object
130 131 132 |
# File 'lib/adlint/ld/object.rb', line 130 def all_variable_declarations @dcl_index.values.reduce(Set.new) { |all, dcls| all + dcls }.to_a end |
#all_variables ⇒ Object
126 127 128 |
# File 'lib/adlint/ld/object.rb', line 126 def all_variables @def_index.values.reduce(Set.new) { |all, vars| all + vars }.to_a end |
#lookup_variable_declarations(var_name) ⇒ Object
138 139 140 |
# File 'lib/adlint/ld/object.rb', line 138 def lookup_variable_declarations(var_name) @dcl_index[var_name].to_a end |
#lookup_variables(var_name) ⇒ Object
134 135 136 |
# File 'lib/adlint/ld/object.rb', line 134 def lookup_variables(var_name) @def_index[var_name].to_a end |