Class: Interner

lib/compiler/ir/lower~Interner()

Interns strings, returning a stable index per distinct value.

Two bindings that read cart.total share one compiled closure and one entry, which is the same de-duplication the source-keyed table got for free from being an object. Nothing depends on the de-duplication for correctness; it exists so a template that reads one value in ten places costs one closure.

Constructor

new Interner()

Creates an empty intern table.

Source:

Members

index :Map:.<string:, number:>

Type:
  • Map:.<string:, number:>
Source:

values :Array:.<string:>

Type:
  • Array:.<string:>
Source:

Methods

intern(source) → {number}

Returns the index for a source string, adding it when new.

Parameters:
Name Type Description
source string

The expression or statement source.

Source:
Returns:

Its index.

Type
number