summaryrefslogtreecommitdiff
path: root/src/ir/module-utils.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-12-09 15:27:25 -0800
committerGitHub <noreply@github.com>2019-12-09 15:27:25 -0800
commit247884e68b30dedeb01457d6c7e50d4bba5e4abc (patch)
tree0f493372db2029e895605a3d9761faa5863db8e0 /src/ir/module-utils.h
parent72bacfd46fb0ed4851c22344c3cc632e701ce022 (diff)
downloadbinaryen-247884e68b30dedeb01457d6c7e50d4bba5e4abc.tar.gz
binaryen-247884e68b30dedeb01457d6c7e50d4bba5e4abc.tar.bz2
binaryen-247884e68b30dedeb01457d6c7e50d4bba5e4abc.zip
Add a RoundTrip pass (#2516)
This pass writes and reads the module. This shows the effects of converting to and back from the binary format, and will be useful in testing dwarf debug support (where we'll need to see that writing and reading a module preserves debug info properly).
Diffstat (limited to 'src/ir/module-utils.h')
-rw-r--r--src/ir/module-utils.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index f2fda908c..e212ae8dc 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -105,8 +105,8 @@ inline Event* copyEvent(Event* event, Module& out) {
return ret;
}
-inline void copyModule(Module& in, Module& out) {
- // we use names throughout, not raw points, so simple copying is fine
+inline void copyModule(const Module& in, Module& out) {
+ // we use names throughout, not raw pointers, so simple copying is fine
// for everything *but* expressions
for (auto& curr : in.functionTypes) {
out.addFunctionType(make_unique<FunctionType>(*curr));
@@ -136,6 +136,20 @@ inline void copyModule(Module& in, Module& out) {
out.debugInfoFileNames = in.debugInfoFileNames;
}
+inline void clearModule(Module& wasm) {
+ wasm.functionTypes.clear();
+ wasm.exports.clear();
+ wasm.functions.clear();
+ wasm.globals.clear();
+ wasm.events.clear();
+ wasm.table.segments.clear();
+ wasm.memory.segments.clear();
+ wasm.start = Name();
+ wasm.userSections.clear();
+ wasm.debugInfoFileNames.clear();
+ wasm.updateMaps();
+}
+
// Renaming
// Rename functions along with all their uses.