declare array types only once; add "value" field to array with GC objects

This commit is contained in:
Volker Berlin 2020-08-09 15:24:10 +02:00
parent 54ad287ed6
commit 28b03b05c2

View File

@ -59,6 +59,11 @@ public class TypeManager {
*/
static final String FIELD_HASHCODE = ".hashcode";
/**
* Name of field with array value.
*/
static final String FIELD_VALUE = ".val";
/**
* Byte position in the type description that contains the offset to the interfaces. Length 4 bytes.
*/
@ -225,13 +230,13 @@ public class TypeManager {
public StructType valueOf( String name ) {
StructType type = structTypes.get( name );
if( type == null ) {
checkStructTypesState( name );
if( name.startsWith( "[" ) ) {
type = (StructType)new ValueTypeParser( name, options.types ).next();
return (StructType)new ValueTypeParser( name, options.types ).next();
} else {
checkStructTypesState( name );
type = new StructType( name, structTypes.size() );
}
structTypes.put( name, type );
}
return type;
@ -583,6 +588,9 @@ public class TypeManager {
} else {
fields.add( new NamedStorageType( ValueType.i32, className, FIELD_VTABLE ) );
fields.add( new NamedStorageType( ValueType.i32, className, FIELD_HASHCODE ) );
if( getComponentClassIndex() >= 0 ) {
fields.add( new NamedStorageType( this, className, FIELD_VALUE ) );
}
}
// list all fields