summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWasm/Parser/Parser.cpp143
1 files changed, 39 insertions, 104 deletions
diff --git a/Userland/Libraries/LibWasm/Parser/Parser.cpp b/Userland/Libraries/LibWasm/Parser/Parser.cpp
index d2e4b7bca2..f35b26b6ea 100644
--- a/Userland/Libraries/LibWasm/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWasm/Parser/Parser.cpp
@@ -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());
- continue;
- } else {
- return section.error();
- }
- }
- case TypeSection::section_id: {
- if (auto section = TypeSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case ImportSection::section_id: {
- if (auto section = ImportSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case FunctionSection::section_id: {
- if (auto section = FunctionSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case TableSection::section_id: {
- if (auto section = TableSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case MemorySection::section_id: {
- if (auto section = MemorySection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case GlobalSection::section_id: {
- if (auto section = GlobalSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case ExportSection::section_id: {
- if (auto section = ExportSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case StartSection::section_id: {
- if (auto section = StartSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case ElementSection::section_id: {
- if (auto section = ElementSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case CodeSection::section_id: {
- if (auto section = CodeSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case DataSection::section_id: {
- if (auto section = DataSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
- case DataCountSection::section_id: {
- if (auto section = DataCountSection::parse(section_stream); !section.is_error()) {
- sections.append(section.release_value());
- continue;
- } else {
- return section.error();
- }
- }
+ case CustomSection::section_id:
+ sections.append(TRY(CustomSection::parse(section_stream)));
+ continue;
+ case TypeSection::section_id:
+ sections.append(TRY(TypeSection::parse(section_stream)));
+ continue;
+ case ImportSection::section_id:
+ sections.append(TRY(ImportSection::parse(section_stream)));
+ continue;
+ case FunctionSection::section_id:
+ sections.append(TRY(FunctionSection::parse(section_stream)));
+ continue;
+ case TableSection::section_id:
+ sections.append(TRY(TableSection::parse(section_stream)));
+ continue;
+ case MemorySection::section_id:
+ sections.append(TRY(MemorySection::parse(section_stream)));
+ continue;
+ case GlobalSection::section_id:
+ sections.append(TRY(GlobalSection::parse(section_stream)));
+ continue;
+ case ExportSection::section_id:
+ sections.append(TRY(ExportSection::parse(section_stream)));
+ continue;
+ case StartSection::section_id:
+ sections.append(TRY(StartSection::parse(section_stream)));
+ continue;
+ case ElementSection::section_id:
+ sections.append(TRY(ElementSection::parse(section_stream)));
+ continue;
+ case CodeSection::section_id:
+ sections.append(TRY(CodeSection::parse(section_stream)));
+ continue;
+ case DataSection::section_id:
+ sections.append(TRY(DataSection::parse(section_stream)));
+ continue;
+ case DataCountSection::section_id:
+ sections.append(TRY(DataCountSection::parse(section_stream)));
+ continue;
default:
return with_eof_check(stream, ParseError::InvalidIndex);
}