mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-22 01:32:13 +00:00
Correctly analyze repeat { ... } forever
loops.
This commit is contained in:
parent
0145c6d34f
commit
4854077cce
@ -9,6 +9,7 @@ History of SixtyPical
|
||||
in a `copy` to a vector is a routine that is defined further down in the source.
|
||||
* Fixed bug which was preventing `if` branches to diverge in what they initialized,
|
||||
if it was already initialized when going into the `if`.
|
||||
* Fixed a bug which was making it crash when trying to analyze `repeat forever` loops.
|
||||
|
||||
0.9
|
||||
---
|
||||
|
@ -240,8 +240,6 @@ routine main
|
||||
copy cinv, save_cinv
|
||||
copy our_cinv, cinv
|
||||
}
|
||||
// FIXME: find out why `repeat { } forever` does not analyze OK
|
||||
repeat {
|
||||
ld a, 0
|
||||
} until not z
|
||||
|
||||
repeat { } forever
|
||||
}
|
||||
|
@ -324,12 +324,14 @@ class Analyzer(object):
|
||||
# it will always be executed at least once, so analyze it having
|
||||
# been executed the first time.
|
||||
self.analyze_block(instr.block, context)
|
||||
context.assert_meaningful(src)
|
||||
if src is not None: # None indicates 'repeat forever'
|
||||
context.assert_meaningful(src)
|
||||
|
||||
# now analyze it having been executed a second time, with the context
|
||||
# of it having already been executed.
|
||||
self.analyze_block(instr.block, context)
|
||||
context.assert_meaningful(src)
|
||||
if src is not None:
|
||||
context.assert_meaningful(src)
|
||||
|
||||
elif opcode == 'copy':
|
||||
# 1. check that their types are compatible
|
||||
|
@ -307,7 +307,7 @@ class Compiler(object):
|
||||
elif opcode == 'repeat':
|
||||
top_label = self.emitter.make_label()
|
||||
self.compile_block(instr.block)
|
||||
if src is None:
|
||||
if src is None: # indicates 'repeat forever'
|
||||
self.emitter.emit(JMP(Absolute(top_label)))
|
||||
else:
|
||||
cls = {
|
||||
|
@ -1195,6 +1195,15 @@ this is an error too.
|
||||
| }
|
||||
? UnmeaningfulReadError: z in main
|
||||
|
||||
The body of `repeat forever` can be empty.
|
||||
|
||||
| routine main
|
||||
| {
|
||||
| repeat {
|
||||
| } forever
|
||||
| }
|
||||
= ok
|
||||
|
||||
### copy ###
|
||||
|
||||
Can't `copy` from a memory location that isn't initialized.
|
||||
|
@ -297,6 +297,16 @@ Compiling `repeat forever`.
|
||||
= $0810 JMP $080F
|
||||
= $0813 RTS
|
||||
|
||||
The body of `repeat forever` can be empty.
|
||||
|
||||
| routine main
|
||||
| {
|
||||
| repeat {
|
||||
| } forever
|
||||
| }
|
||||
= $080D JMP $080D
|
||||
= $0810 RTS
|
||||
|
||||
Indexed access.
|
||||
|
||||
| byte one
|
||||
|
Loading…
Reference in New Issue
Block a user