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 WasmOptions
options
-
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) void
writeConst(java.lang.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(java.lang.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
-
-
-
-
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.IOException
Write 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.IOException
Write 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.IOException
Write 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.IOException
Write 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.IOException
Write 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.IOException
Write 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.IOException
Write 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
-
-