Package de.inetsoftware.jwebassembly
Class JWebAssembly
java.lang.Object
de.inetsoftware.jwebassembly.JWebAssembly
The main class of the compiler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Property for adding debug names to the output if true.static final String
The name of the annotation for export functions.static final String
The name of the annotation for import functions.static final Logger
The logger instancestatic final String
The name of the annotation for partial class another class of the Java runtime.static final String
The name of the annotation for replacing a single method of the Java runtime.static final String
Property for relative path between the final wasm file location and the source files location for the source map.static final String
The name of the annotation for native WASM code in text format.static final String
If the exception handling feature of WASM should be use or an unreachable instruction.static final String
If the GC feature of WASM should be use or the GC of the JavaScript host. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a classFile to compilevoid
Add a classFile to compilevoid
addLibrary
(File library) Add a jar or zip file as library to the compiler.void
addLibrary
(URL library) Add a jar or zip file as library to the compiler.private void
compile
(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 void
compileToBinary
(WasmTarget target) Convert the added files to a WebAssembly module in binary representation.void
compileToBinary
(File file) Convert the added files to a WebAssembly module in binary representation.void
compileToBinary
(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 void
compileToText
(WasmTarget target) Convert the added files to a WebAssembly module in text representation.void
compileToText
(File file) Convert the added files to a WebAssembly module in text representation.void
compileToText
(Appendable output) Convert the added files to a WebAssembly module in text representation.getProperty
(String key) Get the value of a property.void
setProperty
(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
Add a classFile to compile- Parameters:
classFile
- the file
-
addFile
Add a classFile to compile- Parameters:
classFile
- the file
-
setProperty
Set property to control the behavior of the compiler- Parameters:
key
- the keyvalue
- the new value
-
getProperty
Get the value of a property.- Parameters:
key
- the key- Returns:
- the current value
-
addLibrary
Add a jar or zip file as library to the compiler. Methods from the library will be add to the wasm only when used.- Parameters:
library
- a archive file
-
addLibrary
Add a jar or zip file as library to the compiler. Methods from the library will be add to the wasm only when used.- Parameters:
library
- a archive file
-
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
-