Skip to content

Commit 6f3e7fc

Browse files
committed
py: add UNPACK_SEQUENCE and keyword methods to VM.
1 parent ff099f3 commit 6f3e7fc

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

py/vm.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ bool py_execute_byte_code_2(const byte **ip_in_out, py_obj_t *fastn, py_obj_t **
369369
sp++;
370370
break;
371371

372+
case PYBC_UNPACK_SEQUENCE:
373+
DECODE_UINT;
374+
rt_unpack_sequence(sp[0], unum, sp - unum + 1);
375+
sp -= unum - 1;
376+
break;
377+
372378
case PYBC_MAKE_FUNCTION:
373379
DECODE_UINT;
374380
PUSH(rt_make_function_from_id(unum));
@@ -384,10 +390,16 @@ bool py_execute_byte_code_2(const byte **ip_in_out, py_obj_t *fastn, py_obj_t **
384390

385391
case PYBC_CALL_METHOD:
386392
DECODE_UINT;
387-
assert((unum & 0xff00) == 0); // n_keyword
388-
unum &= 0xff;
389-
obj1 = rt_call_method_n(unum, sp);
390-
sp += unum + 1;
393+
if ((unum & 0xff00) == 0) {
394+
// no keywords
395+
unum &= 0xff;
396+
obj1 = rt_call_method_n(unum, sp);
397+
sp += unum + 1;
398+
} else {
399+
// keywords
400+
obj1 = rt_call_method_n_kw(unum & 0xff, (unum >> 8) & 0xff, sp);
401+
sp += (unum & 0xff) + ((unum >> 7) & 0x1fe) + 1;
402+
}
391403
*sp = obj1;
392404
break;
393405

0 commit comments

Comments
 (0)