Class WasmOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
de.inetsoftware.jwebassembly.wasm.LittleEndianOutputStream
de.inetsoftware.jwebassembly.binary.WasmOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
-
Field Summary
FieldsFields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsConstructorDescriptionWasmOutputStream
(WasmOptions options) Create a in memory stream.WasmOutputStream
(WasmOptions options, OutputStream output) Create a wrapped stream. -
Method Summary
Modifier and TypeMethodDescription(package private) void
writeConst
(Number value, ValueType valueType) Write a constant number valuevoid
writeDefaultValue
(AnyType type) Write the default/initial value for a type.(package private) void
writeDouble
(double value) Write an double value.(package private) void
writeFloat
(float value) Write an float value.void
writeOpCode
(int op) Write a binary operation code.void
writeRefValueType
(AnyType type) Write the value type.(package private) void
writeSection
(SectionType type, WasmOutputStream data) Write a section with header and data.(package private) void
writeString
(String str) Write a string as UTF8 encoded.void
writeValueType
(AnyType type) Write a value type.(package private) void
writeVarint
(long value) Write an integer value.(package private) void
writeVaruint32
(int value) Write an unsigned integer.Methods inherited from class de.inetsoftware.jwebassembly.wasm.LittleEndianOutputStream
reset, size, write, write, writeInt32, writeTo
Methods inherited from class java.io.FilterOutputStream
close, flush, write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
options
-
-
Constructor Details
-
WasmOutputStream
WasmOutputStream(WasmOptions options) Create a in memory stream.- Parameters:
options
- compiler properties
-
WasmOutputStream
WasmOutputStream(WasmOptions options, OutputStream output) Create a wrapped stream.- Parameters:
options
- compiler propertiesoutput
- the target of data
-
-
Method Details
-
writeOpCode
Write a binary operation code.- Parameters:
op
- a constant fromInstructionOpcodes
- Throws:
IOException
- if an I/O error occurs.
-
writeValueType
Write a value type.- Parameters:
type
- a type constant- Throws:
IOException
- if an I/O error occurs.
-
writeRefValueType
Write the value type. If it is a struct type then as reference type.- Parameters:
type
- a type constant- Throws:
IOException
- if an I/O error occurs.
-
writeDefaultValue
Write the default/initial value for a type.- Parameters:
type
- the type- Throws:
IOException
- if an I/O error occurs.
-
writeVaruint32
Write an unsigned integer.- Parameters:
value
- the value- Throws:
IOException
- if an I/O error occurs.
-
writeVarint
Write an integer value.- Parameters:
value
- the value- Throws:
IOException
- if an I/O error occurs.
-
writeFloat
Write an float value.- Parameters:
value
- the value- Throws:
IOException
- if an I/O error occurs.
-
writeDouble
Write an double value.- Parameters:
value
- the value- Throws:
IOException
- if an I/O error occurs.
-
writeConst
Write a constant number value- Parameters:
value
- the valuevalueType
- the data type of the number- Throws:
IOException
- if any I/O error occur
-
writeString
Write a string as UTF8 encoded.- Parameters:
str
- the string- Throws:
IOException
- if any I/O error occur
-
writeSection
Write a section with header and data.- Parameters:
type
- the name of the sectiondata
- the data of the section- Throws:
IOException
- if any I/O error occur
-