Class LocaleVariableManager
java.lang.Object
de.inetsoftware.jwebassembly.module.LocaleVariableManager
This manager monitor the locale variables of a method to create a translation from the slot based index in Java to
the variable based index in WebAssembly. An 8-byte variable of type long and double consumes in Java 2 slots, but
only one index in WebAssmenbly.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classThe state of a single local variable slot. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate TypeManagerprivate LocaleVariableManager.Variable[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidCalculate the WebAssembly index position on the consumed data.private voidensureCapacity(int slot) Ensure that there is enough capacity.(package private) voidexpandUse(int slot, int javaCodePos) Expand code range for which the variable is validprivate StringfindUniqueVarName(String name) Find a unique variable name.(package private) intget(int slot, int javaCodePos) Get the WebAssembly variable index of the given Java Slot.(package private) LocaleVariableManager.Variable[]getCopy()Create a copy of the internal state(package private) StringgetLocalName(int idx) Get the name of the variable or null if no name availablegetLocalTypes(int paramCount) Get the data types of the local variables.(package private) intgetTempVariable(AnyType valueType, int startCodePosition, int endCodePosition) Get the slot of the temporary variable.(package private) AnyTypegetValueType(int idx) Get the ValueType of the variable.(package private) voidinit(TypeManager types) Initialize the variable manager;(package private) voidreset(LocalVariableTable variableTable, MethodInfo method, Iterator<AnyType> signature) Reset the manager to an initial state.private voidresetAddVar(AnyType type, int slot) Add a variable in the reset with range.(package private) voidSet a previous copy(package private) voidMark a variable slot as used with its type.private void(package private) void
-
Field Details
-
types
-
variables
-
size
private int size -
localTypes
-
names
-
-
Constructor Details
-
LocaleVariableManager
LocaleVariableManager()Create a new instance.
-
-
Method Details
-
init
-
reset
Reset the manager to an initial state.- Parameters:
variableTable- variable table of the Java method.method- the method with signature as fallback for a missing variable table. If null signature is used and the method must be static.signature- alternative for method signature, can be null if method is set
-
resetAddVar
Add a variable in the reset with range.- Parameters:
type- the type of the variableslot- the slot of the variable
-
findUniqueVarName
-
use
Mark a variable slot as used with its type.- Parameters:
valueType- the type of the local variableslot- the memory/slot index of the local variablejavaCodePos- the code position/offset in the Java method
-
useImpl
-
useIndex
-
calculate
void calculate()Calculate the WebAssembly index position on the consumed data. -
getLocalTypes
-
getLocalName
-
getTempVariable
Get the slot of the temporary variable.- Parameters:
valueType- the valueType for the variablestartCodePosition- the start of the Java code positionendCodePosition- the end of the Java code position- Returns:
- the slot
-
expandUse
void expandUse(int slot, int javaCodePos) Expand code range for which the variable is valid- Parameters:
slot- the memory/slot index of the local variablejavaCodePos- the new end code position in the Java method
-
get
int get(int slot, int javaCodePos) Get the WebAssembly variable index of the given Java Slot.- Parameters:
slot- the memory/slot index of the local variable in JavajavaCodePos- the current code position in the Java method- Returns:
- the variable index in WebAssembly
-
getValueType
Get the ValueType of the variable.- Parameters:
idx- the index of the local variable in WASM- Returns:
- the ValueType
-
getCopy
Create a copy of the internal state- Returns:
- the state
-
setCopy
Set a previous copy- Parameters:
copy- the previous state
-
ensureCapacity
private void ensureCapacity(int slot) Ensure that there is enough capacity.- Parameters:
slot- the needed slot
-