add support for inc/dec

This commit is contained in:
Volker Berlin 2017-04-16 11:28:11 +02:00
parent 65c83c8f4b
commit 28d4fb9b1c
2 changed files with 10 additions and 1 deletions

View File

@ -395,6 +395,13 @@ public abstract class ModuleWriter implements Closeable {
case 114: // frem
case 115: // drem
throw new WasmException( "Modulo/Remainder for floating numbers is not supported in WASM. Use int or long data types." + op, sourceFile, lineNumber );
case 132: // iinc
int idx = byteCode.readUnsignedByte();
writeLoadStore( true, ValueType.i32, idx );
writeConstInt( byteCode.readUnsignedByte() );
writeNumericOperator( NumericOperator.add, ValueType.i32);
writeLoadStore( false, ValueType.i32, idx );
break;
case 136: // l2i
writeCast( ValueTypeConvertion.l2i );
break;

View File

@ -99,6 +99,7 @@ public class MathOperations {
@Export
static int addInt( int a, int b ) {
b++;
return a + b;
}
@ -126,8 +127,9 @@ public class MathOperations {
@Export
static int subLong() {
long a = 1L;
long a = -1L;
long b = 3L;
a--;
return (int)(a - b);
}