1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:47:44 +00:00

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

View file

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