diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-11-01 13:34:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-01 13:34:53 -0700 |
commit | 77c66027f0dcbd7160f78c5de4943372836ab142 (patch) | |
tree | 582c3f937247c14b773e9364d5a901d9db9bcfdd /src/ir/module-utils.h | |
parent | 7d3ddd09d5f68945160cda3f3749a217a13928bf (diff) | |
download | binaryen-77c66027f0dcbd7160f78c5de4943372836ab142.tar.gz binaryen-77c66027f0dcbd7160f78c5de4943372836ab142.tar.bz2 binaryen-77c66027f0dcbd7160f78c5de4943372836ab142.zip |
Emit imports before defined things in text format (#1715)
That is the correct order in the text format, wabt errors otherwise.
See AssemblyScript/assemblyscript#310
Diffstat (limited to 'src/ir/module-utils.h')
-rw-r--r-- | src/ir/module-utils.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index 1d0512401..d6ee50dd0 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -128,7 +128,35 @@ inline void copyModule(Module& in, Module& out) { out.debugInfoFileNames = in.debugInfoFileNames; } -// Convenient iteration over imported/non-imported functions/globals +// Convenient iteration over imported/non-imported module elements + +template<typename T> +inline void iterImportedMemories(Module& wasm, T visitor) { + if (wasm.memory.exists && wasm.memory.imported()) { + visitor(&wasm.memory); + } +} + +template<typename T> +inline void iterDefinedMemories(Module& wasm, T visitor) { + if (wasm.memory.exists && !wasm.memory.imported()) { + visitor(&wasm.memory); + } +} + +template<typename T> +inline void iterImportedTables(Module& wasm, T visitor) { + if (wasm.table.exists && wasm.table.imported()) { + visitor(&wasm.table); + } +} + +template<typename T> +inline void iterDefinedTables(Module& wasm, T visitor) { + if (wasm.table.exists && !wasm.table.imported()) { + visitor(&wasm.table); + } +} template<typename T> inline void iterImportedGlobals(Module& wasm, T visitor) { |