Mercurial > vim
comparison src/vim9execute.c @ 21399:5cb6e676defd v8.2.1250
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Commit: https://github.com/vim/vim/commit/2f8ce0ae8a8247563be0a77a308130e767e0566e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jul 19 19:47:35 2020 +0200
patch 8.2.1250: Vim9: cannot use the g:, b:, t: and w: namespaces
Problem: Vim9: cannot use the g:, b:, t: and w: namespaces.
Solution: Add instructions to push a dict for the namespaces. (closes https://github.com/vim/vim/issues/6480)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Jul 2020 20:00:04 +0200 |
parents | 320581a133d9 |
children | aa7675a4a0cd |
comparison
equal
deleted
inserted
replaced
21398:5f89f2a27c66 | 21399:5cb6e676defd |
---|---|
1087 case ISN_LOADT: | 1087 case ISN_LOADT: |
1088 { | 1088 { |
1089 dictitem_T *di = NULL; | 1089 dictitem_T *di = NULL; |
1090 hashtab_T *ht = NULL; | 1090 hashtab_T *ht = NULL; |
1091 char namespace; | 1091 char namespace; |
1092 | |
1092 switch (iptr->isn_type) | 1093 switch (iptr->isn_type) |
1093 { | 1094 { |
1094 case ISN_LOADG: | 1095 case ISN_LOADG: |
1095 ht = get_globvar_ht(); | 1096 ht = get_globvar_ht(); |
1096 namespace = 'g'; | 1097 namespace = 'g'; |
1126 ++ectx.ec_stack.ga_len; | 1127 ++ectx.ec_stack.ga_len; |
1127 } | 1128 } |
1128 } | 1129 } |
1129 break; | 1130 break; |
1130 | 1131 |
1132 // load g:/b:/w:/t: namespace | |
1133 case ISN_LOADGDICT: | |
1134 case ISN_LOADBDICT: | |
1135 case ISN_LOADWDICT: | |
1136 case ISN_LOADTDICT: | |
1137 { | |
1138 dict_T *d = NULL; | |
1139 | |
1140 switch (iptr->isn_type) | |
1141 { | |
1142 case ISN_LOADG: d = get_globvar_dict(); break; | |
1143 case ISN_LOADB: d = &curbuf->b_vars; break; | |
1144 case ISN_LOADW: d = &curwin->w_vars; break; | |
1145 case ISN_LOADT: d = &curtab->tp_vars; break; | |
1146 default: // Cannot reach here | |
1147 goto failed; | |
1148 } | |
1149 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) | |
1150 goto failed; | |
1151 tv = STACK_TV_BOT(0); | |
1152 tv->v_type = VAR_DICT; | |
1153 tv->v_lock = 0; | |
1154 tv->vval.v_dict = d; | |
1155 ++ectx.ec_stack.ga_len; | |
1156 } | |
1157 break; | |
1158 | |
1131 // load &option | 1159 // load &option |
1132 case ISN_LOADOPT: | 1160 case ISN_LOADOPT: |
1133 { | 1161 { |
1134 typval_T optval; | 1162 typval_T optval; |
1135 char_u *name = iptr->isn_arg.string; | 1163 char_u *name = iptr->isn_arg.string; |
1164 case ISN_LOADREG: | 1192 case ISN_LOADREG: |
1165 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) | 1193 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) |
1166 goto failed; | 1194 goto failed; |
1167 tv = STACK_TV_BOT(0); | 1195 tv = STACK_TV_BOT(0); |
1168 tv->v_type = VAR_STRING; | 1196 tv->v_type = VAR_STRING; |
1197 tv->v_lock = 0; | |
1169 tv->vval.v_string = get_reg_contents( | 1198 tv->vval.v_string = get_reg_contents( |
1170 iptr->isn_arg.number, GREG_EXPR_SRC); | 1199 iptr->isn_arg.number, GREG_EXPR_SRC); |
1171 ++ectx.ec_stack.ga_len; | 1200 ++ectx.ec_stack.ga_len; |
1172 break; | 1201 break; |
1173 | 1202 |
1409 case ISN_PUSHCHANNEL: | 1438 case ISN_PUSHCHANNEL: |
1410 case ISN_PUSHJOB: | 1439 case ISN_PUSHJOB: |
1411 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) | 1440 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) |
1412 goto failed; | 1441 goto failed; |
1413 tv = STACK_TV_BOT(0); | 1442 tv = STACK_TV_BOT(0); |
1443 tv->v_lock = 0; | |
1414 ++ectx.ec_stack.ga_len; | 1444 ++ectx.ec_stack.ga_len; |
1415 switch (iptr->isn_type) | 1445 switch (iptr->isn_type) |
1416 { | 1446 { |
1417 case ISN_PUSHNR: | 1447 case ISN_PUSHNR: |
1418 tv->v_type = VAR_NUMBER; | 1448 tv->v_type = VAR_NUMBER; |
1527 goto failed; | 1557 goto failed; |
1528 else | 1558 else |
1529 ++ectx.ec_stack.ga_len; | 1559 ++ectx.ec_stack.ga_len; |
1530 tv = STACK_TV_BOT(-1); | 1560 tv = STACK_TV_BOT(-1); |
1531 tv->v_type = VAR_DICT; | 1561 tv->v_type = VAR_DICT; |
1562 tv->v_lock = 0; | |
1532 tv->vval.v_dict = dict; | 1563 tv->vval.v_dict = dict; |
1533 ++dict->dv_refcount; | 1564 ++dict->dv_refcount; |
1534 } | 1565 } |
1535 break; | 1566 break; |
1536 | 1567 |
1671 | 1702 |
1672 tv = STACK_TV_BOT(0); | 1703 tv = STACK_TV_BOT(0); |
1673 ++ectx.ec_stack.ga_len; | 1704 ++ectx.ec_stack.ga_len; |
1674 tv->vval.v_partial = pt; | 1705 tv->vval.v_partial = pt; |
1675 tv->v_type = VAR_PARTIAL; | 1706 tv->v_type = VAR_PARTIAL; |
1707 tv->v_lock = 0; | |
1676 } | 1708 } |
1677 break; | 1709 break; |
1678 | 1710 |
1679 // jump if a condition is met | 1711 // jump if a condition is met |
1680 case ISN_JUMP: | 1712 case ISN_JUMP: |
1717 else if (list->lv_first == &range_list_item) | 1749 else if (list->lv_first == &range_list_item) |
1718 { | 1750 { |
1719 // non-materialized range() list | 1751 // non-materialized range() list |
1720 tv = STACK_TV_BOT(0); | 1752 tv = STACK_TV_BOT(0); |
1721 tv->v_type = VAR_NUMBER; | 1753 tv->v_type = VAR_NUMBER; |
1754 tv->v_lock = 0; | |
1722 tv->vval.v_number = list_find_nr( | 1755 tv->vval.v_number = list_find_nr( |
1723 list, idxtv->vval.v_number, NULL); | 1756 list, idxtv->vval.v_number, NULL); |
1724 ++ectx.ec_stack.ga_len; | 1757 ++ectx.ec_stack.ga_len; |
1725 } | 1758 } |
1726 else | 1759 else |
1760 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) | 1793 if (GA_GROW(&ectx.ec_stack, 1) == FAIL) |
1761 goto failed; | 1794 goto failed; |
1762 tv = STACK_TV_BOT(0); | 1795 tv = STACK_TV_BOT(0); |
1763 ++ectx.ec_stack.ga_len; | 1796 ++ectx.ec_stack.ga_len; |
1764 tv->v_type = VAR_STRING; | 1797 tv->v_type = VAR_STRING; |
1798 tv->v_lock = 0; | |
1765 tv->vval.v_string = vim_strsave( | 1799 tv->vval.v_string = vim_strsave( |
1766 (char_u *)current_exception->value); | 1800 (char_u *)current_exception->value); |
1767 break; | 1801 break; |
1768 | 1802 |
1769 case ISN_CATCH: | 1803 case ISN_CATCH: |
2623 case ISN_LOADW: | 2657 case ISN_LOADW: |
2624 smsg("%4d LOADW w:%s", current, iptr->isn_arg.string); | 2658 smsg("%4d LOADW w:%s", current, iptr->isn_arg.string); |
2625 break; | 2659 break; |
2626 case ISN_LOADT: | 2660 case ISN_LOADT: |
2627 smsg("%4d LOADT t:%s", current, iptr->isn_arg.string); | 2661 smsg("%4d LOADT t:%s", current, iptr->isn_arg.string); |
2662 break; | |
2663 case ISN_LOADGDICT: | |
2664 smsg("%4d LOAD g:", current); | |
2665 break; | |
2666 case ISN_LOADBDICT: | |
2667 smsg("%4d LOAD b:", current); | |
2668 break; | |
2669 case ISN_LOADWDICT: | |
2670 smsg("%4d LOAD w:", current); | |
2671 break; | |
2672 case ISN_LOADTDICT: | |
2673 smsg("%4d LOAD t:", current); | |
2628 break; | 2674 break; |
2629 case ISN_LOADOPT: | 2675 case ISN_LOADOPT: |
2630 smsg("%4d LOADOPT %s", current, iptr->isn_arg.string); | 2676 smsg("%4d LOADOPT %s", current, iptr->isn_arg.string); |
2631 break; | 2677 break; |
2632 case ISN_LOADENV: | 2678 case ISN_LOADENV: |