mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
Support tuples and list comprehension, albeit crude.
This commit is contained in:
14
py/vm.c
14
py/vm.c
@@ -268,6 +268,13 @@ py_obj_t py_execute_byte_code(const byte *code, uint len, const py_obj_t *args,
|
||||
*sp = rt_compare_op(unum, obj1, obj2);
|
||||
break;
|
||||
|
||||
case PYBC_BUILD_TUPLE:
|
||||
DECODE_UINT;
|
||||
obj1 = rt_build_tuple(unum, sp);
|
||||
sp += unum - 1;
|
||||
*sp = obj1;
|
||||
break;
|
||||
|
||||
case PYBC_BUILD_LIST:
|
||||
DECODE_UINT;
|
||||
obj1 = rt_build_list(unum, sp);
|
||||
@@ -275,6 +282,13 @@ py_obj_t py_execute_byte_code(const byte *code, uint len, const py_obj_t *args,
|
||||
*sp = obj1;
|
||||
break;
|
||||
|
||||
case PYBC_LIST_APPEND:
|
||||
DECODE_UINT;
|
||||
// I think it's guaranteed by the compiler that sp[unum] is a list
|
||||
rt_list_append(sp[unum], sp[0]);
|
||||
sp++;
|
||||
break;
|
||||
|
||||
case PYBC_BUILD_MAP:
|
||||
DECODE_UINT;
|
||||
PUSH(rt_build_map(unum));
|
||||
|
||||
Reference in New Issue
Block a user