From b20025479124b041c94f9bf6f8053eaa95e46c0c Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Tue, 2 Feb 2016 06:14:34 -0800 Subject: Make Literal's ctors explicit This tends to avoid silly mistakes, which I'm worried about after adding an explicit ctor with the enum WasmType parameter. See 'C++ Coding Standards: 101 Rules, Guidelines, and Best Practices' rule #40 'avoid providing implicit conversion'. --- src/wasm.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/wasm.h') diff --git a/src/wasm.h b/src/wasm.h index a5c163719..6f889737b 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -151,12 +151,12 @@ struct Literal { Literal() : Literal(WasmType::none) {} explicit Literal(WasmType type) : type(type) { memset(&f64, 0, sizeof(f64)); } - Literal(int32_t init) : type(WasmType::i32), i32(init) {} - Literal(uint32_t init) : type(WasmType::i32), i32(init) {} - Literal(int64_t init) : type(WasmType::i64), i64(init) {} - Literal(uint64_t init) : type(WasmType::i64), i64(init) {} - Literal(float init) : type(WasmType::f32), f32(init) {} - Literal(double init) : type(WasmType::f64), f64(init) {} + explicit Literal(int32_t init) : type(WasmType::i32), i32(init) {} + explicit Literal(uint32_t init) : type(WasmType::i32), i32(init) {} + explicit Literal(int64_t init) : type(WasmType::i64), i64(init) {} + explicit Literal(uint64_t init) : type(WasmType::i64), i64(init) {} + explicit Literal(float init) : type(WasmType::f32), f32(init) {} + explicit Literal(double init) : type(WasmType::f64), f64(init) {} int32_t geti32() { assert(type == WasmType::i32); return i32; } int64_t geti64() { assert(type == WasmType::i64); return i64; } -- cgit v1.2.3