Class JWebAssembly
java.lang.Object
de.inetsoftware.jwebassembly.JWebAssembly
The main class of the compiler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringProperty for adding debug names to the output if true.static final StringThe name of the annotation for export functions.static final StringThe name of the annotation for import functions.static final LoggerThe logger instancestatic final StringThe name of the annotation for partial class another class of the Java runtime.static final StringThe name of the annotation for replacing a single method of the Java runtime.static final StringProperty for relative path between the final wasm file location and the source files location for the source map.static final StringThe name of the annotation for native WASM code in text format.static final StringIf the exception handling feature of WASM should be use or an unreachable instruction.static final StringIf the GC feature of WASM should be use or the GC of the JavaScript host. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a classFile to compilevoidAdd a classFile to compilevoidaddLibrary(File library) Add a jar or zip file as library to the compiler.voidaddLibrary(URL library) Add a jar or zip file as library to the compiler.private voidcompile(ModuleWriter writer, WasmTarget target) Convert the added files to a WebAssembly module.byte[]Convert the added files to a WebAssembly module in binary representation.private voidcompileToBinary(WasmTarget target) Convert the added files to a WebAssembly module in binary representation.voidcompileToBinary(File file) Convert the added files to a WebAssembly module in binary representation.voidcompileToBinary(OutputStream output) Convert the added files to a WebAssembly module in binary representation.Convert the added files to a WebAssembly module in text representation.private voidcompileToText(WasmTarget target) Convert the added files to a WebAssembly module in text representation.voidcompileToText(File file) Convert the added files to a WebAssembly module in text representation.voidcompileToText(Appendable output) Convert the added files to a WebAssembly module in text representation.getProperty(String key) Get the value of a property.voidsetProperty(String key, String value) Set property to control the behavior of the compiler
-
Field Details
-
classFiles
-
properties
-
libraries
-
DEBUG_NAMES
Property for adding debug names to the output if true.- See Also:
-
SOURCE_MAP_BASE
Property for relative path between the final wasm file location and the source files location for the source map. If not empty it should end with a slash like "../../src/main/java/".- See Also:
-
IMPORT_ANNOTATION
The name of the annotation for import functions.- See Also:
-
EXPORT_ANNOTATION
The name of the annotation for export functions.- See Also:
-
TEXTCODE_ANNOTATION
The name of the annotation for native WASM code in text format.- See Also:
-
REPLACE_ANNOTATION
The name of the annotation for replacing a single method of the Java runtime.- See Also:
-
PARTIAL_ANNOTATION
The name of the annotation for partial class another class of the Java runtime.- See Also:
-
WASM_USE_GC
If the GC feature of WASM should be use or the GC of the JavaScript host. If true use the GC instructions of WASM.- See Also:
-
WASM_USE_EH
If the exception handling feature of WASM should be use or an unreachable instruction. If true use the exception instructions of WASM.- See Also:
-
LOGGER
The logger instance
-
-
Constructor Details
-
JWebAssembly
public JWebAssembly()Create a instance.
-
-
Method Details
-
addFile
-
addFile
-
setProperty
-
getProperty
-
addLibrary
-
addLibrary
-
compileToText
Convert the added files to a WebAssembly module in text representation.- Returns:
- the module as string
- Throws:
WasmException- if any conversion error occurs
-
compileToText
Convert the added files to a WebAssembly module in text representation.- Parameters:
file- the target for the module data- Throws:
WasmException- if any conversion error occurs
-
compileToText
Convert the added files to a WebAssembly module in text representation.- Parameters:
output- the target for the module data- Throws:
WasmException- if any conversion error occurs
-
compileToText
Convert the added files to a WebAssembly module in text representation.- Parameters:
target- the target for the module data- Throws:
WasmException- if any conversion error occurs
-
compileToBinary
Convert the added files to a WebAssembly module in binary representation.- Returns:
- the module as string
- Throws:
WasmException- if any conversion error occurs
-
compileToBinary
Convert the added files to a WebAssembly module in binary representation.- Parameters:
file- the target for the module data- Throws:
WasmException- if any conversion error occurs
-
compileToBinary
Convert the added files to a WebAssembly module in binary representation.- Parameters:
output- the target for the module data- Throws:
WasmException- if any conversion error occurs
-
compileToBinary
Convert the added files to a WebAssembly module in binary representation.- Parameters:
target- the target for the module data- Throws:
WasmException- if any conversion error occurs
-
compile
Convert the added files to a WebAssembly module.- Parameters:
writer- the formattertarget- the target for the module data- Throws:
IOException- if any I/O error occurWasmException- if any conversion error occurs
-