|
@@ -1066,8 +1066,16 @@ ParseResult<DataSection> DataSection::parse(InputStream& stream)
|
|
|
ParseResult<DataCountSection> DataCountSection::parse([[maybe_unused]] InputStream& stream)
|
|
|
{
|
|
|
ScopeLogger<WASM_BINPARSER_DEBUG> logger("DataCountSection");
|
|
|
- // FIXME: Implement parsing optional values!
|
|
|
- return with_eof_check(stream, ParseError::NotImplemented);
|
|
|
+ u32 value;
|
|
|
+ if (!LEB128::read_unsigned(stream, value)) {
|
|
|
+ if (stream.unreliable_eof()) {
|
|
|
+ // The section simply didn't contain anything.
|
|
|
+ return DataCountSection { {} };
|
|
|
+ }
|
|
|
+ return ParseError::ExpectedSize;
|
|
|
+ }
|
|
|
+
|
|
|
+ return DataCountSection { value };
|
|
|
}
|
|
|
|
|
|
ParseResult<Module> Module::parse(InputStream& stream)
|
|
@@ -1203,6 +1211,14 @@ ParseResult<Module> Module::parse(InputStream& stream)
|
|
|
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();
|
|
|
+ }
|
|
|
+ }
|
|
|
default:
|
|
|
return with_eof_check(stream, ParseError::InvalidIndex);
|
|
|
}
|