mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
implement CAST operation, WIP
This commit is contained in:
parent
8c12f5a3c9
commit
5410764249
@ -653,10 +653,12 @@ class JavaMethodWasmCodeBuilder extends WasmCodeBuilder {
|
||||
case 191: // athrow
|
||||
addBlockInstruction( WasmBlockOperator.THROW, null, codePos, lineNumber );
|
||||
break;
|
||||
//TODO case 192: // checkcast
|
||||
case 192: // checkcast
|
||||
name = ((ConstantClass)constantPool.get( byteCode.readUnsignedShort() )).getName();
|
||||
addStructInstruction( StructOperator.CAST, name, null, codePos, lineNumber );
|
||||
break;
|
||||
case 193: // instanceof
|
||||
idx = byteCode.readUnsignedShort();
|
||||
name = ((ConstantClass)constantPool.get( idx )).getName();
|
||||
name = ((ConstantClass)constantPool.get( byteCode.readUnsignedShort() )).getName();
|
||||
addStructInstruction( StructOperator.INSTANCEOF, name, null, codePos, lineNumber );
|
||||
break;
|
||||
case 194: // monitorenter
|
||||
|
@ -203,6 +203,7 @@ class WasmStructInstruction extends WasmInstruction {
|
||||
return ValueType.anyref;
|
||||
case NEW:
|
||||
case NEW_DEFAULT:
|
||||
case CAST:
|
||||
return type;
|
||||
case GET:
|
||||
return fieldName.getType();
|
||||
@ -223,6 +224,7 @@ class WasmStructInstruction extends WasmInstruction {
|
||||
switch( op ) {
|
||||
case GET:
|
||||
case INSTANCEOF:
|
||||
case CAST:
|
||||
return 1;
|
||||
case SET:
|
||||
return 2;
|
||||
|
@ -27,5 +27,6 @@ public enum StructOperator {
|
||||
GET,
|
||||
SET,
|
||||
NULL,
|
||||
CAST,
|
||||
INSTANCEOF,
|
||||
}
|
@ -76,7 +76,6 @@ public class RuntimeErrors {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void nonStaticImport() throws IOException {
|
||||
compileErrorTest( "Import method must be static:", NonStaticImport.class );
|
||||
@ -127,7 +126,6 @@ public class RuntimeErrors {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void instanceofCall() throws IOException {
|
||||
compileErrorTest( "Unknown operator: INSTANCEOF", InstanceofMethod.class );
|
||||
@ -140,4 +138,17 @@ public class RuntimeErrors {
|
||||
return obj instanceof Integer;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkcast() throws IOException {
|
||||
compileErrorTest( "Unknown operator: CAST", CheckcastMethod.class );
|
||||
}
|
||||
|
||||
static class CheckcastMethod {
|
||||
@Export
|
||||
static Integer runnable() {
|
||||
Object obj = new Integer(0);
|
||||
return (Integer)obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user