From 29677188899bb00ec7a06b85349ce9fc1b344094 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 4 Nov 2015 21:57:11 -0800 Subject: more conversions --- src/wasm-interpreter.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/wasm-interpreter.h') diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index f72dc524e..0843de8b4 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -359,13 +359,18 @@ public: case ExtendSInt32: return Flow(Literal(int64_t(value.geti32()))); case ExtendUInt32: return Flow(Literal(uint64_t((uint32_t)value.geti32()))); case WrapInt64: return Flow(Literal(int32_t(value.geti64()))); - case TruncSFloat32: { + case TruncSFloat32: { float val = value.getf32(); if (isnan(val)) instance.externalInterface->trap(); if (val > (double)INT_MAX || val < (double)INT_MIN) instance.externalInterface->trap(); return Flow(Literal(int32_t(val))); } - case TruncUFloat32: return Flow(Literal(uint32_t(value.getf32()))); + case TruncUFloat32: { + float val = value.getf32(); + if (isnan(val)) instance.externalInterface->trap(); + if (val > (double)UINT_MAX || val <= (double)-1) instance.externalInterface->trap(); + return Flow(Literal(uint32_t(val))); + } case TruncSFloat64: return Flow(Literal(int32_t(value.getf64()))); case TruncUFloat64: return Flow(Literal(int32_t((uint32_t)value.getf64()))); case ReinterpretFloat: return curr->type == i32 ? Flow(Literal(value.reinterpreti32())) : Flow(Literal(value.reinterpreti64())); -- cgit v1.2.3