LibWasm: Use TRY in Module::parse

This commit is contained in:
Hendiadyoin1 2022-10-03 13:07:26 +02:00 committed by Linus Groh
parent 97d15e9b8f
commit 8a9d4246f1
Notes: sideshowbarker 2024-07-17 06:51:40 +09:00

View file

@ -1251,110 +1251,45 @@ ParseResult<Module> Module::parse(InputStream& stream)
};
switch (section_id) {
case CustomSection::section_id: {
if (auto section = CustomSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case CustomSection::section_id:
sections.append(TRY(CustomSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case TypeSection::section_id: {
if (auto section = TypeSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case TypeSection::section_id:
sections.append(TRY(TypeSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case ImportSection::section_id: {
if (auto section = ImportSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case ImportSection::section_id:
sections.append(TRY(ImportSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case FunctionSection::section_id: {
if (auto section = FunctionSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case FunctionSection::section_id:
sections.append(TRY(FunctionSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case TableSection::section_id: {
if (auto section = TableSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case TableSection::section_id:
sections.append(TRY(TableSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case MemorySection::section_id: {
if (auto section = MemorySection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case MemorySection::section_id:
sections.append(TRY(MemorySection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case GlobalSection::section_id: {
if (auto section = GlobalSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case GlobalSection::section_id:
sections.append(TRY(GlobalSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case ExportSection::section_id: {
if (auto section = ExportSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case ExportSection::section_id:
sections.append(TRY(ExportSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case StartSection::section_id: {
if (auto section = StartSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case StartSection::section_id:
sections.append(TRY(StartSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case ElementSection::section_id: {
if (auto section = ElementSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case ElementSection::section_id:
sections.append(TRY(ElementSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case CodeSection::section_id: {
if (auto section = CodeSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case CodeSection::section_id:
sections.append(TRY(CodeSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case DataSection::section_id: {
if (auto section = DataSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case DataSection::section_id:
sections.append(TRY(DataSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
case DataCountSection::section_id: {
if (auto section = DataCountSection::parse(section_stream); !section.is_error()) {
sections.append(section.release_value());
case DataCountSection::section_id:
sections.append(TRY(DataCountSection::parse(section_stream)));
continue;
} else {
return section.error();
}
}
default:
return with_eof_check(stream, ParseError::InvalidIndex);
}