Class TypeManager
java.lang.Object
de.inetsoftware.jwebassembly.module.TypeManager
Manage the written and to write types (classes)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA type that can use for a block(package private) classA generated type that represent a lambda expressionstatic classA reference to a type.static enumThe kind of type -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<TypeManager.BlockType, TypeManager.BlockType> static final intType id of primitive classstatic final intType id of primitive classstatic final intType id of primitive classprivate static final FunctionNameprivate ClassFileLoaderstatic final intType id of primitive class(package private) static final StringName of field with system hash code, start with a point for an invalid Java identifier.static final StringName of field with array value.(package private) static final Stringname of virtual function table, start with a point for an invalid Java identifierstatic final intType id of primitive classstatic final intType id of primitive classprivate booleanstatic final intType id of primitive class(package private) final WasmOptionsprivate static final String[]the list of primitive types.static final intType id of primitive classprivate final Map<Object, TypeManager.StructType> static final intByte position in the type description that contains the type of the array (component type).static final intByte position in the type description that contains the offset to the instanceof list.static final intByte position in the type description that contains the offset to the interfaces.static final intByte position in the type description that contains the offset to class name idx in the string constant table.private intprivate intstatic final intType id of primitive classprivate static final intThe reserved position on start of the vtable: offset of interface call table (itable) offset of instanceof list offset of class name idx in the string constant table -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the array type for the given component type.(package private) TypeManager.BlockTypeCreate block typeprivate voidcheckStructTypesState(Object newType) Check the internal state of the manager and create initial classes.(package private) WatCodeSyntheticFunctionNameCreate the FunctionName for a interface call.(package private) WatCodeSyntheticFunctionNameCreate the FunctionName for a virtual call.(package private) WatCodeSyntheticFunctionNameCreate the FunctionName for the CAST operation and mark it as used.(package private) WatCodeSyntheticFunctionNameCreate the FunctionName for the INSTANCEOF operation and mark it as used.(package private) FunctionNameGet the function name to get a constant class.(package private) WatCodeSyntheticFunctionNameCreate an accessor for typeTableOffset and mark it.(package private) voidinit(ClassFileLoader classFileLoader) Initialize the type manager(package private) booleanisFinish()If the scan phase is finish(package private) TypeManager.LambdaTypelambdaType(BootstrapMethod method, ArrayList<AnyType> params, TypeManager.StructType interfaceType, String interfaceMethodName) Create a lambda type(package private) voidprepareFinish(ModuleWriter writer) Finish the prepare and write the types.(package private) voidScan the hierarchy of the types.intsize()Count of used typesGet the StructType.
-
Field Details
-
FIELD_VTABLE
name of virtual function table, start with a point for an invalid Java identifier- See Also:
-
FIELD_HASHCODE
Name of field with system hash code, start with a point for an invalid Java identifier.- See Also:
-
FIELD_VALUE
-
TYPE_DESCRIPTION_INTERFACE_OFFSET
public static final int TYPE_DESCRIPTION_INTERFACE_OFFSETByte position in the type description that contains the offset to the interfaces. Length 4 bytes.- See Also:
-
TYPE_DESCRIPTION_INSTANCEOF_OFFSET
public static final int TYPE_DESCRIPTION_INSTANCEOF_OFFSETByte position in the type description that contains the offset to the instanceof list. Length 4 bytes.- See Also:
-
TYPE_DESCRIPTION_TYPE_NAME
public static final int TYPE_DESCRIPTION_TYPE_NAMEByte position in the type description that contains the offset to class name idx in the string constant table. Length 4 bytes.- See Also:
-
TYPE_DESCRIPTION_ARRAY_TYPE
public static final int TYPE_DESCRIPTION_ARRAY_TYPEByte position in the type description that contains the type of the array (component type). Length 4 bytes.- See Also:
-
VTABLE_FIRST_FUNCTION_INDEX
private static final int VTABLE_FIRST_FUNCTION_INDEXThe reserved position on start of the vtable:- offset of interface call table (itable)
- offset of instanceof list
- offset of class name idx in the string constant table
- See Also:
-
CLASS_CONSTANT_FUNCTION
-
BOOLEAN
public static final int BOOLEANType id of primitive class- See Also:
-
BYTE
public static final int BYTEType id of primitive class- See Also:
-
CHAR
public static final int CHARType id of primitive class- See Also:
-
DOUBLE
public static final int DOUBLEType id of primitive class- See Also:
-
FLOAT
public static final int FLOATType id of primitive class- See Also:
-
INT
public static final int INTType id of primitive class- See Also:
-
LONG
public static final int LONGType id of primitive class- See Also:
-
SHORT
public static final int SHORTType id of primitive class- See Also:
-
VOID
public static final int VOIDType id of primitive class- See Also:
-
PRIMITIVE_CLASSES
the list of primitive types. The order is important and must correlate with getPrimitiveClass.- See Also:
-
structTypes
-
blockTypes
-
typeIndexCounter
private int typeIndexCounter -
isFinish
private boolean isFinish -
options
-
typeTableOffset
private int typeTableOffset -
classFileLoader
-
-
Constructor Details
-
TypeManager
TypeManager(WasmOptions options) Initialize the type manager.- Parameters:
options- compiler properties
-
-
Method Details
-
init
Initialize the type manager- Parameters:
classFileLoader- for loading the class files
-
size
public int size()Count of used types- Returns:
- the count
-
isFinish
boolean isFinish()If the scan phase is finish- Returns:
- true, if scan phase is finish
-
scanTypeHierarchy
Scan the hierarchy of the types.- Throws:
IOException- if any I/O error occur on loading or writing
-
prepareFinish
Finish the prepare and write the types. Now no new types and functions should be added.- Parameters:
writer- the targets for the types- Throws:
IOException- if any I/O error occur on loading or writing
-
getTypeTableMemoryOffsetFunctionName
WatCodeSyntheticFunctionName getTypeTableMemoryOffsetFunctionName()Create an accessor for typeTableOffset and mark it.- Returns:
- the function name
-
getClassConstantFunction
Get the function name to get a constant class.- Returns:
- the function
-
checkStructTypesState
Check the internal state of the manager and create initial classes.- Parameters:
newType- the requested type for debug output
-
valueOf
Get the StructType. If needed an instance is created.- Parameters:
name- the type name like java/lang/Object- Returns:
- the struct type
-
arrayType
-
lambdaType
TypeManager.LambdaType lambdaType(@Nonnull BootstrapMethod method, ArrayList<AnyType> params, TypeManager.StructType interfaceType, String interfaceMethodName) Create a lambda type- Parameters:
method- the name BootstrapMethod from the parsed class fileparams- the parameters of the constructor and type fieldsinterfaceType- the implemented interfaceinterfaceMethodName- the name of the implemented method in the interface- Returns:
- the type
-
blockType
-
createCallVirtual
Create the FunctionName for a virtual call. The function has 2 parameters (THIS, virtualfunctionIndex) and returns the index of the function.- Returns:
- the name
-
createCallInterface
Create the FunctionName for a interface call. The function has 3 parameters (THIS,classIndex, virtualfunctionIndex) and returns the index of the function.- Returns:
- the name
-
createInstanceOf
WatCodeSyntheticFunctionName createInstanceOf()Create the FunctionName for the INSTANCEOF operation and mark it as used. The function has 2 parameters (THIS, classIndex) and returns true if there is a match.- Returns:
- the name
-
createCast
WatCodeSyntheticFunctionName createCast()Create the FunctionName for the CAST operation and mark it as used. The function has 2 parameters (THIS, classIndex) and returns this if the type match else it throw an exception.- Returns:
- the name
-