Class: CSVPlusPlus::Runtime::References
- Inherits:
-
Object
- Object
- CSVPlusPlus::Runtime::References
- Extended by:
- T::Sig
- Defined in:
- lib/csv_plus_plus/runtime/references.rb
Overview
References in an AST that need to be resolved
Instance Attribute Summary collapse
-
#functions ⇒ Array<Entities::Function>
Functions references.
-
#variables ⇒ Array<Entities::Variable>
Variable references.
Class Method Summary collapse
-
.extract(ast, position, scope) ⇒ References
Extract references from an AST and return them in a new
References
object.
Instance Method Summary collapse
- #==(other) ⇒ boolean
-
#empty? ⇒ ::T::Boolean
Are there any references to be resolved?.
-
#initialize ⇒ References
constructor
Create an object with empty references.
Constructor Details
#initialize ⇒ References
Create an object with empty references. The caller will build them up as it depth-first-searches
93 94 95 96 |
# File 'lib/csv_plus_plus/runtime/references.rb', line 93 def initialize @functions = ::T.let([], ::T::Array[::CSVPlusPlus::Entities::FunctionCall]) @variables = ::T.let([], ::T::Array[::CSVPlusPlus::Entities::Reference]) end |
Instance Attribute Details
#functions ⇒ Array<Entities::Function>
Functions references
10 11 12 |
# File 'lib/csv_plus_plus/runtime/references.rb', line 10 def functions @functions end |
#variables ⇒ Array<Entities::Variable>
Variable references
10 11 12 |
# File 'lib/csv_plus_plus/runtime/references.rb', line 10 def variables @variables end |
Class Method Details
.extract(ast, position, scope) ⇒ References
Extract references from an AST and return them in a new References
object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/csv_plus_plus/runtime/references.rb', line 33 def self.extract(ast, position, scope) new.tap do |refs| ::CSVPlusPlus::Runtime::Graph.depth_first_search(ast) do |node| unless node.is_a?(::CSVPlusPlus::Entities::FunctionCall) || node.is_a?(::CSVPlusPlus::Entities::Reference) next end refs.functions << node if function_reference?(node, scope) refs.variables << node if variable_reference?(node, position, scope) end end end |
Instance Method Details
#==(other) ⇒ boolean
102 103 104 |
# File 'lib/csv_plus_plus/runtime/references.rb', line 102 def ==(other) @functions == other.functions && @variables == other.variables end |
#empty? ⇒ ::T::Boolean
Are there any references to be resolved?
110 111 112 |
# File 'lib/csv_plus_plus/runtime/references.rb', line 110 def empty? @functions.empty? && @variables.empty? end |