class ClassEmitter extends AnyRef
- Alphabetic
- By Inheritance
- ClassEmitter
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def genClassDef(clazz: LinkedClass)(implicit ctx: WasmContext): Unit
-
def
genGlobalArrayClassItable()(implicit ctx: WasmContext): Unit
Generate common itable global for all array classes.
-
def
genTopLevelExport(topLevelExport: LinkedTopLevelExport)(implicit ctx: WasmContext): Unit
Generates code for a top-level export.
Generates code for a top-level export.
It is tempting to use Wasm
export
s for top-level exports. However, that does not work in several situations:- for values, an
export
edglobal
is visible in JS as an instance ofWebAssembly.Global
, of which we need to extract the.value
field anyway - this in turn causes issues for mutable static fields, since we need to republish changes
- we cannot distinguish mutable static fields from immutable ones, so we have to use the same strategy for both
- exported top-level
def
s must be seen by JS asfunction
functions, butexport
edfunc
s are JS arrow functions
Overall, the only things for which
export
s would work are for exported JS classes and objects.Instead, we uniformly use the following strategy for all top-level exports:
- the JS code declares a non-initialized
let
for every top-level export, and exports it from the module with an ECMAScriptexport
- the JS code provides a setter function that we import into a Wasm, which allows to set the
value of that
let
- the Wasm code "publishes" every update to top-level exports to the JS code via this
setter; this happens once in the
start
function for every kind of top-level export (seeEmitter.genStartFunction
), and in addition upon each reassignment of a top-level exported field (seeFunctionEmitter.genAssign
).
This method declares the import of the setter on the Wasm side, for all kinds of top-level exports. In addition, for exported *methods*, it generates the implementation of the method as a Wasm function.
The JS code is generated by
Emitter.buildJSFileContent
. Note that for fields, the JSlet
s are only "mirrors" of the state. The source of truth for the state remains in the Wasm Global for the static field. This is fine because, by spec of ECMAScript modules, JavaScript code that *uses* the export cannot mutate it; it can only read it.The calls to the setters, which actually initialize all the exported
let
s, are performed:- in the
start
function for all kinds of exports, and - in addition on every assignment to an exported mutable static field.
- for values, an
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()