Support passing positional args as keywords to bytecode functions.
For this, record argument names along with each bytecode function. The code
still includes extensive debug logging support so far.
diff --git a/py/runtime.c b/py/runtime.c
index 9fc0b97..b08ae3d 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -64,6 +64,7 @@
void *fun;
} u_inline_asm;
};
+ qstr *arg_names;
} mp_code_t;
STATIC uint next_unique_code_id;
@@ -242,7 +243,7 @@
}
}
-void rt_assign_byte_code(uint unique_code_id, byte *code, uint len, int n_args, int n_locals, int n_stack, uint scope_flags) {
+void rt_assign_byte_code(uint unique_code_id, byte *code, uint len, int n_args, int n_locals, int n_stack, uint scope_flags, qstr *arg_names) {
alloc_unique_codes();
assert(1 <= unique_code_id && unique_code_id < next_unique_code_id && unique_codes[unique_code_id].kind == MP_CODE_NONE);
@@ -252,6 +253,7 @@
unique_codes[unique_code_id].n_state = n_locals + n_stack;
unique_codes[unique_code_id].u_byte.code = code;
unique_codes[unique_code_id].u_byte.len = len;
+ unique_codes[unique_code_id].arg_names = arg_names;
//printf("byte code: %d bytes\n", len);
@@ -714,7 +716,7 @@
mp_obj_t fun;
switch (c->kind) {
case MP_CODE_BYTE:
- fun = mp_obj_new_fun_bc(c->scope_flags, c->n_args, def_args, c->n_state, c->u_byte.code);
+ fun = mp_obj_new_fun_bc(c->scope_flags, c->arg_names, c->n_args, def_args, c->n_state, c->u_byte.code);
break;
case MP_CODE_NATIVE:
fun = rt_make_function_n(c->n_args, c->u_native.fun);