Class WasmOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- de.inetsoftware.jwebassembly.wasm.LittleEndianOutputStream
-
- de.inetsoftware.jwebassembly.binary.WasmOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
class WasmOutputStream extends LittleEndianOutputStream
-
-
Field Summary
Fields Modifier and Type Field Description private WasmOptionsoptions
-
Constructor Summary
Constructors Constructor Description WasmOutputStream(WasmOptions options)Create a in memory stream.WasmOutputStream(WasmOptions options, java.io.OutputStream output)Create a wrapped stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidwriteConst(java.lang.Number value, ValueType valueType)Write a constant number valuevoidwriteDefaultValue(AnyType type)Write the default/initial value for a type.(package private) voidwriteDouble(double value)Write an double value.(package private) voidwriteFloat(float value)Write an float value.voidwriteOpCode(int op)Write a binary operation code.voidwriteRefValueType(AnyType type)Write the value type.(package private) voidwriteSection(SectionType type, WasmOutputStream data)Write a section with header and data.(package private) voidwriteString(java.lang.String str)Write a string as UTF8 encoded.voidwriteValueType(AnyType type)Write a value type.(package private) voidwriteVarint(long value)Write an integer value.(package private) voidwriteVaruint32(int value)Write an unsigned integer.-
Methods inherited from class de.inetsoftware.jwebassembly.wasm.LittleEndianOutputStream
reset, size, write, write, writeInt32, writeTo
-
-
-
-
Field Detail
-
options
private final WasmOptions options
-
-
Constructor Detail
-
WasmOutputStream
WasmOutputStream(WasmOptions options)
Create a in memory stream.- Parameters:
options- compiler properties
-
WasmOutputStream
WasmOutputStream(WasmOptions options, java.io.OutputStream output)
Create a wrapped stream.- Parameters:
output- the target of dataoptions- compiler properties
-
-
Method Detail
-
writeOpCode
public void writeOpCode(int op) throws java.io.IOExceptionWrite a binary operation code.- Parameters:
op- a constant fromInstructionOpcodes- Throws:
java.io.IOException- if an I/O error occurs.
-
writeValueType
public void writeValueType(AnyType type) throws java.io.IOException
Write a value type.- Parameters:
type- a type constant- Throws:
java.io.IOException- if an I/O error occurs.
-
writeRefValueType
public void writeRefValueType(AnyType type) throws java.io.IOException
Write the value type. If it is a struct type then as reference type.- Parameters:
type- a type constant- Throws:
java.io.IOException- if an I/O error occurs.
-
writeDefaultValue
public void writeDefaultValue(AnyType type) throws java.io.IOException
Write the default/initial value for a type.- Parameters:
type- the type- Throws:
java.io.IOException- if an I/O error occurs.
-
writeVaruint32
void writeVaruint32(@Nonnegative int value) throws java.io.IOExceptionWrite an unsigned integer.- Parameters:
value- the value- Throws:
java.io.IOException- if an I/O error occurs.
-
writeVarint
void writeVarint(long value) throws java.io.IOExceptionWrite an integer value.- Parameters:
value- the value- Throws:
java.io.IOException- if an I/O error occurs.
-
writeFloat
void writeFloat(float value) throws java.io.IOExceptionWrite an float value.- Parameters:
value- the value- Throws:
java.io.IOException- if an I/O error occurs.
-
writeDouble
void writeDouble(double value) throws java.io.IOExceptionWrite an double value.- Parameters:
value- the value- Throws:
java.io.IOException- if an I/O error occurs.
-
writeConst
void writeConst(java.lang.Number value, ValueType valueType) throws java.io.IOExceptionWrite a constant number value- Parameters:
value- the valuevalueType- the data type of the number- Throws:
java.io.IOException- if any I/O error occur
-
writeString
void writeString(@Nonnull java.lang.String str) throws java.io.IOExceptionWrite a string as UTF8 encoded.- Parameters:
str- the string- Throws:
java.io.IOException- if any I/O error occur
-
writeSection
void writeSection(SectionType type, WasmOutputStream data) throws java.io.IOException
Write a section with header and data.- Parameters:
type- the name of the sectiondata- the data of the section- Throws:
java.io.IOException- if any I/O error occur
-
-