diff options
author | Damien George <damien.p.george@gmail.com> | 2018-09-15 13:00:11 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-09-15 13:00:11 +1000 |
commit | 80db30a510caeb0c575bcedc09683cacdce46de6 (patch) | |
tree | a46532715bcbe672b6570c8673eacac00d43b044 /py/compile.c | |
parent | 07caf4f969a9ad09e7a18d6cf419d92848908e40 (diff) | |
download | micropython-80db30a510caeb0c575bcedc09683cacdce46de6.tar.gz micropython-80db30a510caeb0c575bcedc09683cacdce46de6.zip |
py/emit: Completely remove set_native_type, arg type is set in compiler.
In viper mode, the type of the argument is now stored in id_info->flags.
Diffstat (limited to 'py/compile.c')
-rw-r--r-- | py/compile.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/py/compile.c b/py/compile.c index 2f6a9a326d..d1fc2c9d4e 100644 --- a/py/compile.c +++ b/py/compile.c @@ -2853,7 +2853,12 @@ STATIC void compile_scope_func_annotations(compiler_t *comp, mp_parse_node_t pn) if (MP_PARSE_NODE_IS_ID(pn_annotation)) { qstr arg_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation); - EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_ARG, id_info->local_num, arg_type); + int native_type = mp_native_type_from_qstr(arg_type); + if (native_type < 0) { + comp->compile_error = mp_obj_new_exception_msg_varg(&mp_type_ViperTypeError, "unknown type '%q'", arg_type); + } else { + id_info->flags |= native_type << ID_FLAG_VIPER_TYPE_POS; + } } else { compile_syntax_error(comp, pn_annotation, "parameter annotation must be an identifier"); } @@ -2983,9 +2988,8 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) { apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_param); } #if MICROPY_EMIT_NATIVE - else if (scope->emit_options == MP_EMIT_OPT_VIPER) { - // compile annotations; only needed on latter compiler passes - // only needed for viper emitter + if (comp->pass == MP_PASS_SCOPE && scope->emit_options == MP_EMIT_OPT_VIPER) { + // compile annotations; only needed for viper emitter // argument annotations apply_to_single_or_list(comp, pns->nodes[1], PN_typedargslist, compile_scope_func_annotations); |