Skip to content

Commit 6ba1314

Browse files
committed
Fix bug: emit native didn't clear last_was_return in label_assign.
1 parent 7410e44 commit 6ba1314

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

py/emitnative.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,15 @@ static void emit_native_delete_id(emit_t *emit, qstr qstr) {
514514
}
515515

516516
static void emit_native_label_assign(emit_t *emit, int l) {
517+
emit_pre(emit);
517518
// need to commit stack because we can jump here from elsewhere
518519
need_stack_settled(emit);
519520
#if N_X64
520521
asm_x64_label_assign(emit->as, l);
521522
#elif N_THUMB
522523
asm_thumb_label_assign(emit->as, l);
523524
#endif
525+
emit_post(emit);
524526
}
525527

526528
static void emit_native_import_name(emit_t *emit, qstr qstr) {
@@ -577,8 +579,10 @@ static void emit_native_load_const_int(emit_t *emit, qstr qstr) {
577579
}
578580

579581
static void emit_native_load_const_dec(emit_t *emit, qstr qstr) {
580-
// not supported for viper (although, could support floats in future)
581-
assert(0);
582+
// for viper, a float/complex is just a Python object
583+
emit_pre(emit);
584+
emit_call_with_imm_arg(emit, RT_F_LOAD_CONST_DEC, rt_load_const_dec, qstr, REG_ARG_1);
585+
emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
582586
}
583587

584588
static void emit_native_load_const_id(emit_t *emit, qstr qstr) {
@@ -903,7 +907,7 @@ static void emit_native_setup_loop(emit_t *emit, int label) {
903907
}
904908

905909
static void emit_native_break_loop(emit_t *emit, int label) {
906-
assert(0);
910+
emit_native_jump(emit, label); // TODO properly
907911
}
908912
static void emit_native_continue_loop(emit_t *emit, int label) {
909913
assert(0);

py/runtime.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,9 @@ py_obj_t rt_iternext(py_obj_t o_in) {
19251925
}
19261926
}
19271927

1928+
// these must correspond to the respective enum
19281929
void *const rt_fun_table[RT_F_NUMBER_OF] = {
1930+
rt_load_const_dec,
19291931
rt_load_const_str,
19301932
rt_load_name,
19311933
rt_load_global,

py/runtime.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ typedef enum {
4848
} rt_compare_op_t;
4949

5050
typedef enum {
51-
RT_F_LOAD_CONST_STR = 0,
51+
RT_F_LOAD_CONST_DEC = 0,
52+
RT_F_LOAD_CONST_STR,
5253
RT_F_LOAD_NAME,
5354
RT_F_LOAD_GLOBAL,
5455
RT_F_LOAD_BUILD_CLASS,

0 commit comments

Comments
 (0)