mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
the shift parameter for i64 data must also be of type i64.
This commit is contained in:
parent
cfac54ec40
commit
4b2089b88d
@ -442,6 +442,9 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
case l2i:
|
||||
op = I32_WRAP_I64;
|
||||
break;
|
||||
case i2l:
|
||||
op = I64_EXTEND_S_I32;
|
||||
break;
|
||||
default:
|
||||
throw new Error( "Unknown cast: " + cast );
|
||||
}
|
||||
|
@ -117,4 +117,5 @@ interface InstructionOpcodes {
|
||||
|
||||
static final int I32_WRAP_I64 = 0xA7;
|
||||
|
||||
static final int I64_EXTEND_S_I32 = 0xAC;
|
||||
}
|
||||
|
@ -399,18 +399,21 @@ public abstract class ModuleWriter implements Closeable {
|
||||
writeNumericOperator( NumericOperator.shl, ValueType.i32 );
|
||||
break;
|
||||
case 121: // lshl
|
||||
writeCast( ValueTypeConvertion.i2l ); // the shift parameter must be of type long!!!
|
||||
writeNumericOperator( NumericOperator.shl, ValueType.i64 );
|
||||
break;
|
||||
case 122: // ishr
|
||||
writeNumericOperator( NumericOperator.shr_s, ValueType.i32 );
|
||||
break;
|
||||
case 123: // lshr
|
||||
writeCast( ValueTypeConvertion.i2l ); // the shift parameter must be of type long!!!
|
||||
writeNumericOperator( NumericOperator.shr_s, ValueType.i64 );
|
||||
break;
|
||||
case 124: // iushr
|
||||
writeNumericOperator( NumericOperator.shr_u, ValueType.i32 );
|
||||
break;
|
||||
case 125: // lushr
|
||||
writeCast( ValueTypeConvertion.i2l ); // the shift parameter must be of type long!!!
|
||||
writeNumericOperator( NumericOperator.shr_u, ValueType.i64 );
|
||||
break;
|
||||
case 126: // iand
|
||||
|
@ -23,4 +23,5 @@ package de.inetsoftware.jwebassembly.module;
|
||||
*/
|
||||
public enum ValueTypeConvertion {
|
||||
l2i,
|
||||
i2l,
|
||||
}
|
||||
|
@ -179,6 +179,9 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
case l2i:
|
||||
op = "i32.wrap/i64";
|
||||
break;
|
||||
case i2l:
|
||||
op = "i64.extend_s/i32";
|
||||
break;
|
||||
default:
|
||||
throw new Error( "Unknown cast: " + cast );
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ public class MathOperations {
|
||||
addParam( list, script, "mulDivLong" );
|
||||
addParam( list, script, "mulDivFloat" );
|
||||
addParam( list, script, "mulDivDouble" );
|
||||
addParam( list, script, "intBits" );
|
||||
addParam( list, script, "longBits" );
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -177,5 +179,29 @@ public class MathOperations {
|
||||
return a;
|
||||
}
|
||||
|
||||
@Export
|
||||
static int intBits() {
|
||||
int a = 1;
|
||||
a = a << 1;
|
||||
a = a | 15;
|
||||
a = a & 4;
|
||||
int b = Integer.MIN_VALUE;
|
||||
b = b >>> 1;
|
||||
b = b >> 2;
|
||||
return a ^ b;
|
||||
}
|
||||
|
||||
@Export
|
||||
static int longBits() {
|
||||
long a = 1;
|
||||
a = a << 1;
|
||||
a = a | 15;
|
||||
a = a & 4;
|
||||
long b = Long.MIN_VALUE;
|
||||
b = b >>> 1;
|
||||
b = b >> 2;
|
||||
return (int)(a ^ (b >> 32));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user