Class WatParser
java.lang.Object
de.inetsoftware.jwebassembly.module.WasmCodeBuilder
de.inetsoftware.jwebassembly.watparser.WatParser
Parser for text format of a function.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate int
addMemoryInstruction
(MemoryOperator op, ValueType type, List<String> tokens, int i, int lineNumber) Parse the optional tokens of a load memory instruction and add it.private String
Get the token at given positionprivate int
Get the token at given position as int.void
parse
(String wat, MethodInfo method, Iterator<AnyType> signature, int lineNumber) Parse the given wasm text format and generate a list of WasmInstuctionssplitTokens
(String wat) Split the string in tokens.Methods inherited from class de.inetsoftware.jwebassembly.module.WasmCodeBuilder
addArrayInstruction, addBlockInstruction, addCallInstruction, addCallInterfaceInstruction, addCallVirtualInstruction, addConstInstruction, addConstInstruction, addConvertInstruction, addDupInstruction, addDupX1Instruction, addDupX2Instruction, addGlobalInstruction, addGlobalInstruction, addInvokeDynamic, addJumpPlaceholder, addLoadStoreInstruction, addLocalInstruction, addMemoryInstruction, addMultiNewArrayInstruction, addMultiNewArrayInstruction, addNopInstruction, addNumericInstruction, addStructInstruction, addTableInstruction, calculateVariables, getTypeManager, reset
-
Constructor Details
-
WatParser
public WatParser()
-
-
Method Details
-
parse
Parse the given wasm text format and generate a list of WasmInstuctions- Parameters:
wat
- the text format content of a functionmethod
- the method with signature as fallback for a missing variable tablesignature
- alternative for method signature, can be null if method is setlineNumber
- the line number for an error message
-
getInt
Get the token at given position as int.- Parameters:
tokens
- the token listidx
- the position in the tokens- Returns:
- the int value
-
get
Get the token at given position- Parameters:
tokens
- the token listidx
- the position in the tokens- Returns:
- the token
-
splitTokens
Split the string in tokens.- Parameters:
wat
- string with wasm text format- Returns:
- the token list.
-
addMemoryInstruction
private int addMemoryInstruction(MemoryOperator op, ValueType type, List<String> tokens, int i, int lineNumber) Parse the optional tokens of a load memory instruction and add it.- Parameters:
op
- the operationtype
- the type of the static fieldtokens
- the token listi
- the position in the tokenslineNumber
- the line number in the Java source code- Returns:
- the current index to the tokens
-