Module: Ryac::BootConstants

Defined in:
lib/ryac/analysis/constant/collection.rb,
sig/ryac/analysis/constant/collection.rbs

Overview

The top-level constants that exist when the minified program boots, before any of its own code runs: Ruby's core names plus whatever its top-level requires provide. Asking a fresh interpreter is what makes this exact — no naming-convention guessing, and no contamination from the constants the minifier process itself happens to have loaded. nil when the probe fails, so callers can fall back conservatively.

Its own module rather than a phase method: the memo is process state (one probe per require set, because the probe boots an interpreter), and process state does not belong on a mixin of per-run phases.

Class Method Summary collapse

Class Method Details

.for(stdlib_requires) ⇒ Set[Symbol]?

Parameters:

  • stdlib_requires (Array[String])

Returns:

  • (Set[Symbol], nil)


357
358
359
360
361
362
# File 'lib/ryac/analysis/constant/collection.rb', line 357

def for(stdlib_requires)
  key = stdlib_requires.sort
  return @cache[key] if @cache.key?(key)

  @cache[key] = probe(stdlib_requires)
end