summaryrefslogtreecommitdiff
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
parent15f1677713a2b9eb6180788ae3f26bc1ecffec5a (diff)
downloadbinaryen-2ceaaf0c976e4fdb9bb10bdf1d5fb8ef56406de5.tar.gz
binaryen-2ceaaf0c976e4fdb9bb10bdf1d5fb8ef56406de5.tar.bz2
binaryen-2ceaaf0c976e4fdb9bb10bdf1d5fb8ef56406de5.zip
fix up static addresses in s2wasm; basics test is complete
-rw-r--r--src/s2wasm.h14
-rw-r--r--test/dot_s/basics.wast2
2 files changed, 14 insertions, 2 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
diff --git a/test/dot_s/basics.wast b/test/dot_s/basics.wast
index e7efb9202..dffc6079c 100644
--- a/test/dot_s/basics.wast
+++ b/test/dot_s/basics.wast
@@ -4,7 +4,7 @@
(block $fake_return_waka123
(block
(call $puts
- (none.const ?)
+ (i32.const 16)
)
(block $BB0_5
(block $BB0_4