mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWasm: Use TRY in Module::parse
This commit is contained in:
parent
97d15e9b8f
commit
8a9d4246f1
Notes:
sideshowbarker
2024-07-17 06:51:40 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/8a9d4246f1 Pull-request: https://github.com/SerenityOS/serenity/pull/15455 Reviewed-by: https://github.com/linusg ✅
1 changed files with 39 additions and 104 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue