summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-05 10:29:23 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-05 10:29:23 -0800
commitd16e8900cb98af97775e406c25d4a8b0c8c86039 (patch)
tree8823a93778674be034eaf7b6765817b67c3fb7b9 /src
parenta1b24a29d50d6e060adf1ffd97d406bc5d71f290 (diff)
downloadbinaryen-d16e8900cb98af97775e406c25d4a8b0c8c86039.tar.gz
binaryen-d16e8900cb98af97775e406c25d4a8b0c8c86039.tar.bz2
binaryen-d16e8900cb98af97775e406c25d4a8b0c8c86039.zip
more conversion fixes
Diffstat (limited to 'src')
-rw-r--r--src/wasm-interpreter.h8
-rw-r--r--src/wasm-s-parser.h5
2 files changed, 8 insertions, 5 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 586715b77..5d9bf89b0 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -386,10 +386,10 @@ public:
}
}
case ReinterpretFloat: return curr->type == i32 ? Flow(Literal(value.reinterpreti32())) : Flow(Literal(value.reinterpreti64()));
- case ConvertUInt32: return Flow(Literal(double(uint32_t(value.geti32()))));
- case ConvertSInt32: return Flow(Literal(double(int32_t(value.geti32()))));
- case ConvertUInt64: return Flow(Literal(double((uint64_t)value.geti64())));
- case ConvertSInt64: return Flow(Literal(double(value.geti64())));
+ case ConvertUInt32: return curr->type == f32 ? Flow(Literal(float(uint32_t(value.geti32())))) : Flow(Literal(double(uint32_t(value.geti32()))));
+ case ConvertSInt32: return curr->type == f32 ? Flow(Literal(float(int32_t(value.geti32())))) : Flow(Literal(double(int32_t(value.geti32()))));
+ case ConvertUInt64: return curr->type == f32 ? Flow(Literal(float((uint64_t)value.geti64()))) : Flow(Literal(double((uint64_t)value.geti64())));
+ case ConvertSInt64: return curr->type == f32 ? Flow(Literal(float(value.geti64()))) : Flow(Literal(double(value.geti64())));
case PromoteFloat32: return Flow(Literal(double(value.getf32())));
case DemoteFloat64: return Flow(Literal(float(value.getf64())));
case ReinterpretInt: return curr->type == f32 ? Flow(Literal(value.reinterpretf32())) : Flow(Literal(value.reinterpretf64()));
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index e1c87c893..df0427e08 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -296,7 +296,10 @@ public:
if (op[1] == 'o') {
if (op[2] == 'p') return makeBinary(s, BinaryOp::CopySign, type);
if (op[2] == 'n') {
- if (op[3] == 'v') return makeConvert(s, op[8] == 'u' ? ConvertOp::ConvertUInt32 : ConvertOp::ConvertSInt32, type);
+ if (op[3] == 'v') {
+ if (op[8] == 's') return makeConvert(s, op[11] == '3' ? ConvertOp::ConvertSInt32 : ConvertOp::ConvertSInt64, type);
+ if (op[8] == 'u') return makeConvert(s, op[11] == '3' ? ConvertOp::ConvertUInt32 : ConvertOp::ConvertUInt64, type);
+ }
if (op[3] == 's') return makeConst(s, type);
}
}