org.scalajs.core.compiler

ExplicitLocalJS

abstract class ExplicitLocalJS extends PluginComponent with Transform with TypingTransformers with PluginComponent210Compat

Makes the references to local JS classes explicit and desugars calls to js.constructorOf.

It also makes explicit all references to inner JS classes, using the pointers created by ExplicitInnerJS, and otherwise makes sure the back-end will receive all the information it needs to translate inner- and local JS classes and objects.

Note that in this comment, by "class" we mean *only* classes. traits and objects are not implied.

Similarly to how ExplicitInnerJS creates explicit fields in the enclosing templates of inner JS classes to hold the JS class values, this phase creates local vals for local JS classes in the enclosing statement list.

For every local JS class of the form:

def outer() = {
class Local extends ParentJSClass
}

this phase creates a local val Local$jslass in the body of outer() to hold the JS class value for Local. The rhs of that val is a call to a magic method, used to retain information that the back-end will need:

The latter will be augmented by lambdalift with the appropriate actual parameters for the captures of Local, which will be needed by the back-end. In code, this looks like:

def outer() = {
class Local extends ParentJSClass
val Local$jsclass: AnyRef = createLocalJSClass(
    classOf[Local],
    js.constructorOf[ParentJSClass],
    Array[AnyRef](new Local(), ...))
}

Since we need to insert fake new Inner()s, this scheme does not work for abstract local classes. We therefore reject them as implementation restriction.

If the body of Local references itself, then the val Local$jsclass is instead declared as a var to work around the cyclic dependency:

def outer() = {
var Local$jsclass: AnyRef = null
class Local extends ParentJSClass {
  ...
}
Local$jsclass = createLocalJSClass(...)
}

In addition to the above, ExplicitLocalJS transforms all *call sites* of local JS classes *and* inner JS classes, so that they refer to the synthesized local vals and fields.

The primary transformation is the desugaring of js.constructorOf[C], which depends on the nature of C:

The other transformations build on top of the desugaring of js.constructorOf[C], and apply only to inner JS classes and local JS classes (not for statically accessible classes):

Finally, for inner- and local JS *objects*, their (only) instantiation point of the form new O.type() is rewritten as withContextualJSClassValue(js.constructorOf[ParentClassOfO], new O.type()), so that the back-end receives a reified reference to the parent class of O. A similar treatment is applied on anonymous JS classes, which basically define something very similar to an object, although without its own JS class.

Linear Supertypes
PluginComponent210Compat, Compat210Component, TypingTransformers, Transform, PluginComponent, SubComponent, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ExplicitLocalJS
  2. PluginComponent210Compat
  3. Compat210Component
  4. TypingTransformers
  5. Transform
  6. PluginComponent
  7. SubComponent
  8. AnyRef
  9. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ExplicitLocalJS()

Type Members

  1. implicit final class ErasedValueTypeCompat extends AnyRef

    Definition Classes
    Compat210Component
  2. class ExplicitLocalJSTransformer extends TypingTransformer

  3. implicit final class GlobalCompat extends AnyRef

    Definition Classes
    Compat210Component
  4. implicit class OverridingPairsCursor2Iterable extends AnyRef

    Definition Classes
    Compat210Component
  5. class Phase extends scala.tools.nsc.transform.Transform.StdPhase

    Definition Classes
    Transform
  6. implicit final class RunCompat extends AnyRef

    Definition Classes
    Compat210Component
  7. type SAMFunctionCompat = SAMFunction

    Definition Classes
    Compat210Component
  8. abstract class StdPhase extends GlobalPhase

    Definition Classes
    SubComponent
  9. implicit final class StdTermNamesCompat extends AnyRef

    Definition Classes
    Compat210Component
  10. implicit final class StdTypeNamesCompat extends AnyRef

    Definition Classes
    Compat210Component
  11. implicit final class SymbolCompat extends AnyRef

    Definition Classes
    Compat210Component
  12. abstract class TypingTransformer extends scala.tools.nsc.Global.Transformer

    Definition Classes
    TypingTransformers

Abstract Value Members

  1. abstract val global: Global

    Definition Classes
    Compat210Component
  2. abstract val jsAddons: JSGlobalAddons { val global: ExplicitLocalJS.this.global.type }

  3. abstract val runsAfter: List[String]

    Definition Classes
    SubComponent

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. object DelambdafyCompat

    Definition Classes
    Compat210Component
  7. object LowPrioGenBCodeCompat

    Definition Classes
    Compat210Component
  8. object Mode

    Definition Classes
    Compat210Component
  9. object SAMFunctionAttachCompat

    Definition Classes
    Compat210Component
  10. object SAMFunctionAttachCompatDef

    Definition Classes
    Compat210Component
  11. lazy val SAMFunctionCompat: SAMFunction.type

    Definition Classes
    Compat210Component
  12. final def afterOwnPhase[T](op: ⇒ T): T

    Definition Classes
    SubComponent
    Annotations
    @inline()
  13. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  14. final def beforeOwnPhase[T](op: ⇒ T): T

    Definition Classes
    SubComponent
    Annotations
    @inline()
  15. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  16. def description: String

  17. final def enteringPhase[T](ph: scala.tools.nsc.Phase)(op: ⇒ T): T

    Definition Classes
    Compat210Component
    Annotations
    @inline()
  18. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  20. final def exitingPhase[T](ph: scala.tools.nsc.Phase)(op: ⇒ T): T

    Definition Classes
    Compat210Component
    Annotations
    @inline()
  21. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  23. def hashCode(): Int

    Definition Classes
    SubComponent → AnyRef → Any
  24. def initializeCoreBTypesCompat(): Unit

    Definition Classes
    Compat210Component
  25. final val internal: Boolean(false)

    Definition Classes
    PluginComponent → SubComponent
  26. final def isFunctionSymbol(sym: scala.tools.nsc.Global.Symbol): Boolean

    Definition Classes
    Compat210Component
  27. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  28. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  29. def newPhase(prev: scala.tools.nsc.Phase): StdPhase

    Definition Classes
    Transform → SubComponent
  30. def newTransformer(unit: scala.tools.nsc.Global.CompilationUnit): scala.tools.nsc.Global.Transformer

    Attributes
    protected
    Definition Classes
    ExplicitLocalJS → Transform
  31. final def notify(): Unit

    Definition Classes
    AnyRef
  32. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  33. def ownPhase: scala.tools.nsc.Phase

    Definition Classes
    SubComponent
  34. val phaseName: String

    Definition Classes
    ExplicitLocalJS → SubComponent
  35. def phaseNewFlags: Long

    Definition Classes
    SubComponent
  36. def phaseNextFlags: Long

    Definition Classes
    SubComponent
  37. final def repeatedToSingle(t: scala.tools.nsc.Global.Type): scala.tools.nsc.Global.Type

    Definition Classes
    Compat210Component
    Annotations
    @inline()
  38. val runsBefore: List[String]

    Definition Classes
    SubComponent
  39. val runsRightAfter: Option[String]

    Definition Classes
    PluginComponent → SubComponent
  40. lazy val scalaUsesImplClasses: Boolean

    Definition Classes
    Compat210Component
  41. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  42. def toString(): String

    Definition Classes
    AnyRef → Any
  43. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  45. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from PluginComponent210Compat

Inherited from Compat210Component

Inherited from TypingTransformers

Inherited from Transform

Inherited from PluginComponent

Inherited from SubComponent

Inherited from AnyRef

Inherited from Any

Ungrouped