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 class
The state of a single local variable slot. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private TypeManager
private LocaleVariableManager.Variable[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
Calculate the WebAssembly index position on the consumed data.private void
ensureCapacity
(int slot) Ensure that there is enough capacity.(package private) void
expandUse
(int slot, int javaCodePos) Expand code range for which the variable is validprivate String
findUniqueVarName
(String name) Find a unique variable name.(package private) int
get
(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) String
getLocalName
(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) int
getTempVariable
(AnyType valueType, int startCodePosition, int endCodePosition) Get the slot of the temporary variable.(package private) AnyType
getValueType
(int idx) Get the ValueType of the variable.(package private) void
init
(TypeManager types) Initialize the variable manager;(package private) void
reset
(LocalVariableTable variableTable, MethodInfo method, Iterator<AnyType> signature) Reset the manager to an initial state.private void
resetAddVar
(AnyType type, int slot) Add a variable in the reset with range.(package private) void
Set a previous copy(package private) void
Mark 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
Initialize the variable manager;- Parameters:
types
- the type manager
-
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
Find a unique variable name.- Parameters:
name
- the suggested name- Returns:
- a name that not was used before
-
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
Get the data types of the local variables. The value is only valid until the next call.- Parameters:
paramCount
- the count of method parameter which should be exclude- Returns:
- the reused list with fresh values
-
getLocalName
Get the name of the variable or null if no name available- Parameters:
idx
- the wasm variable index- Returns:
- the name
-
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
-