diff --git a/src/de/inetsoftware/jwebassembly/module/TypeManager.java b/src/de/inetsoftware/jwebassembly/module/TypeManager.java index 6c8e6a8..d82ed3e 100644 --- a/src/de/inetsoftware/jwebassembly/module/TypeManager.java +++ b/src/de/inetsoftware/jwebassembly/module/TypeManager.java @@ -803,6 +803,15 @@ public class TypeManager { return classIndex; } + /** + * The running index of the component/array class/type for class meta data, instanceof and interface calls. + * + * @return the unique index or -1 id not an array + */ + protected int getComponentClassIndex() { + return -1; + } + /** * Get the fields of this struct * @return the fields @@ -885,7 +894,7 @@ public class TypeManager { header.writeInt32( classNameIdx ); // string id of the className // header position TYPE_DESCRIPTION_ARRAY_TYPE - header.writeInt32( -1 ); + header.writeInt32( getComponentClassIndex() ); data.writeTo( dataStream ); } diff --git a/src/de/inetsoftware/jwebassembly/wasm/ArrayType.java b/src/de/inetsoftware/jwebassembly/wasm/ArrayType.java index 1323461..6c70950 100644 --- a/src/de/inetsoftware/jwebassembly/wasm/ArrayType.java +++ b/src/de/inetsoftware/jwebassembly/wasm/ArrayType.java @@ -27,6 +27,8 @@ public class ArrayType extends StructType { private AnyType arrayType; + private int componentClassIndex; + /** * Create a new array type * @@ -41,6 +43,7 @@ public class ArrayType extends StructType { //TODO name super( "[", classIndex ); this.arrayType = arrayType; + this.componentClassIndex = componentClassIndex; } /** @@ -51,6 +54,14 @@ public class ArrayType extends StructType { return arrayType; } + /** + * {@inheritDoc} + */ + @Override + protected int getComponentClassIndex() { + return componentClassIndex; + } + /** * {@inheritDoc} */