git @ Cat's Eye Technologies SixtyPical / 4854077
Correctly analyze `repeat { ... } forever` loops. Chris Pressey 3 years ago
6 changed file(s) with 28 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
88 in a `copy` to a vector is a routine that is defined further down in the source.
99 * Fixed bug which was preventing `if` branches to diverge in what they initialized,
1010 if it was already initialized when going into the `if`.
11 * Fixed a bug which was making it crash when trying to analyze `repeat forever` loops.
1112
1213 0.9
1314 ---
239239 copy cinv, save_cinv
240240 copy our_cinv, cinv
241241 }
242 // FIXME: find out why `repeat { } forever` does not analyze OK
243 repeat {
244 ld a, 0
245 } until not z
246 }
242
243 repeat { } forever
244 }
323323 # it will always be executed at least once, so analyze it having
324324 # been executed the first time.
325325 self.analyze_block(instr.block, context)
326 context.assert_meaningful(src)
326 if src is not None: # None indicates 'repeat forever'
327 context.assert_meaningful(src)
327328
328329 # now analyze it having been executed a second time, with the context
329330 # of it having already been executed.
330331 self.analyze_block(instr.block, context)
331 context.assert_meaningful(src)
332 if src is not None:
333 context.assert_meaningful(src)
332334
333335 elif opcode == 'copy':
334336 # 1. check that their types are compatible
306306 elif opcode == 'repeat':
307307 top_label = self.emitter.make_label()
308308 self.compile_block(instr.block)
309 if src is None:
309 if src is None: # indicates 'repeat forever'
310310 self.emitter.emit(JMP(Absolute(top_label)))
311311 else:
312312 cls = {
11941194 | }
11951195 ? UnmeaningfulReadError: z in main
11961196
1197 The body of `repeat forever` can be empty.
1198
1199 | routine main
1200 | {
1201 | repeat {
1202 | } forever
1203 | }
1204 = ok
1205
11971206 ### copy ###
11981207
11991208 Can't `copy` from a memory location that isn't initialized.
296296 = $0810 JMP $080F
297297 = $0813 RTS
298298
299 The body of `repeat forever` can be empty.
300
301 | routine main
302 | {
303 | repeat {
304 | } forever
305 | }
306 = $080D JMP $080D
307 = $0810 RTS
308
299309 Indexed access.
300310
301311 | byte one