summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binary-writer.cc4
-rw-r--r--src/ir.cc2
-rw-r--r--src/ir.h2
-rw-r--r--src/resolve-names.cc4
-rw-r--r--src/wast-parser.cc15
5 files changed, 14 insertions, 13 deletions
diff --git a/src/binary-writer.cc b/src/binary-writer.cc
index 54ba2fcb..687b117d 100644
--- a/src/binary-writer.cc
+++ b/src/binary-writer.cc
@@ -820,8 +820,8 @@ Result BinaryWriter::WriteModule(const Module* module) {
EndSection();
}
- if (module->start) {
- Index start_func_index = module->GetFuncIndex(*module->start);
+ if (module->starts.size()) {
+ Index start_func_index = module->GetFuncIndex(*module->starts[0]);
if (start_func_index != kInvalidIndex) {
BeginKnownSection(BinarySection::Start, LEB_SECTION_SIZE_GUESS);
WriteU32Leb128(stream_, start_func_index, "start func index");
diff --git a/src/ir.cc b/src/ir.cc
index 7522e511..10564d8a 100644
--- a/src/ir.cc
+++ b/src/ir.cc
@@ -319,7 +319,7 @@ void Module::AppendField(std::unique_ptr<MemoryModuleField> field) {
}
void Module::AppendField(std::unique_ptr<StartModuleField> field) {
- start = &field->start;
+ starts.push_back(&field->start);
fields.push_back(std::move(field));
}
diff --git a/src/ir.h b/src/ir.h
index 2ad56379..99950421 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -707,7 +707,7 @@ struct Module {
std::vector<ElemSegment*> elem_segments;
std::vector<Memory*> memories;
std::vector<DataSegment*> data_segments;
- Var* start = nullptr;
+ std::vector<Var*> starts;
BindingHash except_bindings;
BindingHash func_bindings;
diff --git a/src/resolve-names.cc b/src/resolve-names.cc
index 47f254c1..dfdee366 100644
--- a/src/resolve-names.cc
+++ b/src/resolve-names.cc
@@ -383,8 +383,8 @@ Result NameResolver::VisitModule(Module* module) {
VisitElemSegment(elem_segment);
for (DataSegment* data_segment : module->data_segments)
VisitDataSegment(data_segment);
- if (module->start)
- ResolveFuncVar(module->start);
+ for (Var* start : module->starts)
+ ResolveFuncVar(start);
current_module_ = nullptr;
return result_;
}
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index eaa4a31e..2c16c7e6 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -439,8 +439,10 @@ Result WastParser::ErrorExpected(const std::vector<std::string>& expected,
Result WastParser::ErrorIfLpar(const std::vector<std::string>& expected,
const char* example) {
- if (Match(TokenType::Lpar))
+ if (Match(TokenType::Lpar)) {
+ GetToken();
return ErrorExpected(expected, example);
+ }
return Result::Ok;
}
@@ -554,7 +556,6 @@ Result WastParser::ParseValueTypeList(TypeVector* out_type_list) {
while (PeekMatch(TokenType::ValueType))
out_type_list->push_back(Consume().type());
- CHECK_RESULT(ErrorIfLpar({"i32", "i64", "f32", "f64"}));
return Result::Ok;
}
@@ -708,7 +709,7 @@ Result WastParser::ParseScript(std::unique_ptr<Script>* out_script) {
Result WastParser::ParseModuleFieldList(Module* module) {
WABT_TRACE(ParseModuleFieldList);
- while (PeekMatch(TokenType::Lpar)) {
+ while (IsModuleField(PeekPair())) {
if (Failed(ParseModuleField(module))) {
CHECK_RESULT(Synchronize(IsModuleField));
}
@@ -772,7 +773,7 @@ Result WastParser::ParseExceptModuleField(Module* module) {
auto field = MakeUnique<ExceptionModuleField>(GetLocation());
EXPECT(Except);
ParseBindVarOpt(&field->except.name);
- ParseValueTypeList(&field->except.sig);
+ CHECK_RESULT(ParseValueTypeList(&field->except.sig));
EXPECT(Rpar);
module->AppendField(std::move(field));
return Result::Ok;
@@ -947,7 +948,7 @@ Result WastParser::ParseImportModuleField(Module* module) {
Consume();
ParseBindVarOpt(&name);
auto import = MakeUnique<ExceptionImport>(name);
- ParseValueTypeList(&import->except.sig);
+ CHECK_RESULT(ParseValueTypeList(&import->except.sig));
EXPECT(Rpar);
field = MakeUnique<ImportModuleField>(std::move(import), loc);
break;
@@ -1155,7 +1156,7 @@ Result WastParser::ParseBoundValueTypeList(TokenType token,
bindings->emplace(name, Binding(loc, types->size()));
types->push_back(type);
} else {
- ParseValueTypeList(types);
+ CHECK_RESULT(ParseValueTypeList(types));
}
EXPECT(Rpar);
}
@@ -1165,7 +1166,7 @@ Result WastParser::ParseBoundValueTypeList(TokenType token,
Result WastParser::ParseResultList(TypeVector* result_types) {
WABT_TRACE(ParseResultList);
while (MatchLpar(TokenType::Result)) {
- ParseValueTypeList(result_types);
+ CHECK_RESULT(ParseValueTypeList(result_types));
EXPECT(Rpar);
}
return Result::Ok;