summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-11-06 09:08:14 -0800
committerAlon Zakai <alonzakai@gmail.com>2015-11-06 09:08:14 -0800
commit034596930c9d4ca3e771e78e03e06efc026fadff (patch)
treef26854cabb4489395f979c5761820b3b64580fcc /src/wasm.h
parenteeba133dffb9e50e8cb3cbd58b46ea02a9e34c1b (diff)
downloadbinaryen-034596930c9d4ca3e771e78e03e06efc026fadff.tar.gz
binaryen-034596930c9d4ca3e771e78e03e06efc026fadff.tar.bz2
binaryen-034596930c9d4ca3e771e78e03e06efc026fadff.zip
convenience methods
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 32f9d9130..0104e45df 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -118,6 +118,22 @@ struct Literal {
float reinterpretf32() { assert(type == WasmType::i32); return f32; }
double reinterpretf64() { assert(type == WasmType::i64); return f64; }
+ int64_t getInteger() {
+ switch (type) {
+ case WasmType::i32: return i32;
+ case WasmType::i64: return i64;
+ default: abort();
+ }
+ }
+
+ double getFloat() {
+ switch (type) {
+ case WasmType::f32: return f32;
+ case WasmType::f64: return f64;
+ default: abort();
+ }
+ }
+
bool operator==(Literal& other) {
if (type != other.type) return false;
if (type == none) return true;