mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
implements byte code ifne
This commit is contained in:
parent
07c18fac6b
commit
8d7ea08f64
@ -453,6 +453,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
op = F64_EQ;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ne:
|
||||
switch( valueType ) {
|
||||
case i32:
|
||||
@ -468,6 +469,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
op = F64_NE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if( op == 0 ) {
|
||||
throw new Error( valueType + "." + numOp );
|
||||
|
@ -499,6 +499,9 @@ public abstract class ModuleWriter implements Closeable {
|
||||
case 153: // ifeq
|
||||
opIfCondition( NumericOperator.ne, byteCode );
|
||||
break;
|
||||
case 154: // ifne
|
||||
opIfCondition( NumericOperator.eq, byteCode );
|
||||
break;
|
||||
case 167: // goto
|
||||
int baseCodePosition = byteCode.getCodePosition() - 1;
|
||||
int offset = byteCode.readUnsignedShort();
|
||||
|
@ -24,7 +24,8 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
ArrayList<Object[]> list = new ArrayList<>();
|
||||
for( ScriptEngine[] val : ScriptEngine.testParams() ) {
|
||||
ScriptEngine script = val[0];
|
||||
addParam( list, script, "ifThenElse_Int0" );
|
||||
addParam( list, script, "ifeq" );
|
||||
addParam( list, script, "ifne" );
|
||||
addParam( list, script, "forLoop" );
|
||||
}
|
||||
return list;
|
||||
@ -33,7 +34,7 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
static class TestClass {
|
||||
|
||||
@Export
|
||||
static int ifThenElse_Int0() {
|
||||
static int ifeq() {
|
||||
int condition = 0;
|
||||
if( condition != 0 ) {
|
||||
return 13;
|
||||
@ -42,6 +43,16 @@ public class ControlFlowOperators extends AbstractBaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Export
|
||||
static int ifne() {
|
||||
int condition = 3;
|
||||
if( condition == 0 ) {
|
||||
return 13;
|
||||
} else {
|
||||
return 76;
|
||||
}
|
||||
}
|
||||
|
||||
@Export
|
||||
static int forLoop() {
|
||||
int a = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user