diff options
Diffstat (limited to 'src/wasm')
-rw-r--r-- | src/wasm/literal.cpp | 8 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 15 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp index a7c14fdb6..d309be308 100644 --- a/src/wasm/literal.cpp +++ b/src/wasm/literal.cpp @@ -139,7 +139,11 @@ Literals Literal::makeZero(Type type) { Literal Literal::makeSingleZero(Type type) { assert(type.isSingle()); if (type.isRef()) { - return makeNull(type); + if (type == Type::i31ref) { + return makeI31(0); + } else { + return makeNull(type); + } } else { return makeFromInt32(0, type); } @@ -438,7 +442,7 @@ std::ostream& operator<<(std::ostream& o, Literal literal) { o << "eqref(null)"; break; case Type::i31ref: - o << "i31ref(" << literal.geti31(false) << ")"; + o << "i31ref(" << literal.geti31() << ")"; break; case Type::unreachable: WASM_UNREACHABLE("invalid type"); diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index c03a9b281..c857b202c 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -217,18 +217,15 @@ const char* getExpressionName(Expression* curr) { } Literal getSingleLiteralFromConstExpression(Expression* curr) { - if (auto* c = curr->dynCast<Const>()) { - return c->value; - } else if (auto* n = curr->dynCast<RefNull>()) { - return Literal::makeNull(n->type); - } else if (auto* r = curr->dynCast<RefFunc>()) { - return Literal::makeFunc(r->func); - } else { - WASM_UNREACHABLE("Not a constant expression"); - } + // TODO: Do we need this function given that Properties::getSingleLiteral + // (currently) does the same? + assert(Properties::isConstantExpression(curr)); + return Properties::getSingleLiteral(curr); } Literals getLiteralsFromConstExpression(Expression* curr) { + // TODO: Do we need this function given that Properties::getLiterals + // (currently) does the same? if (auto* t = curr->dynCast<TupleMake>()) { Literals values; for (auto* operand : t->operands) { |