comparison src/vim9instr.c @ 31416:f088f1d97eee v9.0.1041

patch 9.0.1041: cannot define a method in a class Commit: https://github.com/vim/vim/commit/ffdaca9e6f3d39af6857ac52ced9385df203a152 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 9 21:41:48 2022 +0000 patch 9.0.1041: cannot define a method in a class Problem: Cannot define a method in a class. Solution: Implement defining an object method. Make calling an object method work.
author Bram Moolenaar <Bram@vim.org>
date Fri, 09 Dec 2022 22:45:03 +0100
parents 307f68a41b03
children e31fc75f6aff
comparison
equal deleted inserted replaced
31415:4fd33db887f2 31416:f088f1d97eee
127 return FAIL; 127 return FAIL;
128 isn->isn_arg.construct.construct_size = sizeof(object_T) 128 isn->isn_arg.construct.construct_size = sizeof(object_T)
129 + cl->class_obj_member_count * sizeof(typval_T); 129 + cl->class_obj_member_count * sizeof(typval_T);
130 isn->isn_arg.construct.construct_class = cl; 130 isn->isn_arg.construct.construct_class = cl;
131 return OK; 131 return OK;
132 }
133
134 /*
135 * Generate ISN_OBJ_MEMBER - access object member by indes.
136 */
137 int
138 generate_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type)
139 {
140 RETURN_OK_IF_SKIP(cctx);
141
142 // drop the object type
143 isn_T *isn = generate_instr_drop(cctx, ISN_OBJ_MEMBER, 1);
144 if (isn == NULL)
145 return FAIL;
146
147 isn->isn_arg.number = idx;
148 return push_type_stack2(cctx, type, &t_any);
132 } 149 }
133 150
134 /* 151 /*
135 * If type at "offset" isn't already VAR_STRING then generate ISN_2STRING. 152 * If type at "offset" isn't already VAR_STRING then generate ISN_2STRING.
136 * But only for simple types. 153 * But only for simple types.
2458 case ISN_MEMBER: 2475 case ISN_MEMBER:
2459 case ISN_NEGATENR: 2476 case ISN_NEGATENR:
2460 case ISN_NEWDICT: 2477 case ISN_NEWDICT:
2461 case ISN_NEWLIST: 2478 case ISN_NEWLIST:
2462 case ISN_NEWPARTIAL: 2479 case ISN_NEWPARTIAL:
2480 case ISN_OBJ_MEMBER:
2463 case ISN_OPANY: 2481 case ISN_OPANY:
2464 case ISN_OPFLOAT: 2482 case ISN_OPFLOAT:
2465 case ISN_OPNR: 2483 case ISN_OPNR:
2466 case ISN_PCALL: 2484 case ISN_PCALL:
2467 case ISN_PCALL_END: 2485 case ISN_PCALL_END: