summaryrefslogtreecommitdiff
path: root/src/parser/wast-parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/wast-parser.cpp')
-rw-r--r--src/parser/wast-parser.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/parser/wast-parser.cpp b/src/parser/wast-parser.cpp
index a3a6c14ce..00269a577 100644
--- a/src/parser/wast-parser.cpp
+++ b/src/parser/wast-parser.cpp
@@ -25,7 +25,17 @@ using namespace std::string_view_literals;
namespace {
Result<Literal> const_(Lexer& in) {
- // TODO: handle `ref.extern n` as well.
+ if (in.takeSExprStart("ref.extern"sv)) {
+ auto n = in.takeI32();
+ if (!n) {
+ return in.err("expected host reference payload");
+ }
+ if (!in.takeRParen()) {
+ return in.err("expected end of ref.extern");
+ }
+ // Represent host references as externalized i31s.
+ return Literal::makeI31(*n, Unshared).externalize();
+ }
return parseConst(in);
}