Package com.dylibso.chicory.wasm
Class Parser
- java.lang.Object
-
- com.dylibso.chicory.wasm.Parser
-
public final class Parser extends Object
Parser for Web Assembly binaries.
-
-
Field Summary
Fields Modifier and Type Field Description static longMAX_SIGNED_INTstatic longMAX_SIGNED_LONGstatic longMAX_UNSIGNED_INTstatic longMIN_SIGNED_INTstatic longMIN_SIGNED_LONGstatic longMIN_UNSIGNED_INT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidincludeSection(int sectionId)ModuleparseModule(InputStream in)static longreadFloat32(ByteBuffer buffer)Read a F32 from the buffer which fits neatly into a long.static longreadFloat64(ByteBuffer buffer)Read a F64 from the buffer which fits neatly into a long.static StringreadName(ByteBuffer buffer)Read a symbol name from the buffer as UTF-8 String.static StringreadName(ByteBuffer buffer, boolean checkMalformed)static longreadVarSInt32(ByteBuffer buffer)Read a signed I32 from the buffer.static longreadVarSInt64(ByteBuffer buffer)Read a signed I64 from the buffer which fits neatly into a long.static longreadVarUInt32(ByteBuffer buffer)Read an unsigned I32 from the buffer.
-
-
-
Field Detail
-
MIN_SIGNED_INT
public static final long MIN_SIGNED_INT
- See Also:
- Constant Field Values
-
MAX_SIGNED_INT
public static final long MAX_SIGNED_INT
- See Also:
- Constant Field Values
-
MIN_UNSIGNED_INT
public static final long MIN_UNSIGNED_INT
- See Also:
- Constant Field Values
-
MAX_UNSIGNED_INT
public static final long MAX_UNSIGNED_INT
- See Also:
- Constant Field Values
-
MIN_SIGNED_LONG
public static final long MIN_SIGNED_LONG
- See Also:
- Constant Field Values
-
MAX_SIGNED_LONG
public static final long MAX_SIGNED_LONG
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseModule
public Module parseModule(InputStream in)
-
includeSection
public void includeSection(int sectionId)
-
readVarUInt32
public static long readVarUInt32(ByteBuffer buffer)
Read an unsigned I32 from the buffer. We can't fit an unsigned 32bit int into a java int, so we must use a long. See 2.2.2. Integers of the WebAssembly Core Specification.- Parameters:
buffer- the byte buffer- Returns:
- the resulting long
-
readVarSInt32
public static long readVarSInt32(ByteBuffer buffer)
Read a signed I32 from the buffer. We can't fit an unsigned 32bit int into a java int, so we must use a long to use the same type as unsigned. See 2.2.2. Integers of the WebAssembly Core Specification.- Parameters:
buffer- the byte buffer- Returns:
- the resulting long
-
readVarSInt64
public static long readVarSInt64(ByteBuffer buffer)
Read a signed I64 from the buffer which fits neatly into a long. See 2.2.2. Integers of the WebAssembly Core Specification.- Parameters:
buffer- the byte buffer- Returns:
- the resulting long
-
readFloat64
public static long readFloat64(ByteBuffer buffer)
Read a F64 from the buffer which fits neatly into a long. See 2.2.3. Floating-Point of the WebAssembly Core Specification.- Parameters:
buffer- the byte buffer- Returns:
- the resulting long
-
readFloat32
public static long readFloat32(ByteBuffer buffer)
Read a F32 from the buffer which fits neatly into a long. See 2.2.3. Floating-Point of the WebAssembly Core Specification.- Parameters:
buffer- the byte buffer- Returns:
- the resulting long
-
readName
public static String readName(ByteBuffer buffer)
Read a symbol name from the buffer as UTF-8 String. See 2.2.4. Names of the WebAssembly Core Specification.- Parameters:
buffer- the byte buffer- Returns:
- the resulting long
-
readName
public static String readName(ByteBuffer buffer, boolean checkMalformed)
-
-