Mercurial > vim
comparison src/vim9compile.c @ 25660:7b80b25a5c2b v8.2.3366
patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Commit: https://github.com/vim/vim/commit/093165c899f1620543844d1c1a7a05975697c286
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 22 13:35:31 2021 +0200
patch 8.2.3366: Vim9: debugging elseif does not stop before condition
Problem: Vim9: debugging elseif does not stop before condition.
Solution: Move debug statement to after the jump. (closes https://github.com/vim/vim/issues/8781)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 22 Aug 2021 13:45:04 +0200 |
parents | 483b40e87ca5 |
children | 812c75fd255c |
comparison
equal
deleted
inserted
replaced
25659:eeb0364f03a2 | 25660:7b80b25a5c2b |
---|---|
2385 return FALSE; | 2385 return FALSE; |
2386 } | 2386 } |
2387 | 2387 |
2388 /* | 2388 /* |
2389 * Get the index of the current instruction. | 2389 * Get the index of the current instruction. |
2390 * This compenstates for a preceding ISN_CMDMOD and ISN_PROF_START. | 2390 * This compensates for a preceding ISN_CMDMOD and ISN_PROF_START. |
2391 */ | 2391 */ |
2392 static int | 2392 static int |
2393 current_instr_idx(cctx_T *cctx) | 2393 current_instr_idx(cctx_T *cctx) |
2394 { | 2394 { |
2395 garray_T *instr = &cctx->ctx_instr; | 2395 garray_T *instr = &cctx->ctx_instr; |
7730 return p; | 7730 return p; |
7731 } | 7731 } |
7732 | 7732 |
7733 if (cctx->ctx_skip == SKIP_UNKNOWN) | 7733 if (cctx->ctx_skip == SKIP_UNKNOWN) |
7734 { | 7734 { |
7735 int moved_cmdmod = FALSE; | 7735 int moved_cmdmod = FALSE; |
7736 int saved_debug = FALSE; | |
7737 isn_T debug_isn; | |
7736 | 7738 |
7737 // Move any CMDMOD instruction to after the jump | 7739 // Move any CMDMOD instruction to after the jump |
7738 if (((isn_T *)instr->ga_data)[instr->ga_len - 1].isn_type == ISN_CMDMOD) | 7740 if (((isn_T *)instr->ga_data)[instr->ga_len - 1].isn_type == ISN_CMDMOD) |
7739 { | 7741 { |
7740 if (GA_GROW_FAILS(instr, 1)) | 7742 if (GA_GROW_FAILS(instr, 1)) |
7743 ((isn_T *)instr->ga_data)[instr->ga_len - 1]; | 7745 ((isn_T *)instr->ga_data)[instr->ga_len - 1]; |
7744 --instr->ga_len; | 7746 --instr->ga_len; |
7745 moved_cmdmod = TRUE; | 7747 moved_cmdmod = TRUE; |
7746 } | 7748 } |
7747 | 7749 |
7750 // Remove the already generated ISN_DEBUG, it is written below the | |
7751 // ISN_FOR instruction. | |
7752 if (cctx->ctx_compile_type == CT_DEBUG && instr->ga_len > 0 | |
7753 && ((isn_T *)instr->ga_data)[instr->ga_len - 1] | |
7754 .isn_type == ISN_DEBUG) | |
7755 { | |
7756 --instr->ga_len; | |
7757 debug_isn = ((isn_T *)instr->ga_data)[instr->ga_len]; | |
7758 saved_debug = TRUE; | |
7759 } | |
7760 | |
7748 if (compile_jump_to_end(&scope->se_u.se_if.is_end_label, | 7761 if (compile_jump_to_end(&scope->se_u.se_if.is_end_label, |
7749 JUMP_ALWAYS, cctx) == FAIL) | 7762 JUMP_ALWAYS, cctx) == FAIL) |
7750 return NULL; | 7763 return NULL; |
7751 // previous "if" or "elseif" jumps here | 7764 // previous "if" or "elseif" jumps here |
7752 isn = ((isn_T *)instr->ga_data) + scope->se_u.se_if.is_if_label; | 7765 isn = ((isn_T *)instr->ga_data) + scope->se_u.se_if.is_if_label; |
7753 isn->isn_arg.jump.jump_where = instr->ga_len; | 7766 isn->isn_arg.jump.jump_where = instr->ga_len; |
7767 | |
7754 if (moved_cmdmod) | 7768 if (moved_cmdmod) |
7755 ++instr->ga_len; | 7769 ++instr->ga_len; |
7770 | |
7771 if (saved_debug) | |
7772 { | |
7773 // move the debug instruction here | |
7774 if (GA_GROW_FAILS(instr, 1)) | |
7775 return NULL; | |
7776 ((isn_T *)instr->ga_data)[instr->ga_len] = debug_isn; | |
7777 ++instr->ga_len; | |
7778 } | |
7756 } | 7779 } |
7757 | 7780 |
7758 // compile "expr"; if we know it evaluates to FALSE skip the block | 7781 // compile "expr"; if we know it evaluates to FALSE skip the block |
7759 CLEAR_FIELD(ppconst); | 7782 CLEAR_FIELD(ppconst); |
7760 if (cctx->ctx_skip == SKIP_YES) | 7783 if (cctx->ctx_skip == SKIP_YES) |