summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/wasm.h b/src/wasm.h
index aea38f9b7..d53c4e629 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1035,7 +1035,21 @@ public:
printOpening(o, "memory") << " " << module.memory.initial;
if (module.memory.max) o << " " << module.memory.max;
for (auto segment : module.memory.segments) {
- o << " (segment " << segment.offset << " \"" << segment.data << "\")";
+ o << " (segment " << segment.offset << " \"";
+ for (size_t i = 0; i < segment.size; i++) {
+ char c = segment.data[i];
+ switch (c) {
+ case '\n': o << "\\n"; break;
+ case '\r': o << "\\r"; break;
+ case '\t': o << "\\t"; break;
+ case '\f': o << "\\f"; break;
+ case '\b': o << "\\b"; break;
+ case '\\': o << "\\\\"; break;
+ case 0: o << "\\0"; break;
+ default: o << c; // TODO: escaping
+ }
+ }
+ o << "\")";
}
o << ")\n";
for (auto& curr : module.functionTypes) {