[njs] Fixes in generating "continue" and "break" statements.
Igor Sysoev
igor at sysoev.ru
Tue Oct 18 13:00:38 UTC 2016
details: http://hg.nginx.org/njs/rev/462f7d2113f9
branches:
changeset: 205:462f7d2113f9
user: Igor Sysoev <igor at sysoev.ru>
date: Tue Oct 18 15:48:13 2016 +0300
description:
Fixes in generating "continue" and "break" statements.
diffstat:
njs/njs_generator.c | 8 ++++----
njs/test/njs_unit_test.c | 3 +++
2 files changed, 7 insertions(+), 4 deletions(-)
diffs (38 lines):
diff -r d055824ff0f7 -r 462f7d2113f9 njs/njs_generator.c
--- a/njs/njs_generator.c Mon Oct 17 23:29:15 2016 +0300
+++ b/njs/njs_generator.c Tue Oct 18 15:48:13 2016 +0300
@@ -1089,8 +1089,8 @@ found:
patch = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_parser_patch_t));
if (nxt_fast_path(patch != NULL)) {
- patch->next = parser->block->continuation;
- parser->block->continuation = patch;
+ patch->next = block->continuation;
+ block->continuation = patch;
njs_generate_code(parser, njs_vmcode_jump_t, jump);
jump->code.operation = njs_vmcode_jump;
@@ -1133,8 +1133,8 @@ found:
patch = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_parser_patch_t));
if (nxt_fast_path(patch != NULL)) {
- patch->next = parser->block->exit;
- parser->block->exit = patch;
+ patch->next = block->exit;
+ block->exit = patch;
njs_generate_code(parser, njs_vmcode_jump_t, jump);
jump->code.operation = njs_vmcode_jump;
diff -r d055824ff0f7 -r 462f7d2113f9 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Mon Oct 17 23:29:15 2016 +0300
+++ b/njs/test/njs_unit_test.c Tue Oct 18 15:48:13 2016 +0300
@@ -1657,6 +1657,9 @@ static njs_unit_test_t njs_test[] =
"for (i in a) { if (a[i] > 4) continue; s += a[i] } s"),
nxt_string("10") },
+ { nxt_string("var a; for (a = 1; a; a--) switch (a) { case 0: continue }"),
+ nxt_string("undefined") },
+
/* break. */
{ nxt_string("break"),
More information about the nginx-devel
mailing list