mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +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();
|
int typeValue = byteCode.readByte();
|
||||||
switch( typeValue ) {
|
switch( typeValue ) {
|
||||||
case 4: // boolean
|
case 4: // boolean
|
||||||
type = ValueType.i8;
|
type = ValueType.bool;
|
||||||
break;
|
break;
|
||||||
case 5: // char
|
case 5: // char
|
||||||
type = ValueType.i16;
|
type = ValueType.u16;
|
||||||
break;
|
break;
|
||||||
case 6: //float
|
case 6: //float
|
||||||
type = ValueType.f32;
|
type = ValueType.f32;
|
||||||
|
@ -248,10 +248,13 @@ public class TypeManager {
|
|||||||
if( !arrayType.isRefType() ) {
|
if( !arrayType.isRefType() ) {
|
||||||
// see ReplacementForClass.getPrimitiveClass(String)
|
// see ReplacementForClass.getPrimitiveClass(String)
|
||||||
switch( (ValueType)arrayType ) {
|
switch( (ValueType)arrayType ) {
|
||||||
|
case bool:
|
||||||
|
componentClassIndex = 0;
|
||||||
|
break;
|
||||||
case i8:
|
case i8:
|
||||||
componentClassIndex = 1;
|
componentClassIndex = 1;
|
||||||
break;
|
break;
|
||||||
case i16:
|
case u16:
|
||||||
componentClassIndex = 2;
|
componentClassIndex = 2;
|
||||||
break;
|
break;
|
||||||
case f64:
|
case f64:
|
||||||
@ -266,6 +269,9 @@ public class TypeManager {
|
|||||||
case i64:
|
case i64:
|
||||||
componentClassIndex = 6;
|
componentClassIndex = 6;
|
||||||
break;
|
break;
|
||||||
|
case i16:
|
||||||
|
componentClassIndex = 7;
|
||||||
|
break;
|
||||||
case externref:
|
case externref:
|
||||||
componentClassIndex = valueOf( "java/lang/Object" ).classIndex;
|
componentClassIndex = valueOf( "java/lang/Object" ).classIndex;
|
||||||
break;
|
break;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.inetsoftware.jwebassembly.wasm;
|
package de.inetsoftware.jwebassembly.wasm;
|
||||||
|
|
||||||
|
import de.inetsoftware.jwebassembly.WasmException;
|
||||||
import de.inetsoftware.jwebassembly.module.TypeManager.StructType;
|
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
|
* the running index of the component/array class/type
|
||||||
*/
|
*/
|
||||||
public ArrayType( AnyType arrayType, int classIndex, int componentClassIndex ) {
|
public ArrayType( AnyType arrayType, int classIndex, int componentClassIndex ) {
|
||||||
//TODO name
|
super( getJavaClassName( arrayType ), classIndex );
|
||||||
super( "[", classIndex );
|
|
||||||
this.arrayType = arrayType;
|
this.arrayType = arrayType;
|
||||||
this.componentClassIndex = componentClassIndex;
|
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
|
* The element type of the array
|
||||||
* @return the type
|
* @return the type
|
||||||
|
@ -24,8 +24,10 @@ public enum ValueType implements AnyType {
|
|||||||
f32(-0x03),
|
f32(-0x03),
|
||||||
f64(-0x04),
|
f64(-0x04),
|
||||||
v128(-0x05),
|
v128(-0x05),
|
||||||
|
bool(-0x06),
|
||||||
i8(-0x06),
|
i8(-0x06),
|
||||||
i16(-0x07),
|
i16(-0x07),
|
||||||
|
u16(-0x07),
|
||||||
funcref(-0x10),
|
funcref(-0x10),
|
||||||
externref(-0x11),
|
externref(-0x11),
|
||||||
anyref(-0x12),
|
anyref(-0x12),
|
||||||
|
@ -87,9 +87,11 @@ public class ValueTypeParser implements Iterator<AnyType> {
|
|||||||
idx = idx2 + 1;
|
idx = idx2 + 1;
|
||||||
return types.valueOf( name );
|
return types.valueOf( name );
|
||||||
case 'Z': // boolean
|
case 'Z': // boolean
|
||||||
|
return isArray ? ValueType.bool : ValueType.i32;
|
||||||
case 'B': // byte
|
case 'B': // byte
|
||||||
return isArray ? ValueType.i8 : ValueType.i32;
|
return isArray ? ValueType.i8 : ValueType.i32;
|
||||||
case 'C': // char
|
case 'C': // char
|
||||||
|
return isArray ? ValueType.u16 : ValueType.i32;
|
||||||
case 'S': // short
|
case 'S': // short
|
||||||
return isArray ? ValueType.i16 : ValueType.i32;
|
return isArray ? ValueType.i16 : ValueType.i32;
|
||||||
case 'I': // int
|
case 'I': // int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user