summaryrefslogtreecommitdiff
path: root/py/runtime.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-02-16 18:30:49 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-02-16 18:36:33 +0200
commitac2e28c6547f34d961e8b0a0ede323c9c32b5315 (patch)
tree9b6cce27c5f65d5c80ff04de9b9f9743e82e6c38 /py/runtime.c
parent44739e280e81c2ebf2491818eb5a6d0ef30c7c6b (diff)
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.
Diffstat (limited to 'py/runtime.c')
-rw-r--r--py/runtime.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/py/runtime.c b/py/runtime.c
index 9fc0b9708..b08ae3d4e 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -64,6 +64,7 @@ typedef struct _mp_code_t {
void *fun;
} u_inline_asm;
};
+ qstr *arg_names;
} mp_code_t;
STATIC uint next_unique_code_id;
@@ -242,7 +243,7 @@ STATIC void alloc_unique_codes(void) {
}
}
-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 @@ void rt_assign_byte_code(uint unique_code_id, byte *code, uint len, int n_args,
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 rt_make_function_from_id(int unique_code_id, mp_obj_t def_args) {
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);