Apply an instance method with dynamic dispatch (the default).
Apply a static method.
Apply an instance method with static dispatch (e.g., super calls).
Binary operation (always preserves pureness).
Closure with explicit captures.
Closure with explicit captures. The n captures map to the n first formal arguments.
Binary operation (always preserves pureness).
Binary operation (always preserves pureness).
Operations which do not preserve pureness are not allowed in this tree. These are notably +=, -=, *=, /= and %=
JavaScript dynamic import of the form import(arg)
.
JavaScript dynamic import of the form import(arg)
.
This form is its own node, rather than using something like
JSFunctionApply(JSImport())
because import
is not a first-class term in JavaScript.
ImportCall
is a dedicated syntactic form that cannot be
dissociated.
Loading specification for a native JS class or object.
...items
, the "spread" operator of ECMAScript 6.
...items
, the "spread" operator of ECMAScript 6.
It is only valid in the args
/items
of a JSNew, JSFunctionApply,
JSDotMethodApply, JSBracketMethodApply, or JSArrayConstr.
An Array whose items will be spread (not an arbitrary iterable)
Calls a method inherited from the parent class of cls
on receiver
.
Calls a method inherited from the parent class of cls
on receiver
.
cls
must be a Scala.js-defined JS class.
Given the Scala.js-defined JS class
class Foo extends Bar
The node
JSSuperBrackerCall(ClassType(Foo), receiver, method, args)
which is printed as
receiver.Foo::super[method](...args)
has the following semantics:
Bar.prototype[method].call(receiver, ...args)
If this happens to be located in an instance method of Foo
, *and*
receiver
happens to be This()
, this is equivalent to the ES6
statement
super[method](...args)
Selects a property inherited from the parent class of cls
on receiver
.
Selects a property inherited from the parent class of cls
on receiver
.
cls
must be a Scala.js-defined JS class.
Given the Scala.js-defined JS class
class Foo extends Bar
The node
JSSuperBrackerSelect(ClassType(Foo), qualifier, item)
which is printed as
qualifier.Foo::super[item]
has the semantics of an ES6 super reference
super[item]
as if it were in an instance method of Foo
with qualifier
as the
this
value.
Super constructor call in the constructor of a Scala.js-defined JS class.
Super constructor call in the constructor of a Scala.js-defined JS class.
Exactly one such node must appear in the constructor of a
Scala.js-defined JS class, at the top-level (possibly as a direct child
of a top-level Block
). Any other use of this node is invalid.
Statements before this node, as well as the args
, cannot contain any
This()
node. Statements after this node can use This()
.
After the execution of this node, it is guaranteed that all fields declared in the current class have been created and initialized. Up to that point, accessing any field declared in this class (e.g., through an overridden method called from the super constructor) is undefined behavior.
All in all, the shape of a constructor is therefore:
{ statementsNotUsingThis(); JSSuperConstructorCall(...argsNotUsingThis); statementsThatMayUseThis() }
which currently translates to something of the following shape:
{ statementsNotUsingThis(); super(...argsNotUsingThis); this.privateField1 = 0; this["publicField2"] = false; statementsThatMayUseThis() }
Unary operation (always preserves pureness).
Unary operation (always preserves pureness).
Operations which do not preserve pureness are not allowed in this tree. These are notably ++ and --
Marker for literals.
Marker for literals. Literals are always pure.
Loads the constructor of a JS class (native or not).
Loads the constructor of a JS class (native or not).
cls
must represent a non-trait JS class (native or not).
This is used typically to instantiate a JS class, and most importantly if it is a Scala.js-defined JS class. Given the class
class Foo(x: Int) extends js.Object
The instantiation new Foo(1)
would be represented as
JSNew(LoadJSConstructor(ClassType("Foo")), List(IntLiteral(1)))
This node is also useful to encode o.isInstanceOf[Foo]
:
JSBinaryOp(instanceof, o, LoadJSConstructor(ClassType("Foo")))
If Foo
is Scala.js-defined, the presence of this node makes it
instantiable, and therefore reachable.
Like LoadModule but for a JS module class.
A break-free switch (without fallthrough behavior).
A break-free switch (without fallthrough behavior). Unlike a JavaScript switch, it can be used in expression position. It supports alternatives explicitly (hence the List[Tree] in cases), whereas in a switch one would use the fallthrough behavior to implement alternatives. (This is not a pattern matching construct like in Scala.)
Traditional @JSExport
for top-level objects, as a 0-arg function.
Traditional @JSExport
for top-level objects, as a 0-arg function.
This exports a module as a 0-arg function that returns the module instance. It is initialized lazily in that case.
This alternative should eventually disappear.
New-style @JSExportTopLevel
for top-level objects, directly as the
object.
New-style @JSExportTopLevel
for top-level objects, directly as the
object.
This exports a module directly as a variable holding the module instance. The instance is initialized during ES module instantiation.
AST node of the IR.
A hash of a tree (usually a MethodDef).
A hash of a tree (usually a MethodDef). Contains two SHA-1 hashes
Unary operation (always preserves pureness).