Mercurial > vim
comparison src/eval.c @ 31424:e31fc75f6aff v9.0.1045
patch 9.0.1045: in a class object members cannot be initialized
Commit: https://github.com/vim/vim/commit/7ce7daf6cd6a7ed27eac060699026640b4b239a8
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Dec 10 18:42:12 2022 +0000
patch 9.0.1045: in a class object members cannot be initialized
Problem: In a class object members cannot be initialized.
Solution: Support initializing object members. Make "dissassemble" work on
an object method.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 10 Dec 2022 19:45:04 +0100 |
parents | f088f1d97eee |
children | 5804270d6e9b |
comparison
equal
deleted
inserted
replaced
31423:66c85efdf4b0 | 31424:e31fc75f6aff |
---|---|
1191 */ | 1191 */ |
1192 var1.v_type = VAR_UNKNOWN; | 1192 var1.v_type = VAR_UNKNOWN; |
1193 var2.v_type = VAR_UNKNOWN; | 1193 var2.v_type = VAR_UNKNOWN; |
1194 while (*p == '[' || (*p == '.' && p[1] != '=' && p[1] != '.')) | 1194 while (*p == '[' || (*p == '.' && p[1] != '=' && p[1] != '.')) |
1195 { | 1195 { |
1196 int r = OK; | 1196 if (*p == '.' && lp->ll_tv->v_type != VAR_DICT |
1197 | 1197 && lp->ll_tv->v_type != VAR_CLASS) |
1198 if (*p == '.' && lp->ll_tv->v_type != VAR_DICT) | |
1199 { | 1198 { |
1200 if (!quiet) | 1199 if (!quiet) |
1201 semsg(_(e_dot_can_only_be_used_on_dictionary_str), name); | 1200 semsg(_(e_dot_can_only_be_used_on_dictionary_str), name); |
1202 return NULL; | 1201 return NULL; |
1203 } | 1202 } |
1204 if (lp->ll_tv->v_type != VAR_LIST | 1203 if (lp->ll_tv->v_type != VAR_LIST |
1205 && lp->ll_tv->v_type != VAR_DICT | 1204 && lp->ll_tv->v_type != VAR_DICT |
1206 && lp->ll_tv->v_type != VAR_BLOB) | 1205 && lp->ll_tv->v_type != VAR_BLOB |
1206 && lp->ll_tv->v_type != VAR_CLASS) | |
1207 { | 1207 { |
1208 if (!quiet) | 1208 if (!quiet) |
1209 emsg(_(e_can_only_index_list_dictionary_or_blob)); | 1209 emsg(_(e_can_only_index_list_dictionary_or_blob)); |
1210 return NULL; | 1210 return NULL; |
1211 } | 1211 } |
1212 | 1212 |
1213 // A NULL list/blob works like an empty list/blob, allocate one now. | 1213 // A NULL list/blob works like an empty list/blob, allocate one now. |
1214 int r = OK; | |
1214 if (lp->ll_tv->v_type == VAR_LIST && lp->ll_tv->vval.v_list == NULL) | 1215 if (lp->ll_tv->v_type == VAR_LIST && lp->ll_tv->vval.v_list == NULL) |
1215 r = rettv_list_alloc(lp->ll_tv); | 1216 r = rettv_list_alloc(lp->ll_tv); |
1216 else if (lp->ll_tv->v_type == VAR_BLOB | 1217 else if (lp->ll_tv->v_type == VAR_BLOB |
1217 && lp->ll_tv->vval.v_blob == NULL) | 1218 && lp->ll_tv->vval.v_blob == NULL) |
1218 r = rettv_blob_alloc(lp->ll_tv); | 1219 r = rettv_blob_alloc(lp->ll_tv); |
1461 } | 1462 } |
1462 lp->ll_blob = lp->ll_tv->vval.v_blob; | 1463 lp->ll_blob = lp->ll_tv->vval.v_blob; |
1463 lp->ll_tv = NULL; | 1464 lp->ll_tv = NULL; |
1464 break; | 1465 break; |
1465 } | 1466 } |
1466 else | 1467 else if (lp->ll_tv->v_type == VAR_LIST) |
1467 { | 1468 { |
1468 /* | 1469 /* |
1469 * Get the number and item for the only or first index of the List. | 1470 * Get the number and item for the only or first index of the List. |
1470 */ | 1471 */ |
1471 if (empty1) | 1472 if (empty1) |
1505 &lp->ll_n2, quiet) == FAIL) | 1506 &lp->ll_n2, quiet) == FAIL) |
1506 return NULL; | 1507 return NULL; |
1507 } | 1508 } |
1508 | 1509 |
1509 lp->ll_tv = &lp->ll_li->li_tv; | 1510 lp->ll_tv = &lp->ll_li->li_tv; |
1511 } | |
1512 else // v_type == VAR_CLASS | |
1513 { | |
1514 // TODO: check object members and methods if | |
1515 // "key" points name start, "p" to the end | |
1510 } | 1516 } |
1511 } | 1517 } |
1512 | 1518 |
1513 clear_tv(&var1); | 1519 clear_tv(&var1); |
1514 lp->ll_name_end = p; | 1520 lp->ll_name_end = p; |