summaryrefslogtreecommitdiff
path: root/src/wast-parser.cc
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2023-02-28 16:30:42 -0800
committerGitHub <noreply@github.com>2023-02-28 16:30:42 -0800
commit86d025bff8cac969b3f3e69f2b2a2b00116b496c (patch)
tree69b1386268c83dcaef6d971e9521c1395deef6d1 /src/wast-parser.cc
parent297e6593288ff8b3db1bfc94ee59cb9b42d962ef (diff)
downloadwabt-86d025bff8cac969b3f3e69f2b2a2b00116b496c.tar.gz
wabt-86d025bff8cac969b3f3e69f2b2a2b00116b496c.tar.bz2
wabt-86d025bff8cac969b3f3e69f2b2a2b00116b496c.zip
Always do a full roundtrip in run-roundtrip.py (#1661)
Even when the result is to be printed rather than compared byte for byte with the first version its still good to process the resulting wat output file so that we know we can parse what we generate. Case in point, this changed caused me to fix two latent bugs: 1. We were not correctly parsing events with inline import/export. 2. We were output element segment names even when bulk memory was not enabled (See #1651) The fix for (2) is a little more involved that we might like since for the first time the wat writer needs to know what features are enabled. Fixes: #1651
Diffstat (limited to 'src/wast-parser.cc')
-rw-r--r--src/wast-parser.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index e9c0687e..de754ea1 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -1351,6 +1351,8 @@ Result WastParser::ParseTagModuleField(Module* module) {
}
EXPECT(Lpar);
EXPECT(Tag);
+ Location loc = GetLocation();
+
std::string name;
ParseBindVarOpt(&name);
@@ -1360,20 +1362,23 @@ Result WastParser::ParseTagModuleField(Module* module) {
if (PeekMatchLpar(TokenType::Import)) {
CheckImportOrdering(module);
auto import = std::make_unique<TagImport>(name);
+ Tag& tag = import->tag;
CHECK_RESULT(ParseInlineImport(import.get()));
- CHECK_RESULT(ParseTypeUseOpt(&import->tag.decl));
- CHECK_RESULT(ParseUnboundFuncSignature(&import->tag.decl.sig));
+ CHECK_RESULT(ParseTypeUseOpt(&tag.decl));
+ CHECK_RESULT(ParseUnboundFuncSignature(&tag.decl.sig));
+ CHECK_RESULT(ErrorIfLpar({"type", "param", "result"}));
auto field =
std::make_unique<ImportModuleField>(std::move(import), GetLocation());
module->AppendField(std::move(field));
} else {
- auto field = std::make_unique<TagModuleField>(GetLocation(), name);
+ auto field = std::make_unique<TagModuleField>(loc, name);
CHECK_RESULT(ParseTypeUseOpt(&field->tag.decl));
CHECK_RESULT(ParseUnboundFuncSignature(&field->tag.decl.sig));
module->AppendField(std::move(field));
}
AppendInlineExportFields(module, &export_fields, module->tags.size() - 1);
+
EXPECT(Rpar);
return Result::Ok;
}