diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-04-18 15:54:55 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-04-18 15:54:55 -0700 |
commit | 0b5d70e43b4b984ed7a25cf16ee2ccece3812dbf (patch) | |
tree | 25511239f3fab4c7fe1a04a969044adc3978a5f3 /src | |
parent | 684ed50648fd45199edca7532c743b16a7050695 (diff) | |
download | binaryen-0b5d70e43b4b984ed7a25cf16ee2ccece3812dbf.tar.gz binaryen-0b5d70e43b4b984ed7a25cf16ee2ccece3812dbf.tar.bz2 binaryen-0b5d70e43b4b984ed7a25cf16ee2ccece3812dbf.zip |
fix br_table order of evaluation, the value is first
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-interpreter.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 8f3f09ed1..c57c764e4 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -292,24 +292,23 @@ private: } Flow visitSwitch(Switch *curr) { NOTE_ENTER("Switch"); - Flow flow = visit(curr->condition); - if (flow.breaking()) return flow; - NOTE_EVAL1(flow.value); - int64_t index = flow.value.getInteger(); - + Flow flow; + Literal value; if (curr->value) { flow = visit(curr->value); if (flow.breaking()) return flow; - NOTE_EVAL1(flow.value); - } else { - flow = Flow(); + value = flow.value; + NOTE_EVAL1(value); } - + flow = visit(curr->condition); + if (flow.breaking()) return flow; + int64_t index = flow.value.getInteger(); Name target = curr->default_; if (index >= 0 && (size_t)index < curr->targets.size()) { target = curr->targets[(size_t)index]; } flow.breakTo = target; + flow.value = value; return flow; } |