diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-02-01 14:43:19 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-02-01 15:01:19 -0800 |
commit | 5a2217d4d50c5302562ba29fb38a60edbe84d262 (patch) | |
tree | 25ee847d1d3d18361a3cbd89515723f448ac5c8b /src/wasm-interpreter.h | |
parent | f18096a0d7d355499a218e1ff4196b296a1f82b1 (diff) | |
download | binaryen-5a2217d4d50c5302562ba29fb38a60edbe84d262.tar.gz binaryen-5a2217d4d50c5302562ba29fb38a60edbe84d262.tar.bz2 binaryen-5a2217d4d50c5302562ba29fb38a60edbe84d262.zip |
add return node
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r-- | src/wasm-interpreter.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index bcd8dee28..086b9751e 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -34,7 +34,8 @@ using namespace cashew; // Utilities -IString WASM("wasm"); +IString WASM("wasm"), + RETURN_FLOW("*return:)*"); enum { pageSize = 64*1024, @@ -623,6 +624,17 @@ private: if (ifFalse.breaking()) return ifFalse; return condition.value.geti32() ? ifTrue : ifFalse; // ;-) } + Flow visitReturn(Return *curr) { + NOTE_ENTER("Return"); + Flow flow; + if (curr->value) { + flow = visit(curr->value); + if (flow.breaking()) return flow; + NOTE_EVAL1(flow.value); + } + flow.breakTo = RETURN_FLOW; + return flow; + } Flow visitHost(Host *curr) { NOTE_ENTER("Host"); switch (curr->op) { @@ -738,7 +750,7 @@ private: #endif Flow flow = ExpressionRunner(*this, scope).visit(function->body); - assert(!flow.breaking()); // cannot still be breaking, it means we missed our stop + assert(!flow.breaking() || flow.breakTo == RETURN_FLOW); // cannot still be breaking, it means we missed our stop Literal ret = flow.value; if (function->result == none) ret = Literal(); assert(function->result == ret.type); |