mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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.
This commit is contained in:
@@ -3009,7 +3009,7 @@ exec_instructions(ectx_T *ectx)
|
||||
iptr = &ectx->ec_instr[ectx->ec_iidx++];
|
||||
switch (iptr->isn_type)
|
||||
{
|
||||
// Constructor, new() method.
|
||||
// Constructor, first instruction in a new() method.
|
||||
case ISN_CONSTRUCT:
|
||||
// "this" is always the local variable at index zero
|
||||
tv = STACK_TV_VAR(0);
|
||||
@@ -5114,7 +5114,7 @@ exec_instructions(ectx_T *ectx)
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_OBJ_MEMBER:
|
||||
case ISN_GET_OBJ_MEMBER:
|
||||
{
|
||||
tv = STACK_TV_BOT(-1);
|
||||
if (tv->v_type != VAR_OBJECT)
|
||||
@@ -5143,6 +5143,18 @@ exec_instructions(ectx_T *ectx)
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_STORE_THIS:
|
||||
{
|
||||
int idx = iptr->isn_arg.number;
|
||||
object_T *obj = STACK_TV_VAR(0)->vval.v_object;
|
||||
// the members are located right after the object struct
|
||||
typval_T *mtv = ((typval_T *)(obj + 1)) + idx;
|
||||
clear_tv(mtv);
|
||||
*mtv = *STACK_TV_BOT(-1);
|
||||
--ectx->ec_stack.ga_len;
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_CLEARDICT:
|
||||
dict_stack_drop();
|
||||
break;
|
||||
@@ -6805,7 +6817,9 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
|
||||
case ISN_MEMBER: smsg("%s%4d MEMBER", pfx, current); break;
|
||||
case ISN_STRINGMEMBER: smsg("%s%4d MEMBER %s", pfx, current,
|
||||
iptr->isn_arg.string); break;
|
||||
case ISN_OBJ_MEMBER: smsg("%s%4d OBJ_MEMBER %d", pfx, current,
|
||||
case ISN_GET_OBJ_MEMBER: smsg("%s%4d OBJ_MEMBER %d", pfx, current,
|
||||
(int)iptr->isn_arg.number); break;
|
||||
case ISN_STORE_THIS: smsg("%s%4d STORE_THIS %d", pfx, current,
|
||||
(int)iptr->isn_arg.number); break;
|
||||
case ISN_CLEARDICT: smsg("%s%4d CLEARDICT", pfx, current); break;
|
||||
case ISN_USEDICT: smsg("%s%4d USEDICT", pfx, current); break;
|
||||
|
Reference in New Issue
Block a user