Class StringManager
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<java.lang.String,java.lang.Integer>
-
- de.inetsoftware.jwebassembly.module.StringManager
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.String,java.lang.Integer>
public class StringManager extends java.util.LinkedHashMap<java.lang.String,java.lang.Integer>
Handle all the constant strings. The constant strings will be write into the data section. At runtime the strings will be instantiate on the fly and hold in a table.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private FunctionManager
functions
private FunctionName
stringConstantFunction
private int
stringMemoryOffset
-
Constructor Summary
Constructors Constructor Description StringManager(WasmOptions options)
Create a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Integer
get(java.lang.Object str)
Get the positive id for the string.(package private) FunctionName
getStringConstantFunction()
Get the function name object for the#stringConstant(int)
.(package private) void
prepareFinish(ModuleWriter writer)
Finish the prepare.private static void
writeVaruint32(int value, java.io.OutputStream out)
Write an unsigned integer.-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
-
-
-
Field Detail
-
stringConstantFunction
private FunctionName stringConstantFunction
-
functions
private FunctionManager functions
-
stringMemoryOffset
private int stringMemoryOffset
-
-
Constructor Detail
-
StringManager
StringManager(WasmOptions options)
Create a new instance.- Parameters:
options
- compiler properties and shared managers
-
-
Method Detail
-
get
public java.lang.Integer get(@Nonnull java.lang.Object str)
Get the positive id for the string.- Specified by:
get
in interfacejava.util.Map<java.lang.String,java.lang.Integer>
- Overrides:
get
in classjava.util.LinkedHashMap<java.lang.String,java.lang.Integer>
- Parameters:
str
- the string- Returns:
- the id
-
getStringConstantFunction
@Nonnull FunctionName getStringConstantFunction()
Get the function name object for the#stringConstant(int)
.- Returns:
- the name
- See Also:
#stringConstant(int)
-
prepareFinish
void prepareFinish(ModuleWriter writer) throws java.io.IOException
Finish the prepare. Now no new strings should be added.- Parameters:
writer
- the targets for the strings- Throws:
java.io.IOException
- if any I/O error occur
-
writeVaruint32
private static void writeVaruint32(@Nonnegative int value, java.io.OutputStream out) throws java.io.IOException
Write an unsigned integer.- Parameters:
value
- the valueout
- target stream- Throws:
java.io.IOException
- if an I/O error occurs.
-
-