summaryrefslogtreecommitdiff
path: root/src/s2wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-11 18:52:12 -0500
committerAlon Zakai <alonzakai@gmail.com>2015-12-11 18:52:12 -0500
commit2ceaaf0c976e4fdb9bb10bdf1d5fb8ef56406de5 (patch)
tree79cf4d5a2fcece52db7dbcbc38efa8ca252cd69b /src/s2wasm.h
parent15f1677713a2b9eb6180788ae3f26bc1ecffec5a (diff)
downloadbinaryen-2ceaaf0c976e4fdb9bb10bdf1d5fb8ef56406de5.tar.gz
binaryen-2ceaaf0c976e4fdb9bb10bdf1d5fb8ef56406de5.tar.bz2
binaryen-2ceaaf0c976e4fdb9bb10bdf1d5fb8ef56406de5.zip
fix up static addresses in s2wasm; basics test is complete
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r--src/s2wasm.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index 1731aa2e4..57982f857 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -22,13 +22,14 @@ class S2WasmBuilder {
public:
S2WasmBuilder(AllocatingModule& wasm, char *s) : wasm(wasm), allocator(wasm.allocator), s(s) {
process();
+ fix();
}
private:
// state
size_t nextStatic = 0; // location of next static allocation, i.e., the data segment
- std::map<Name, size_t> staticAddresses; // name => address
+ std::map<Name, int32_t> staticAddresses; // name => address
typedef std::pair<Const*, Name> Addressing;
std::vector<Addressing> addressings; // we fix these up
@@ -461,6 +462,17 @@ private:
nextStatic += size;
nextStatic = (nextStatic + ALIGN - 1) & -ALIGN;
}
+
+ void fix() {
+ for (auto& pair : addressings) {
+ Const* curr = pair.first;
+ Name name = pair.second;
+ curr->value = Literal(staticAddresses[name]);
+ assert(curr->value.i32 > 0);
+ curr->type = i32;
+ }
+ }
+
};
} // namespace wasm