diff options
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index 4edaf8039..b7cf5084e 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -55,6 +55,9 @@ Literal::Literal(const Literal& other) : type(other.type) { } else { new (&exn) std::unique_ptr<ExceptionPackage>(); } + } else if (other.isGCData()) { + // Avoid calling the destructor on an uninitialized value + new (&gcData) std::shared_ptr<Literals>(other.gcData); } else if (type.isFunction()) { func = other.func; } else { @@ -189,6 +192,11 @@ ExceptionPackage Literal::getExceptionPackage() const { return *exn; } +std::shared_ptr<Literals> Literal::getGCData() const { + assert(isGCData()); + return gcData; +} + Literal Literal::castToF32() { assert(type == Type::i32); Literal ret(Type::f32); @@ -428,6 +436,13 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { } else { o << "funcref(" << literal.getFunc() << ")"; } + } else if (literal.isGCData()) { + auto data = literal.getGCData(); + if (data) { + o << "[ref " << *data << ']'; + } else { + o << "[ref null " << literal.type << ']'; + } } else { TODO_SINGLE_COMPOUND(literal.type); switch (literal.type.getBasic()) { |