From 1b693d221566b017b63e002526bfbe724522e679 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 4 Nov 2015 20:25:16 -0800 Subject: literal == --- src/wasm.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/wasm.h b/src/wasm.h index 5cad00c3a..f7f6ce6b5 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -114,6 +114,13 @@ struct Literal { float reinterpretf32() { assert(type == WasmType::i32); return f32; } double reinterpretf64() { assert(type == WasmType::i64); return f64; } + bool operator==(Literal& other) { + if (type != other.type) return false; + if (type == none) return true; + if (type == i32 || type == f32) return i32 == other.i32; + return i64 == other.i64; + } + void printDouble(std::ostream &o, double d) { const char *text = cashew::JSPrinter::numToString(d); // spec interpreter hates floats starting with '.' -- cgit v1.2.3