summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-10-29 17:26:23 -0700
committerAlon Zakai <alonzakai@gmail.com>2015-10-29 17:26:23 -0700
commitd93c05bfa9a7fc813c31c7972e6680d6ef0277d2 (patch)
treec0b1eddc0126d46a1e3f17793b12ada018e34693
parent4d319b84d83ad3168ee798c52071e4b4b831e042 (diff)
downloadbinaryen-d93c05bfa9a7fc813c31c7972e6680d6ef0277d2.tar.gz
binaryen-d93c05bfa9a7fc813c31c7972e6680d6ef0277d2.tar.bz2
binaryen-d93c05bfa9a7fc813c31c7972e6680d6ef0277d2.zip
fix Convert
-rw-r--r--src/asm2wasm.cpp2
-rw-r--r--src/wasm.h11
-rw-r--r--test/emcc_hello_world.wast4
3 files changed, 10 insertions, 7 deletions
diff --git a/src/asm2wasm.cpp b/src/asm2wasm.cpp
index 28ff7d563..ef43a6ac2 100644
--- a/src/asm2wasm.cpp
+++ b/src/asm2wasm.cpp
@@ -821,7 +821,7 @@ Function* Asm2WasmModule::processFunction(Ref ast) {
auto ret = allocator.alloc<Convert>();
ret->op = isUnsignedCoercion(ast[2]) ? ConvertUInt32 : ConvertSInt32;
ret->value = process(ast[2]);
- ret->type = BasicType::i32;
+ ret->type = BasicType::f64;
return ret;
}
assert(childType == ASM_NONE); // e.g. a coercion on a call
diff --git a/src/wasm.h b/src/wasm.h
index 6aa568210..a5210e4d6 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -654,13 +654,16 @@ public:
Expression *value;
std::ostream& print(std::ostream &o, unsigned indent) override {
- printOpening(o, "convert ");
+ o << '(';
+ prepareColor(o);
+ printBasicType(o, type) << ".convert_";
switch (op) {
- case ConvertUInt32: o << "uint32toDouble"; break;
- case ConvertSInt32: o << "sint32toDouble"; break;
- case TruncSFloat64: o << "float64tosint32"; break;
+ case ConvertUInt32: o << "u/i32"; break;
+ case ConvertSInt32: o << "s/i32"; break;
+ case TruncSFloat64: o << "s/f64"; break;
default: abort();
}
+ restoreNormalColor(o);
incIndent(o, indent);
printFullLine(o, indent, value);
decIndent(o, indent);
diff --git a/test/emcc_hello_world.wast b/test/emcc_hello_world.wast
index 410a3b2b5..2a5fe5699 100644
--- a/test/emcc_hello_world.wast
+++ b/test/emcc_hello_world.wast
@@ -426,7 +426,7 @@
)
(nop)
(break $topmost
- (convert sint32toDouble
+ (f64.convert_s/i32
(get_local $$retval$0)
)
)
@@ -449,7 +449,7 @@
)
)
(break $topmost
- (convert sint32toDouble
+ (f64.convert_s/i32
(get_local $$call)
)
)