summaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/contexts.h48
-rw-r--r--src/parser/parsers.h84
-rw-r--r--src/parser/wat-parser.cpp5
3 files changed, 15 insertions, 122 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h
index f66e3d051..b32e32a15 100644
--- a/src/parser/contexts.h
+++ b/src/parser/contexts.h
@@ -217,9 +217,6 @@ template<typename Ctx> struct TypeParserCtx {
HeapTypeT makeArrayType() { return HeapType::array; }
HeapTypeT makeExnType() { return HeapType::exn; }
HeapTypeT makeStringType() { return HeapType::string; }
- HeapTypeT makeStringViewWTF8Type() { return HeapType::stringview_wtf8; }
- HeapTypeT makeStringViewWTF16Type() { return HeapType::stringview_wtf16; }
- HeapTypeT makeStringViewIterType() { return HeapType::stringview_iter; }
HeapTypeT makeContType() { return HeapType::cont; }
HeapTypeT makeNoneType() { return HeapType::none; }
HeapTypeT makeNoextType() { return HeapType::noext; }
@@ -799,9 +796,6 @@ struct NullInstrParserCtx {
Result<> makeStringEq(Index, const std::vector<Annotation>&, StringEqOp) {
return Ok{};
}
- Result<> makeStringAs(Index, const std::vector<Annotation>&, StringAsOp) {
- return Ok{};
- }
Result<> makeStringWTF8Advance(Index, const std::vector<Annotation>&) {
return Ok{};
}
@@ -811,15 +805,7 @@ struct NullInstrParserCtx {
Result<> makeStringIterNext(Index, const std::vector<Annotation>&) {
return Ok{};
}
- Result<>
- makeStringIterMove(Index, const std::vector<Annotation>&, StringIterMoveOp) {
- return Ok{};
- }
- Result<>
- makeStringSliceWTF(Index, const std::vector<Annotation>&, StringSliceWTFOp) {
- return Ok{};
- }
- Result<> makeStringSliceIter(Index, const std::vector<Annotation>&) {
+ Result<> makeStringSliceWTF(Index, const std::vector<Annotation>&) {
return Ok{};
}
template<typename HeapTypeT>
@@ -2562,42 +2548,14 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> {
return withLoc(pos, irBuilder.makeStringEq(op));
}
- Result<> makeStringAs(Index pos,
- const std::vector<Annotation>& annotations,
- StringAsOp op) {
- return withLoc(pos, irBuilder.makeStringAs(op));
- }
-
- Result<> makeStringWTF8Advance(Index pos,
- const std::vector<Annotation>& annotations) {
- return withLoc(pos, irBuilder.makeStringWTF8Advance());
- }
-
Result<> makeStringWTF16Get(Index pos,
const std::vector<Annotation>& annotations) {
return withLoc(pos, irBuilder.makeStringWTF16Get());
}
- Result<> makeStringIterNext(Index pos,
- const std::vector<Annotation>& annotations) {
- return withLoc(pos, irBuilder.makeStringIterNext());
- }
-
- Result<> makeStringIterMove(Index pos,
- const std::vector<Annotation>& annotations,
- StringIterMoveOp op) {
- return withLoc(pos, irBuilder.makeStringIterMove(op));
- }
-
Result<> makeStringSliceWTF(Index pos,
- const std::vector<Annotation>& annotations,
- StringSliceWTFOp op) {
- return withLoc(pos, irBuilder.makeStringSliceWTF(op));
- }
-
- Result<> makeStringSliceIter(Index pos,
- const std::vector<Annotation>& annotations) {
- return withLoc(pos, irBuilder.makeStringSliceIter());
+ const std::vector<Annotation>& annotations) {
+ return withLoc(pos, irBuilder.makeStringSliceWTF());
}
Result<> makeContBind(Index pos,
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index 30a828822..60d3f0391 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -285,26 +285,9 @@ Result<> makeStringConcat(Ctx&, Index, const std::vector<Annotation>&);
template<typename Ctx>
Result<> makeStringEq(Ctx&, Index, const std::vector<Annotation>&, StringEqOp);
template<typename Ctx>
-Result<>
-makeStringAs(Ctx&, Index, const std::vector<Annotation>&, StringAsOp op);
-template<typename Ctx>
-Result<> makeStringWTF8Advance(Ctx&, Index, const std::vector<Annotation>&);
-template<typename Ctx>
Result<> makeStringWTF16Get(Ctx&, Index, const std::vector<Annotation>&);
template<typename Ctx>
-Result<> makeStringIterNext(Ctx&, Index, const std::vector<Annotation>&);
-template<typename Ctx>
-Result<> makeStringIterMove(Ctx&,
- Index,
- const std::vector<Annotation>&,
- StringIterMoveOp op);
-template<typename Ctx>
-Result<> makeStringSliceWTF(Ctx&,
- Index,
- const std::vector<Annotation>&,
- StringSliceWTFOp op);
-template<typename Ctx>
-Result<> makeStringSliceIter(Ctx&, Index, const std::vector<Annotation>&);
+Result<> makeStringSliceWTF(Ctx&, Index, const std::vector<Annotation>&);
template<typename Ctx>
Result<> makeContBind(Ctx&, Index, const std::vector<Annotation>&);
template<typename Ctx>
@@ -314,6 +297,11 @@ Result<> makeResume(Ctx&, Index, const std::vector<Annotation>&);
template<typename Ctx>
Result<> makeSuspend(Ctx&, Index, const std::vector<Annotation>&);
+template<typename Ctx>
+Result<> ignore(Ctx&, Index, const std::vector<Annotation>&) {
+ return Ok{};
+}
+
// Modules
template<typename Ctx> MaybeResult<Index> maybeTypeidx(Ctx& ctx);
template<typename Ctx> Result<typename Ctx::HeapTypeT> typeidx(Ctx&);
@@ -421,15 +409,6 @@ template<typename Ctx> Result<typename Ctx::HeapTypeT> heaptype(Ctx& ctx) {
if (ctx.in.takeKeyword("string"sv)) {
return ctx.makeStringType();
}
- if (ctx.in.takeKeyword("stringview_wtf8"sv)) {
- return ctx.makeStringViewWTF8Type();
- }
- if (ctx.in.takeKeyword("stringview_wtf16"sv)) {
- return ctx.makeStringViewWTF16Type();
- }
- if (ctx.in.takeKeyword("stringview_iter"sv)) {
- return ctx.makeStringViewIterType();
- }
if (ctx.in.takeKeyword("cont"sv)) {
return ctx.makeContType();
}
@@ -489,15 +468,6 @@ template<typename Ctx> MaybeResult<typename Ctx::TypeT> reftype(Ctx& ctx) {
if (ctx.in.takeKeyword("stringref"sv)) {
return ctx.makeRefType(ctx.makeStringType(), Nullable);
}
- if (ctx.in.takeKeyword("stringview_wtf8"sv)) {
- return ctx.makeRefType(ctx.makeStringViewWTF8Type(), Nullable);
- }
- if (ctx.in.takeKeyword("stringview_wtf16"sv)) {
- return ctx.makeRefType(ctx.makeStringViewWTF16Type(), Nullable);
- }
- if (ctx.in.takeKeyword("stringview_iter"sv)) {
- return ctx.makeRefType(ctx.makeStringViewIterType(), Nullable);
- }
if (ctx.in.takeKeyword("contref"sv)) {
return ctx.makeRefType(ctx.makeContType(), Nullable);
}
@@ -2436,21 +2406,6 @@ Result<> makeStringEq(Ctx& ctx,
}
template<typename Ctx>
-Result<> makeStringAs(Ctx& ctx,
- Index pos,
- const std::vector<Annotation>& annotations,
- StringAsOp op) {
- return ctx.makeStringAs(pos, annotations, op);
-}
-
-template<typename Ctx>
-Result<> makeStringWTF8Advance(Ctx& ctx,
- Index pos,
- const std::vector<Annotation>& annotations) {
- return ctx.makeStringWTF8Advance(pos, annotations);
-}
-
-template<typename Ctx>
Result<> makeStringWTF16Get(Ctx& ctx,
Index pos,
const std::vector<Annotation>& annotations) {
@@ -2458,33 +2413,10 @@ Result<> makeStringWTF16Get(Ctx& ctx,
}
template<typename Ctx>
-Result<> makeStringIterNext(Ctx& ctx,
- Index pos,
- const std::vector<Annotation>& annotations) {
- return ctx.makeStringIterNext(pos, annotations);
-}
-
-template<typename Ctx>
-Result<> makeStringIterMove(Ctx& ctx,
- Index pos,
- const std::vector<Annotation>& annotations,
- StringIterMoveOp op) {
- return ctx.makeStringIterMove(pos, annotations, op);
-}
-
-template<typename Ctx>
Result<> makeStringSliceWTF(Ctx& ctx,
Index pos,
- const std::vector<Annotation>& annotations,
- StringSliceWTFOp op) {
- return ctx.makeStringSliceWTF(pos, annotations, op);
-}
-
-template<typename Ctx>
-Result<> makeStringSliceIter(Ctx& ctx,
- Index pos,
- const std::vector<Annotation>& annotations) {
- return ctx.makeStringSliceIter(pos, annotations);
+ const std::vector<Annotation>& annotations) {
+ return ctx.makeStringSliceWTF(pos, annotations);
}
// contbind ::= 'cont.bind' typeidx typeidx
diff --git a/src/parser/wat-parser.cpp b/src/parser/wat-parser.cpp
index 2bc222d6b..85ef1e80f 100644
--- a/src/parser/wat-parser.cpp
+++ b/src/parser/wat-parser.cpp
@@ -202,7 +202,10 @@ Result<> doParseModule(Module& wasm, Lexer& input, bool allowExtra) {
CHECK_ERR(im);
}
if (!f->imported()) {
- CHECK_ERR(ctx.irBuilder.visitEnd());
+ auto end = ctx.irBuilder.visitEnd();
+ if (auto* err = end.getErr()) {
+ return ctx.in.err(decls.funcDefs[i].pos, err->msg);
+ }
}
}