Class: Datadog::CI::SourceCode::StaticDependenciesExtractor::BytecodeScanner Private
- Inherits:
-
Object
- Object
- Datadog::CI::SourceCode::StaticDependenciesExtractor::BytecodeScanner
- Defined in:
- lib/datadog/ci/source_code/static_dependencies_extractor.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
BytecodeScanner scans Ruby bytecode instructions for constant references.
This class traverses the ISeq#to_a representation to find:
-
:getconstant instructions - simple constant references
-
:opt_getconstant_path instructions - optimized qualified constant paths
Instance Method Summary collapse
-
#build_constant_path(symbol_array) ⇒ String
private
Build a qualified constant name from an array of symbols.
-
#scan(body) ⇒ Array<String>
private
Scan an ISeq body for constant references.
Instance Method Details
#build_constant_path(symbol_array) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build a qualified constant name from an array of symbols. e.g., [:Foo, :Bar, :Baz] -> “Foo::Bar::Baz”
51 52 53 54 55 56 |
# File 'lib/datadog/ci/source_code/static_dependencies_extractor.rb', line 51 def build_constant_path(symbol_array) symbol_array .select { |part| part.is_a?(Symbol) } .map(&:to_s) .join("::") end |
#scan(body) ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Scan an ISeq body for constant references.
38 39 40 41 42 43 44 |
# File 'lib/datadog/ci/source_code/static_dependencies_extractor.rb', line 38 def scan(body) return [] unless body.is_a?(Array) constants = [] scan_value(body, constants) constants end |