Class StandardColors

java.lang.Object
com.google.javascript.jscomp.colors.StandardColors

public final class StandardColors extends Object
Colors that are expected to be referencable as part of any compilation.

This set describes any Color that needs to be used a priori by a compiler pass. That includes:

  • "axiomatic" Colors (those with constant definitions, e.g. UNKNOWN)
  • primitive Colors (e.g. `number`, `null`)
  • box Colors (e.g. `Number`, `String`)
  • Colors used in AstFactory to type synthetic nodes (e.g. `Array`)
  • Field Details

    • ARGUMENTS_ID

      public static final ColorId ARGUMENTS_ID
    • ARRAY_ID

      public static final ColorId ARRAY_ID
    • READONLY_ARRAY_ID

      public static final ColorId READONLY_ARRAY_ID
    • GENERATOR_ID

      public static final ColorId GENERATOR_ID
    • I_TEMPLATE_ARRAY_ID

      public static final ColorId I_TEMPLATE_ARRAY_ID
    • ITERATOR_ID

      public static final ColorId ITERATOR_ID
    • ASYNC_ITERATOR_ITERABLE_ID

      public static final ColorId ASYNC_ITERATOR_ITERABLE_ID
    • PROMISE_ID

      public static final ColorId PROMISE_ID
    • BIGINT_OBJECT_ID

      public static final ColorId BIGINT_OBJECT_ID
    • BOOLEAN_OBJECT_ID

      public static final ColorId BOOLEAN_OBJECT_ID
    • NUMBER_OBJECT_ID

      public static final ColorId NUMBER_OBJECT_ID
    • STRING_OBJECT_ID

      public static final ColorId STRING_OBJECT_ID
    • SYMBOL_OBJECT_ID

      public static final ColorId SYMBOL_OBJECT_ID
    • BIGINT

      public static final Color BIGINT
    • BOOLEAN

      public static final Color BOOLEAN
    • NULL_OR_VOID

      public static final Color NULL_OR_VOID
    • NUMBER

      public static final Color NUMBER
    • STRING

      public static final Color STRING
    • SYMBOL

      public static final Color SYMBOL
    • TOP_OBJECT

      public static final Color TOP_OBJECT
      The supertype of all objects but not primitives.

      Separate from UNKNOWN because some optimizations back off on any non-object primitives + unknown but operate on the top object.

    • UNKNOWN

      public static final Color UNKNOWN
      Analagous to Closure '*'/'?' and TS unknown/any
    • AXIOMATIC_COLORS

      public static final com.google.common.collect.ImmutableMap<ColorId,Color> AXIOMATIC_COLORS
      The set of Colors whose definitions are independent of all JS code.

      Because they have no dependencies, they are instantated once, here, and made globally available. No other Color object may ever have these IDs.

      Some axiomatic Colors do not have an associated runtime type or set of runtime instances. These represent abstract concepts, rather than anything in a JSVM.

    • PRIMITIVE_COLORS

      public static final com.google.common.collect.ImmutableMap<ColorId,Color> PRIMITIVE_COLORS
      The set of Colors that have associated runtime values but are not objects.

      In JS, instances of primitve Colors are deeply immutable.

    • PRIMITIVE_BOX_IDS

      public static final com.google.common.collect.ImmutableSet<ColorId> PRIMITIVE_BOX_IDS
      The set of ColorIds for object Colors that "box" primitive Colors.

      Boxing is when the JSVM automatically wraps a primitive value in a temporary object so it can participate in a method call or other object-only operation.

      The eaxct definition of each box Color may be altered by JS code.