Change the old text format to the new format. fix #3

This commit is contained in:
Volker Berlin 2019-02-22 23:19:10 +01:00
parent f5ed8aeeb6
commit 9bcc7347c1
5 changed files with 51 additions and 51 deletions

View File

@ -671,37 +671,37 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
int op;
switch( cast ) {
case i2l:
op = I64_EXTEND_S_I32;
op = I64_EXTEND_I32_S;
break;
case i2f:
op = F32_CONVERT_S_I32;
op = F32_CONVERT_I32_S;
break;
case i2d:
op = F64_CONVERT_S_I32;
op = F64_CONVERT_I32_S;
break;
case l2i:
op = I32_WRAP_I64;
break;
case l2f:
op = F32_CONVERT_S_I64;
op = F32_CONVERT_I64_S;
break;
case l2d:
op = F64_CONVERT_S_I64;
op = F64_CONVERT_I64_S;
break;
case f2i:
op = I32_TRUNC_S_SAT_F32;
op = I32_TRUNC_SAT_F32_S;
break;
case f2l:
op = I64_TRUNC_S_SAT_F32;
op = I64_TRUNC_SAT_F32_S;
break;
case f2d:
op = F64_PROMOTE_F32;
break;
case d2i:
op = I32_TRUNC_S_SAT_F64;
op = I32_TRUNC_SAT_F64_S;
break;
case d2l:
op = I64_TRUNC_S_SAT_F64;
op = I64_TRUNC_SAT_F64_S;
break;
case d2f:
op = F32_DEMOTE_F64;

View File

@ -311,43 +311,43 @@ interface InstructionOpcodes {
static final int I32_WRAP_I64 = 0xA7;
static final int I32_TRUNC_S_F32 = 0xA8;
static final int I32_TRUNC_F32_S = 0xA8;
static final int I32_TRUNC_U_F32 = 0xA9;
static final int I32_TRUNC_F32_U = 0xA9;
static final int I32_TRUNC_S_F64 = 0xAA;
static final int I32_TRUNC_F64_S = 0xAA;
static final int I32_TRUNC_U_F64 = 0xAB;
static final int I32_TRUNC_F64_U = 0xAB;
static final int I64_EXTEND_S_I32 = 0xAC;
static final int I64_EXTEND_I32_S = 0xAC;
static final int I64_EXTEND_U_I32 = 0xAD;
static final int I64_EXTEND_I32_U = 0xAD;
static final int I64_TRUNC_S_F32 = 0xAE;
static final int I64_TRUNC_F32_S = 0xAE;
static final int I64_TRUNC_U_F32 = 0xAF;
static final int I64_TRUNC_F32_U = 0xAF;
static final int I64_TRUNC_S_F64 = 0xB0;
static final int I64_TRUNC_F64_S = 0xB0;
static final int I64_TRUNC_U_F64 = 0xB1;
static final int I64_TRUNC_F64_U = 0xB1;
static final int F32_CONVERT_S_I32 = 0xB2;
static final int F32_CONVERT_I32_S = 0xB2;
static final int F32_CONVERT_U_I32 = 0xB3;
static final int F32_CONVERT_I32_U = 0xB3;
static final int F32_CONVERT_S_I64 = 0xB4;
static final int F32_CONVERT_I64_S = 0xB4;
static final int F32_CONVERT_U_I64 = 0xB5;
static final int F32_CONVERT_I64_U = 0xB5;
static final int F32_DEMOTE_F64 = 0xB6;
static final int F64_CONVERT_S_I32 = 0xB7;
static final int F64_CONVERT_I32_S = 0xB7;
static final int F64_CONVERT_U_I32 = 0xB8;
static final int F64_CONVERT_I32_U = 0xB8;
static final int F64_CONVERT_S_I64 = 0xB9;
static final int F64_CONVERT_I64_S = 0xB9;
static final int F64_CONVERT_U_I64 = 0xBA;
static final int F64_CONVERT_I64_U = 0xBA;
static final int F64_PROMOTE_F32 = 0xBB;
@ -383,21 +383,21 @@ interface InstructionOpcodes {
// === Non-trapping float-to-int conversions ====== https://github.com/WebAssembly/design/issues/1143
static final int I32_TRUNC_S_SAT_F32 = 0xFC00;
static final int I32_TRUNC_SAT_F32_S = 0xFC00;
static final int I32_TRUNC_U_SAT_F32 = 0xFC01;
static final int I32_TRUNC_SAT_F32_U = 0xFC01;
static final int I32_TRUNC_S_SAT_F64 = 0xFC02;
static final int I32_TRUNC_SAT_F64_S = 0xFC02;
static final int I32_TRUNC_U_SAT_F64 = 0xFC03;
static final int I32_TRUNC_SAT_F64_U = 0xFC03;
static final int I64_TRUNC_S_SAT_F32 = 0xFC04;
static final int I64_TRUNC_SAT_F32_S = 0xFC04;
static final int I64_TRUNC_U_SAT_F32 = 0xFC05;
static final int I64_TRUNC_SAT_F32_U = 0xFC05;
static final int I64_TRUNC_S_SAT_F64 = 0xFC06;
static final int I64_TRUNC_SAT_F64_S = 0xFC06;
static final int I64_TRUNC_U_SAT_F64 = 0xFC07;
static final int I64_TRUNC_SAT_F64_U = 0xFC07;
// === GC opcodes (unofficial, experimental) ===== https://github.com/lars-t-hansen/moz-gc-experiments/blob/master/version2.md

View File

@ -213,7 +213,7 @@ public class TextModuleWriter extends ModuleWriter {
globals.add( name.fullName );
}
newline( methodOutput );
methodOutput.append( load ? "get_global $" : "set_global $" ).append( name.fullName );
methodOutput.append( load ? "global.get $" : "global.set $" ).append( name.fullName );
}
/**
@ -265,40 +265,40 @@ public class TextModuleWriter extends ModuleWriter {
String op;
switch( cast ) {
case i2l:
op = "i64.extend_s/i32";
op = "i64.extend_i32_s";
break;
case i2f:
op = "f32.convert_s/i32";
op = "f32.convert_i32_s";
break;
case i2d:
op = "f64.convert_s/i32";
op = "f64.convert_i32_s";
break;
case l2i:
op = "i32.wrap/i64";
op = "i32.wrap_i64";
break;
case l2f:
op = "f32.convert_s/i64";
op = "f32.convert_i64_s";
break;
case l2d:
op = "f64.convert_s/i64";
op = "f64.convert_i64_s";
break;
case f2i:
op = "i32.trunc_s:sat/f32";
op = "i32.trunc_sat_f32_s";
break;
case f2l:
op = "i64.trunc_s:sat/f32";
op = "i64.trunc_sat_f32_s";
break;
case f2d:
op = "f64.promote/f32";
op = "f64.promote_f32";
break;
case d2i:
op = "i32.trunc_s:sat/f64";
op = "i32.trunc_sat_f64_s";
break;
case d2l:
op = "i64.trunc_s:sat/f64";
op = "i64.trunc_sat_f64_s";
break;
case d2f:
op = "f32.demote/f64";
op = "f32.demote_f64";
break;
case i2b:
op = "i32.extend8_s";

View File

@ -76,7 +76,7 @@ public class WatParser extends WasmCodeBuilder {
case "f64.max":
addNumericInstruction( NumericOperator.max, ValueType.f64, javaCodePos );
break;
case "i64.extend_s/i32":
case "i64.extend_i32_s":
addConvertInstruction( ValueTypeConvertion.i2l, javaCodePos );
break;
// case "call":

View File

@ -118,8 +118,8 @@ public class WatParserTest {
}
@Test
public void i64_extend_s_i32() throws IOException {
test( "i64.extend_s/i32" );
public void i64_extend_i32_s() throws IOException {
test( "i64.extend_i32_s" );
}
@Test