From 2bb4b33e296f999d45b95b2252dfaa11e2ea61b5 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 4 Nov 2015 15:40:33 -0800 Subject: memory --- src/wasm.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/wasm.h') diff --git a/src/wasm.h b/src/wasm.h index 6655a167e..8b2f9ad94 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -798,6 +798,19 @@ public: } }; +class Memory { +public: + struct Segment { + size_t offset; + const char* data; + }; + + size_t initial, max; + std::vector segments; + + Memory() : initial(0), max(0) {} +}; + class Module { public: // wasm contents @@ -806,18 +819,20 @@ public: std::vector exports; Table table; std::vector functions; - size_t memorySize; + Memory memory; - Module() : memorySize(0) {} + Module() {} friend std::ostream& operator<<(std::ostream &o, Module module) { unsigned indent = 0; printOpening(o, "module", true); incIndent(o, indent); doIndent(o, indent); - if (module.memorySize) { - printOpening(o, "memory") << " " << module.memorySize << " " << module.memorySize << ")\n"; + printOpening(o, "memory") << " " << module.memory.initial << " " << module.memory.max; + for (auto segment : module.memory.segments) { + o << " (segment " << segment.offset << " \"" << segment.data << "\")"; } + o << ")\n"; for (auto& curr : module.functionTypes) { doIndent(o, indent); curr.second->print(o, indent, true); -- cgit v1.2.3