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