py/emit: Remove need to call set_native_type to set viper return type.

Instead this return type is now stored in the scope_flags.
This commit is contained in:
Damien George
2018-09-15 12:41:25 +10:00
parent 1d7c221b30
commit 07caf4f969
4 changed files with 34 additions and 25 deletions

View File

@@ -2996,7 +2996,12 @@ STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
// nodes[2] can be null or a test-expr
if (MP_PARSE_NODE_IS_ID(pn_annotation)) {
qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation);
EMIT_ARG(set_native_type, MP_EMIT_NATIVE_TYPE_RETURN, 0, ret_type);
int native_type = mp_native_type_from_qstr(ret_type);
if (native_type < 0) {
comp->compile_error = mp_obj_new_exception_msg_varg(&mp_type_ViperTypeError, "unknown type '%q'", ret_type);
} else {
scope->scope_flags |= native_type << MP_SCOPE_FLAG_VIPERRET_POS;
}
} else {
compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier");
}