@@ -126,7 +126,6 @@ static mp_obj_t code_colines_iter(mp_obj_t self_in) {
126
126
iter -> bc = 0 ;
127
127
iter -> source_line = 1 ;
128
128
iter -> ci = self -> rc -> prelude .line_info ;
129
- code_colines_next (MP_OBJ_FROM_PTR (iter ));
130
129
return MP_OBJ_FROM_PTR (iter );
131
130
}
132
131
static MP_DEFINE_CONST_FUN_OBJ_1 (code_colines_obj , code_colines_iter ) ;
@@ -136,19 +135,30 @@ static mp_obj_t code_colines_next(mp_obj_t iter_in) {
136
135
137
136
mp_uint_t start = iter -> bc ;
138
137
mp_uint_t line_no = iter -> source_line ;
138
+ bool another = true;
139
139
140
- if (iter -> ci >= iter -> rc -> prelude .line_info_top ) {
140
+ while (another && iter -> ci < iter -> rc -> prelude .line_info_top ) {
141
+ another = false;
142
+ mp_code_lineinfo_t decoded = mp_bytecode_decode_lineinfo (& iter -> ci );
143
+ iter -> bc += decoded .bc_increment ;
144
+ iter -> source_line += decoded .line_increment ;
145
+
146
+ if (decoded .bc_increment == 0 ) {
147
+ line_no = iter -> source_line ;
148
+ another = true;
149
+ } else if (decoded .line_increment == 0 ) {
150
+ another = true;
151
+ }
152
+ }
153
+
154
+ if (another ) {
141
155
mp_uint_t prelude_size = (iter -> rc -> prelude .opcodes - (const byte * )iter -> rc -> fun_data );
142
156
mp_uint_t bc_end = iter -> rc -> fun_data_len - prelude_size ;
143
157
if (iter -> bc >= bc_end ) {
144
158
return MP_OBJ_STOP_ITERATION ;
145
159
} else {
146
160
iter -> bc = bc_end ;
147
161
}
148
- } else {
149
- mp_code_lineinfo_t decoded = mp_bytecode_decode_lineinfo (& iter -> ci );
150
- iter -> bc += decoded .bc_increment ;
151
- iter -> source_line += decoded .line_increment ;
152
162
}
153
163
154
164
mp_uint_t end = iter -> bc ;
0 commit comments