summaryrefslogtreecommitdiff
path: root/src/literal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/literal.h')
-rw-r--r--src/literal.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/literal.h b/src/literal.h
index 698063cbe..4ae4f969a 100644
--- a/src/literal.h
+++ b/src/literal.h
@@ -143,6 +143,11 @@ public:
static Literal makeExn(std::unique_ptr<ExceptionPackage>&& exn) {
return Literal(std::move(exn));
}
+ static Literal makeI31(int32_t value) {
+ auto lit = Literal(Type::i31ref);
+ lit.i32 = value & 0x7fffffff;
+ return lit;
+ }
Literal castToF32();
Literal castToF64();
@@ -153,6 +158,10 @@ public:
assert(type == Type::i32);
return i32;
}
+ int32_t geti31(bool signed_) const {
+ assert(type == Type::i31ref);
+ return signed_ ? (i32 << 1) >> 1 : i32;
+ }
int64_t geti64() const {
assert(type == Type::i64);
return i64;