@@ -1702,6 +1702,11 @@ STATIC void compile_with_stmt_helper(compiler_t *comp, const byte *n_pre, const
1702
1702
compile_node (comp , p_body );
1703
1703
} else {
1704
1704
uint l_end = comp_next_label (comp );
1705
+ if (MICROPY_EMIT_NATIVE && comp -> scope_cur -> emit_options != MP_EMIT_OPT_BYTECODE ) {
1706
+ // we need to allocate an extra label for the native emitter
1707
+ // it will use l_end+1 as an auxiliary label
1708
+ comp_next_label (comp );
1709
+ }
1705
1710
if (pt_is_rule (n_pre , PN_with_item )) {
1706
1711
// this pre-bit is of the form "a as b"
1707
1712
const byte * p = pt_rule_first (n_pre );
@@ -1719,10 +1724,7 @@ STATIC void compile_with_stmt_helper(compiler_t *comp, const byte *n_pre, const
1719
1724
// compile additional pre-bits and the body
1720
1725
compile_with_stmt_helper (comp , n_pre , p_body );
1721
1726
// finish this with block
1722
- EMIT (pop_block );
1723
- EMIT_ARG (load_const_tok , MP_TOKEN_KW_NONE );
1724
- EMIT_ARG (label_assign , l_end );
1725
- EMIT (with_cleanup );
1727
+ EMIT_ARG (with_cleanup , l_end );
1726
1728
compile_decrease_except_level (comp );
1727
1729
EMIT (end_finally );
1728
1730
}
@@ -2073,6 +2075,10 @@ STATIC void compile_power(compiler_t *comp, const byte *p, const byte *ptop) {
2073
2075
comp -> func_arg_is_super = pt_is_id (p , MP_QSTR_super );
2074
2076
2075
2077
compile_generic_all_nodes (comp , p , ptop );
2078
+
2079
+ if (pt_num_nodes (p , ptop ) == 3 ) {
2080
+ EMIT_ARG (binary_op , MP_BINARY_OP_POWER );
2081
+ }
2076
2082
}
2077
2083
2078
2084
// if p_arglist==NULL then there are no arguments
@@ -2205,12 +2211,6 @@ STATIC void compile_power_trailers(compiler_t *comp, const byte *p, const byte *
2205
2211
}
2206
2212
}
2207
2213
2208
- STATIC void compile_power_dbl_star (compiler_t * comp , const byte * p , const byte * ptop ) {
2209
- (void )ptop ;
2210
- compile_node (comp , p );
2211
- EMIT_ARG (binary_op , MP_BINARY_OP_POWER );
2212
- }
2213
-
2214
2214
// p needs to point to 2 successive nodes, first is lhs of comprehension, second is PN_comp_for node
2215
2215
STATIC void compile_comprehension (compiler_t * comp , const byte * p , scope_kind_t kind ) {
2216
2216
const byte * p_comp_for = pt_next (p );
@@ -2493,7 +2493,23 @@ STATIC const byte *compile_node(compiler_t *comp, const byte *p) {
2493
2493
} else if (pt_is_small_int (p )) {
2494
2494
mp_int_t arg ;
2495
2495
p = pt_get_small_int (p , & arg );
2496
+ #if MICROPY_DYNAMIC_COMPILER
2497
+ mp_uint_t sign_mask = - (1 << (mp_dynamic_compiler .small_int_bits - 1 ));
2498
+ if ((arg & sign_mask ) == 0 || (arg & sign_mask ) == sign_mask ) {
2499
+ // integer fits in target runtime's small-int
2500
+ EMIT_ARG (load_const_small_int , arg );
2501
+ } else {
2502
+ // integer doesn't fit, so create a multi-precision int object
2503
+ // (but only create the actual object on the last pass)
2504
+ if (comp -> pass != MP_PASS_EMIT ) {
2505
+ EMIT_ARG (load_const_obj , mp_const_none );
2506
+ } else {
2507
+ EMIT_ARG (load_const_obj , mp_obj_new_int_from_ll (arg ));
2508
+ }
2509
+ }
2510
+ #else
2496
2511
EMIT_ARG (load_const_small_int , arg );
2512
+ #endif
2497
2513
return p ;
2498
2514
} else if (pt_is_any_tok (p )) {
2499
2515
byte tok ;
@@ -2970,7 +2986,25 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
2970
2986
}
2971
2987
2972
2988
p = pt_next (p ); // skip the parameter list
2973
- p = pt_next (p ); // skip the return type
2989
+
2990
+ // function return annotation is in the next node
2991
+ mp_uint_t type_sig = MP_NATIVE_TYPE_INT ;
2992
+ if (!pt_is_null (p )) {
2993
+ if (pt_is_any_id (p )) {
2994
+ qstr ret_type ;
2995
+ pt_extract_id (p , & ret_type );
2996
+ switch (ret_type ) {
2997
+ case MP_QSTR_object : type_sig = MP_NATIVE_TYPE_OBJ ; break ;
2998
+ case MP_QSTR_bool : type_sig = MP_NATIVE_TYPE_BOOL ; break ;
2999
+ case MP_QSTR_int : type_sig = MP_NATIVE_TYPE_INT ; break ;
3000
+ case MP_QSTR_uint : type_sig = MP_NATIVE_TYPE_UINT ; break ;
3001
+ default : compile_syntax_error (comp , p , "unknown type" ); return ;
3002
+ }
3003
+ } else {
3004
+ compile_syntax_error (comp , p , "return annotation must be an identifier" );
3005
+ }
3006
+ }
3007
+ p = pt_next (p ); // move past function return annotation
2974
3008
2975
3009
// get the list of statements within the body of the function
2976
3010
const byte * ptop = mp_parse_node_extract_list (& p , PN_suite_block_stmts );
@@ -3077,7 +3111,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
3077
3111
}
3078
3112
3079
3113
if (comp -> pass > MP_PASS_SCOPE ) {
3080
- EMIT_INLINE_ASM_ARG (end_pass , 0 );
3114
+ EMIT_INLINE_ASM_ARG (end_pass , type_sig );
3081
3115
}
3082
3116
3083
3117
if (comp -> compile_error != MP_OBJ_NULL ) {
0 commit comments