mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:47:34 +00:00
LibWasm: Stub out/implement parsing of all ElementSection segments
Previously, this was parsing only one kind because I mistakenly assumed that they all had the same shape, now it can parse two kinds, and will return NotImplemented for the rest.
This commit is contained in:
parent
4d9246ac9d
commit
a5194274af
5 changed files with 235 additions and 81 deletions
|
@ -169,42 +169,56 @@ void Printer::print(const Wasm::ElementSection& section)
|
|||
print("(section element\n");
|
||||
{
|
||||
TemporaryChange change { m_indent, m_indent + 1 };
|
||||
print(section.function());
|
||||
for (auto& entry : section.segments())
|
||||
entry.visit([this](auto& segment) { print(segment); });
|
||||
}
|
||||
print_indent();
|
||||
print(")\n");
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::Element& element)
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType0&)
|
||||
{
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType1& segment)
|
||||
{
|
||||
print_indent();
|
||||
print("(element\n");
|
||||
print("(element segment kind 1\n");
|
||||
{
|
||||
TemporaryChange change { m_indent, m_indent + 1 };
|
||||
print_indent();
|
||||
print("(table with index {})\n", element.table().value());
|
||||
print_indent();
|
||||
print("(offset\n");
|
||||
{
|
||||
TemporaryChange change { m_indent, m_indent + 1 };
|
||||
print(element.offset());
|
||||
for (auto& index : segment.function_indices) {
|
||||
print_indent();
|
||||
print("(function index {})\n", index.value());
|
||||
}
|
||||
print_indent();
|
||||
print(")\n");
|
||||
print_indent();
|
||||
print("(initializers\n");
|
||||
{
|
||||
TemporaryChange change { m_indent, m_indent + 1 };
|
||||
for (auto& index : element.init())
|
||||
print("(init function {})\n", index.value());
|
||||
}
|
||||
print_indent();
|
||||
print(")\n");
|
||||
}
|
||||
print_indent();
|
||||
print(")\n");
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType2&)
|
||||
{
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType3&)
|
||||
{
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType4&)
|
||||
{
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType5&)
|
||||
{
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType6&)
|
||||
{
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ElementSection::SegmentType7&)
|
||||
{
|
||||
}
|
||||
|
||||
void Printer::print(const Wasm::ExportSection& section)
|
||||
{
|
||||
print_indent();
|
||||
|
|
|
@ -21,13 +21,19 @@ struct Printer {
|
|||
void print(const Wasm::CodeSection&);
|
||||
void print(const Wasm::CodeSection::Code&);
|
||||
void print(const Wasm::CodeSection::Func&);
|
||||
void print(const Wasm::ConstrainedStream&);
|
||||
void print(const Wasm::CustomSection&);
|
||||
void print(const Wasm::DataCountSection&);
|
||||
void print(const Wasm::DataSection&);
|
||||
void print(const Wasm::DataSection::Data&);
|
||||
void print(const Wasm::ElementSection&);
|
||||
void print(const Wasm::ElementSection::Element&);
|
||||
void print(const Wasm::ElementSection::SegmentType0&);
|
||||
void print(const Wasm::ElementSection::SegmentType1&);
|
||||
void print(const Wasm::ElementSection::SegmentType2&);
|
||||
void print(const Wasm::ElementSection::SegmentType3&);
|
||||
void print(const Wasm::ElementSection::SegmentType4&);
|
||||
void print(const Wasm::ElementSection::SegmentType5&);
|
||||
void print(const Wasm::ElementSection::SegmentType6&);
|
||||
void print(const Wasm::ElementSection::SegmentType7&);
|
||||
void print(const Wasm::ExportSection&);
|
||||
void print(const Wasm::ExportSection::Export&);
|
||||
void print(const Wasm::Expression&);
|
||||
|
@ -46,8 +52,6 @@ struct Printer {
|
|||
void print(const Wasm::MemoryType&);
|
||||
void print(const Wasm::Module&);
|
||||
void print(const Wasm::Module::Function&);
|
||||
void print(const Wasm::ReconsumableStream&);
|
||||
void print(const Wasm::ResultType&);
|
||||
void print(const Wasm::StartSection&);
|
||||
void print(const Wasm::StartSection::StartFunction&);
|
||||
void print(const Wasm::TableSection&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue