summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitglue.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-04-06 22:38:53 +0100
committerDamien George <damien.p.george@gmail.com>2015-04-07 22:43:28 +0100
commit9988618e0e0f5c319e31b135d993e22efb593093 (patch)
treed89d8df392ce2669c9e516a05b11742e72dc8cf2 /py/emitglue.c
parent18bd51707c218137005cd73cb5a35ebfe2bccd6e (diff)
downloadmicropython-9988618e0e0f5c319e31b135d993e22efb593093.tar.gz
micropython-9988618e0e0f5c319e31b135d993e22efb593093.zip
py: Implement full func arg passing for native emitter.
This patch gets full function argument passing working with native emitter. Includes named args, keyword args, default args, var args and var keyword args. Fully Python compliant. It reuses the bytecode mp_setup_code_state function to do all the hard work. This function is slightly adjusted to accommodate native calls, and the native emitter is forced a bit to emit similar prelude and code-info as bytecode.
Diffstat (limited to 'py/emitglue.c')
-rw-r--r--py/emitglue.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/py/emitglue.c b/py/emitglue.c
index b3e8495d94..610e76d534 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -86,16 +86,17 @@ void mp_emit_glue_assign_bytecode(mp_raw_code_t *rc, byte *code, mp_uint_t len,
}
#if MICROPY_EMIT_NATIVE || MICROPY_EMIT_INLINE_THUMB
-void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, mp_uint_t n_args, mp_uint_t type_sig) {
+void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void *fun_data, mp_uint_t fun_len, mp_uint_t n_pos_args, mp_uint_t n_kwonly_args, mp_uint_t scope_flags, mp_uint_t type_sig) {
assert(kind == MP_CODE_NATIVE_PY || kind == MP_CODE_NATIVE_VIPER || kind == MP_CODE_NATIVE_ASM);
rc->kind = kind;
- rc->scope_flags = 0;
- rc->n_pos_args = n_args;
+ rc->scope_flags = scope_flags;
+ rc->n_pos_args = n_pos_args;
+ rc->n_kwonly_args = n_kwonly_args;
rc->data.u_native.fun_data = fun_data;
rc->data.u_native.type_sig = type_sig;
#ifdef DEBUG_PRINT
- DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " n_args=" UINT_FMT "\n", kind, fun_data, fun_len, n_args);
+ DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " n_pos_args=" UINT_FMT " n_kwonly_args=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, n_pos_args, n_kwonly_args, (uint)scope_flags);
for (mp_uint_t i = 0; i < fun_len; i++) {
if (i > 0 && i % 16 == 0) {
DEBUG_printf("\n");
@@ -134,7 +135,7 @@ mp_obj_t mp_make_function_from_raw_code(mp_raw_code_t *rc, mp_obj_t def_args, mp
break;
#if MICROPY_EMIT_NATIVE
case MP_CODE_NATIVE_PY:
- fun = mp_obj_new_fun_native(rc->n_pos_args, rc->data.u_native.fun_data);
+ fun = mp_obj_new_fun_native(rc->scope_flags, rc->n_pos_args, rc->n_kwonly_args, def_args, def_kw_args, rc->data.u_native.fun_data);
break;
case MP_CODE_NATIVE_VIPER:
fun = mp_obj_new_fun_viper(rc->n_pos_args, rc->data.u_native.fun_data, rc->data.u_native.type_sig);