blob: e4cfcc18ba76cbb5b2e895a166c31948f966e15b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWasm/Types.h>
namespace Wasm {
String instruction_name(const OpCode& opcode);
struct Printer {
explicit Printer(OutputStream& stream, size_t initial_indent = 0)
: m_stream(stream)
, m_indent(initial_indent)
{
}
void print(const Wasm::BlockType&);
void print(const Wasm::CodeSection&);
void print(const Wasm::CodeSection::Code&);
void print(const Wasm::CodeSection::Func&);
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::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&);
void print(const Wasm::FunctionSection&);
void print(const Wasm::FunctionType&);
void print(const Wasm::GlobalSection&);
void print(const Wasm::GlobalSection::Global&);
void print(const Wasm::GlobalType&);
void print(const Wasm::ImportSection&);
void print(const Wasm::ImportSection::Import&);
void print(const Wasm::Instruction&);
void print(const Wasm::Limits&);
void print(const Wasm::Locals&);
void print(const Wasm::MemorySection&);
void print(const Wasm::MemorySection::Memory&);
void print(const Wasm::MemoryType&);
void print(const Wasm::Module&);
void print(const Wasm::Module::Function&);
void print(const Wasm::StartSection&);
void print(const Wasm::StartSection::StartFunction&);
void print(const Wasm::TableSection&);
void print(const Wasm::TableSection::Table&);
void print(const Wasm::TableType&);
void print(const Wasm::TypeSection&);
void print(const Wasm::ValueType&);
private:
void print_indent();
template<typename... Args>
void print(CheckedFormatString<Args...> fmt, Args&&... args)
{
StringBuilder builder;
builder.appendff(fmt.view(), forward<Args>(args)...);
m_stream.write_or_error(builder.string_view().bytes());
}
OutputStream& m_stream;
size_t m_indent { 0 };
};
}
|