org.scalajs.core.ir.Trees
Loads the constructor of a JS class (native or not).
cls must represent a non-trait JS class (native or not).
cls
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
new Foo(1)
JSNew(LoadJSConstructor(ClassType("Foo")), List(IntLiteral(1)))
This node is also useful to encode o.isInstanceOf[Foo]:
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.
Foo
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
The instantiation
new Foo(1)
would be represented asThis 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.