diff options
author | Diego Frias <styx5242@gmail.com> | 2023-09-15 13:49:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-15 13:49:31 -0700 |
commit | b22be5a08611c53e8a893bbab049e6f18da6c55a (patch) | |
tree | 9b998aee94bada6db5b5715afe99d806167c8d52 /src/wat-writer.cc | |
parent | 0869da3eb84616b0dabefc34ea0d5326c1f43888 (diff) | |
download | wabt-b22be5a08611c53e8a893bbab049e6f18da6c55a.tar.gz wabt-b22be5a08611c53e8a893bbab049e6f18da6c55a.tar.bz2 wabt-b22be5a08611c53e8a893bbab049e6f18da6c55a.zip |
Implement custom section reading/writing (#2284)
Diffstat (limited to 'src/wat-writer.cc')
-rw-r--r-- | src/wat-writer.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/wat-writer.cc b/src/wat-writer.cc index d696894e..88ff60ba 100644 --- a/src/wat-writer.cc +++ b/src/wat-writer.cc @@ -164,6 +164,7 @@ class WatWriter : ModuleContext { void WriteTypeEntry(const TypeEntry& type); void WriteField(const Field& field); void WriteStartFunction(const Var& start); + void WriteCustom(const Custom& custom); class ExprVisitorDelegate; @@ -1613,6 +1614,13 @@ void WatWriter::WriteStartFunction(const Var& start) { WriteCloseNewline(); } +void WatWriter::WriteCustom(const Custom& custom) { + WriteOpenSpace("@custom"); + WriteQuotedString(custom.name, NextChar::Space); + WriteQuotedData(custom.data.data(), custom.data.size()); + WriteCloseNewline(); +} + Result WatWriter::WriteModule() { BuildInlineExportMap(); BuildInlineImportMap(); @@ -1659,6 +1667,11 @@ Result WatWriter::WriteModule() { break; } } + if (options_.features.annotations_enabled()) { + for (const Custom& custom : module.customs) { + WriteCustom(custom); + } + } WriteCloseNewline(); /* force the newline to be written */ WriteNextChar(); |