package compiler
- Source
- package.scala
- Alphabetic
- By Inheritance
- compiler
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class Compiler[F[_]] extends AnyRef
Compiles a valid module to the low level assembly language.
Compiles a valid module to the low level assembly language. This is a one-pass assembler which generates typed breaks.
This compiler executes the static part of the specification semantics, i.e. the one dealing with labels and breaks. The static restrictions on the WebAssembly bytecodes make it possible to statically compute the local stack size at any point in a function body. Of course, it assumes that the module is valid otherwise it will break or generate undefined assembly code.
- case class Context[F[_]](types: Vector[FuncType] = Vector.empty, funcs: Vector[Int] = Vector.empty, code: Vector[Func[F]] = Vector.empty, tables: Vector[Tab] = Vector.empty, mems: Vector[Mem] = Vector.empty, globals: Vector[Glob[F]] = Vector.empty, elems: Vector[CompiledElem[F]] = Vector.empty, data: Vector[CompiledData[F]] = Vector.empty, start: Option[Int] = None, exports: Vector[Export] = Vector.empty, imports: Vector[Import] = Vector.empty, customs: Vector[Custom] = Vector.empty) extends Product with Serializable
- sealed trait Func[+F[_]] extends AnyRef
- case class FunctionContext(labels: LabelStack, errata: List[(Target, (Int) => Unit)], offsets: Map[Target, Int], offset: Int, nxt: Int) extends Product with Serializable
Compilation context used when compiling instructions for a function.
Compilation context used when compiling instructions for a function. The label stack represents the static trace of the program so far in terms of stack modifications, the errata registers the label to fix later, and the jump label offsets. This allows to compile code in one pass even with forward jumps.
The
errata
lists how to set correct offset for target labels.The
offsets
maps label names to their offset.Once all code has been generated, the placeholders pointed by the
errata
map are replaced with real offsets from theoffsets
map. - sealed trait Glob[+F[_]] extends AnyRef
- case class LabelStack(parent: LabelStack, target: Target, arity: Int, pushed: Int) extends Product with Serializable
A stack of labels, each one tracking following information:
A stack of labels, each one tracking following information:
- the parent label
- its target on break
- its arity (i.e. the number of return value to pop and return on break)
- the number of pushed value so far for the current label
At top-level, the parent is
null
and target is0
. No checks need to be performed because the compiler is only called if the program is correct, in which case all breaks target an existing label. The top-level label is a special synthesized one, representing the top-level block of the function body.
- sealed trait Mem extends AnyRef
- sealed trait Tab extends AnyRef
- type Target = Int
A target label for a break