From 1f84970eab7c99122e50d475c4328ef1e76b7d53 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 20 Nov 2015 20:47:48 -0800 Subject: handle labels on blocks in asm2wasm --- src/asm2wasm.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 014658eb5..5f18a5811 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -1150,7 +1150,24 @@ Function* Asm2WasmBuilder::processFunction(Ref ast) { ret->value = !!ast[1] ? process(ast[1]) : nullptr; return ret; } else if (what == BLOCK) { - return processStatements(ast[1], 0); + Name name; + if (parentLabel.is()) { + name = getBreakLabelName(parentLabel); + parentLabel = IString(); + } + auto ret = processStatements(ast[1], 0); + if (name.is()) { + Block* block = ret->dyn_cast(); + if (block && block->name.isNull()) { + block->name = name; + } else { + block = allocator.alloc(); + block->name = name; + block->list.push_back(ret); + ret = block; + } + } + return ret; } else if (what == BREAK) { auto ret = allocator.alloc(); assert(breakStack.size() > 0); -- cgit v1.2.3