deferred statement bugfixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 30 Jul 2020 22:58:47 +0000 (17:58 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 30 Jul 2020 22:58:47 +0000 (17:58 -0500)
onyx
src/onyxwasm.c

diff --git a/onyx b/onyx
index 1950f6fb5dc3d18974c78a16652e7824d94173b3..3cab3d483ca8c30499bf05a483639ec8a28ded7a 100755 (executable)
Binary files a/onyx and b/onyx differ
index 2b2c8e85399e4b2b17b25b973578d42aed36c5b3..c1d963aae82832832244fa33a9cff96b706f0f16 100644 (file)
@@ -549,11 +549,11 @@ COMPILE_FUNC(while, AstWhile* while_node) {
         compile_statement(mod, &code, while_node->stmt);
     }
 
+    compile_deferred_stmts(mod, &code, (AstNode *) while_node);
+
     bh_arr_pop(mod->structured_jump_target);
     bh_arr_pop(mod->structured_jump_target);
 
-    compile_deferred_stmts(mod, &code, (AstNode *) while_node);
-
     WID(WI_JUMP, 0x00);
 
     WI(WI_LOOP_END);
@@ -618,6 +618,8 @@ COMPILE_FUNC(defer, AstDefer* defer) {
 }
 
 COMPILE_FUNC(deferred_stmts, AstNode* node) {
+    if (bh_arr_length(mod->deferred_stmts) == 0) return;
+
     bh_arr(WasmInstruction) code = *pcode;
 
     u64 depth = bh_arr_length(mod->structured_jump_target);