summaryrefslogtreecommitdiff
path: root/src/s2wasm-main.cpp
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2016-04-27 09:18:37 -0700
committerDerek Schuff <dschuff@chromium.org>2016-04-27 09:18:37 -0700
commitd63486d0ef085f905dafdb14a76cfb2ca1fb452e (patch)
tree33fd133e9c3313c458ae756f0e7b397dfb198d28 /src/s2wasm-main.cpp
parent206338a6c4e3f9739abd7a2ad082d1770b3a628f (diff)
downloadbinaryen-d63486d0ef085f905dafdb14a76cfb2ca1fb452e.tar.gz
binaryen-d63486d0ef085f905dafdb14a76cfb2ca1fb452e.tar.bz2
binaryen-d63486d0ef085f905dafdb14a76cfb2ca1fb452e.zip
Split construction, scanning, and building phases of S2WasmBuilder (#400)
Instead of doing all of the S2Wasm work in the constructor, split construction, scanning (to determine implemented functions) and building of the wasm module. This allows the linker to get the symbol information (e.g. implemented functions) without having to build an entire module (which will be useful for archives) and to allow the linker to link a new object into the existing one by building the wasm module in place on the existing module.
Diffstat (limited to 'src/s2wasm-main.cpp')
-rw-r--r--src/s2wasm-main.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/s2wasm-main.cpp b/src/s2wasm-main.cpp
index 435eb560f..7b0e4c179 100644
--- a/src/s2wasm-main.cpp
+++ b/src/s2wasm-main.cpp
@@ -104,7 +104,13 @@ int main(int argc, const char *argv[]) {
Linker linker(globalBase, stackAllocation, initialMem, maxMem,
ignoreUnknownSymbols, startFunction, options.debug);
- S2WasmBuilder s2wasm(linker.getOutput(), input.c_str(), options.debug);
+ S2WasmBuilder mainbuilder(input.c_str(), options.debug);
+ linker.linkObject(mainbuilder);
+
+ // In the future, there will be code to open additional files/buffers and
+ // link additional objects, as well as archive members (which only get linked if needed), e.g.:
+ // S2WasmBuilder lazyObject(some_other_buffer, options.debug)
+ // linker.linkLazyObject(lazyObject); // calls builder.scan to get symbol info, then build
linker.layout();