mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
implements class name for array objects
This commit is contained in:
parent
f785c1025d
commit
13e99875b0
@ -641,10 +641,10 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
||||
int typeValue = byteCode.readByte();
|
||||
switch( typeValue ) {
|
||||
case 4: // boolean
|
||||
type = ValueType.i8;
|
||||
type = ValueType.bool;
|
||||
break;
|
||||
case 5: // char
|
||||
type = ValueType.i16;
|
||||
type = ValueType.u16;
|
||||
break;
|
||||
case 6: //float
|
||||
type = ValueType.f32;
|
||||
|
@ -248,10 +248,13 @@ public class TypeManager {
|
||||
if( !arrayType.isRefType() ) {
|
||||
// see ReplacementForClass.getPrimitiveClass(String)
|
||||
switch( (ValueType)arrayType ) {
|
||||
case bool:
|
||||
componentClassIndex = 0;
|
||||
break;
|
||||
case i8:
|
||||
componentClassIndex = 1;
|
||||
break;
|
||||
case i16:
|
||||
case u16:
|
||||
componentClassIndex = 2;
|
||||
break;
|
||||
case f64:
|
||||
@ -266,6 +269,9 @@ public class TypeManager {
|
||||
case i64:
|
||||
componentClassIndex = 6;
|
||||
break;
|
||||
case i16:
|
||||
componentClassIndex = 7;
|
||||
break;
|
||||
case externref:
|
||||
componentClassIndex = valueOf( "java/lang/Object" ).classIndex;
|
||||
break;
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package de.inetsoftware.jwebassembly.wasm;
|
||||
|
||||
import de.inetsoftware.jwebassembly.WasmException;
|
||||
import de.inetsoftware.jwebassembly.module.TypeManager.StructType;
|
||||
|
||||
/**
|
||||
@ -40,12 +41,46 @@ public class ArrayType extends StructType {
|
||||
* the running index of the component/array class/type
|
||||
*/
|
||||
public ArrayType( AnyType arrayType, int classIndex, int componentClassIndex ) {
|
||||
//TODO name
|
||||
super( "[", classIndex );
|
||||
super( getJavaClassName( arrayType ), classIndex );
|
||||
this.arrayType = arrayType;
|
||||
this.componentClassIndex = componentClassIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create class name for the array class.
|
||||
*
|
||||
* @param arrayType
|
||||
* the type of the array
|
||||
* @return the name
|
||||
*/
|
||||
private static String getJavaClassName( AnyType arrayType ) {
|
||||
if( !arrayType.isRefType() ) {
|
||||
switch( (ValueType)arrayType ) {
|
||||
case bool:
|
||||
return "[Z";
|
||||
case i8:
|
||||
return "[B";
|
||||
case i16:
|
||||
return "[S";
|
||||
case u16:
|
||||
return "[C";
|
||||
case f64:
|
||||
return "[D";
|
||||
case f32:
|
||||
return "[F";
|
||||
case i32:
|
||||
return "[I";
|
||||
case i64:
|
||||
return "[J";
|
||||
case externref:
|
||||
return "[Ljava.lang.Object;";
|
||||
default:
|
||||
throw new WasmException( "Not supported array type: " + arrayType, -1 );
|
||||
}
|
||||
}
|
||||
return "[" + ((StructType)arrayType).getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* The element type of the array
|
||||
* @return the type
|
||||
|
@ -24,8 +24,10 @@ public enum ValueType implements AnyType {
|
||||
f32(-0x03),
|
||||
f64(-0x04),
|
||||
v128(-0x05),
|
||||
bool(-0x06),
|
||||
i8(-0x06),
|
||||
i16(-0x07),
|
||||
u16(-0x07),
|
||||
funcref(-0x10),
|
||||
externref(-0x11),
|
||||
anyref(-0x12),
|
||||
|
@ -87,9 +87,11 @@ public class ValueTypeParser implements Iterator<AnyType> {
|
||||
idx = idx2 + 1;
|
||||
return types.valueOf( name );
|
||||
case 'Z': // boolean
|
||||
return isArray ? ValueType.bool : ValueType.i32;
|
||||
case 'B': // byte
|
||||
return isArray ? ValueType.i8 : ValueType.i32;
|
||||
case 'C': // char
|
||||
return isArray ? ValueType.u16 : ValueType.i32;
|
||||
case 'S': // short
|
||||
return isArray ? ValueType.i16 : ValueType.i32;
|
||||
case 'I': // int
|
||||
|
Loading…
x
Reference in New Issue
Block a user