From 927242bc9be3c5aaace97fd01de9eb44f6c71abd Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 11 Dec 2015 18:09:39 -0500 Subject: fix out label in loop in s2wasm --- src/s2wasm.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/s2wasm.h b/src/s2wasm.h index a04ab65bd..9766471f7 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -279,6 +279,7 @@ private: typedef std::pair Addressing; std::vector addressings; std::vector loopBlocks; // we need to clear their names + std::set seenLabels; // if we already used a label, we don't need it in a loop (there is a block above it, with that label) // main loop while (1) { skipWhitespace(); @@ -354,6 +355,7 @@ private: curr->name = getStr(); bstack.back()->list.push_back(curr); bstack.push_back(curr); + seenLabels.insert(curr->name); } else if (match("BB")) { s -= 2; Name name = getStrToColon(); @@ -373,11 +375,14 @@ private: if (*s == 'l') { auto curr = allocator.alloc(); bstack.back()->list.push_back(curr); - curr->out = name; + curr->in = name; mustMatch("loop"); - curr->in = getStr(); + Name out = getStr(); + if (seenLabels.count(out) == 0) { + curr->out = out; + } auto block = allocator.alloc(); - block->name = curr->in; // temporary, fake + block->name = out; // temporary, fake curr->body = block; loopBlocks.push_back(block); bstack.push_back(block); -- cgit v1.2.3