mirror of
https://github.com/catseye/SixtyPical.git
synced 2026-04-25 20:17:51 +00:00
goto is no longer restricted to appearing in tail position.
This commit is contained in:
@@ -2280,7 +2280,7 @@ But only if they are bytes.
|
||||
| }
|
||||
? TypeMismatchError
|
||||
|
||||
A `goto` cannot appear within a `save` block, even if it is otherwise in tail position.
|
||||
A `goto` cannot appear within a `save` block.
|
||||
|
||||
| define other routine
|
||||
| trashes a, z, n
|
||||
@@ -2325,8 +2325,7 @@ A `goto` cannot appear within a `save` block, even if it is otherwise in tail po
|
||||
| }
|
||||
= ok
|
||||
|
||||
A `goto` cannot appear within a `with interrupts` block, even if it is
|
||||
otherwise in tail position.
|
||||
A `goto` cannot appear within a `with interrupts` block.
|
||||
|
||||
| vector routine
|
||||
| inputs x
|
||||
@@ -2973,7 +2972,26 @@ Calling the vector does indeed trash the things the vector says it does.
|
||||
| }
|
||||
? UnmeaningfulOutputError: x
|
||||
|
||||
`goto`, if present, must be in tail position (the final instruction in a routine.)
|
||||
For now at least, you cannot have a `goto` inside a loop.
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
| }
|
||||
|
|
||||
| define main routine trashes x, z, n {
|
||||
| ld x, 0
|
||||
| repeat {
|
||||
| inc x
|
||||
| goto bar
|
||||
| } until z
|
||||
| }
|
||||
? IllegalJumpError
|
||||
|
||||
`goto`, as a matter of syntax, can only appear at the end
|
||||
of a block; but it need not be the final instruction in a
|
||||
routine. It is only important that the type context at every
|
||||
`goto` is compatible with the type context at the end of
|
||||
the routine.
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
@@ -2995,9 +3013,8 @@ Calling the vector does indeed trash the things the vector says it does.
|
||||
| ld x, 1
|
||||
| goto bar
|
||||
| }
|
||||
| ld x, 0
|
||||
| }
|
||||
? IllegalJumpError
|
||||
= ok
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
@@ -3009,6 +3026,7 @@ Calling the vector does indeed trash the things the vector says it does.
|
||||
| ld x, 1
|
||||
| goto bar
|
||||
| }
|
||||
| goto bar
|
||||
| }
|
||||
= ok
|
||||
|
||||
@@ -3024,7 +3042,7 @@ Calling the vector does indeed trash the things the vector says it does.
|
||||
| }
|
||||
| ld x, 0
|
||||
| }
|
||||
? IllegalJumpError
|
||||
= ok
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
@@ -3057,7 +3075,21 @@ Calling the vector does indeed trash the things the vector says it does.
|
||||
| }
|
||||
= ok
|
||||
|
||||
For the purposes of `goto`, the end of a loop is never tail position.
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
| }
|
||||
|
|
||||
| define main routine trashes x, z, n {
|
||||
| ld x, 0
|
||||
| if z {
|
||||
| ld x, 1
|
||||
| goto bar
|
||||
| } else {
|
||||
| ld x, 0
|
||||
| }
|
||||
| ld x, 0
|
||||
| }
|
||||
= ok
|
||||
|
||||
| define bar routine trashes x, z, n {
|
||||
| ld x, 200
|
||||
@@ -3065,12 +3097,15 @@ For the purposes of `goto`, the end of a loop is never tail position.
|
||||
|
|
||||
| define main routine trashes x, z, n {
|
||||
| ld x, 0
|
||||
| repeat {
|
||||
| inc x
|
||||
| if z {
|
||||
| ld x, 1
|
||||
| goto bar
|
||||
| } until z
|
||||
| } else {
|
||||
| ld x, 0
|
||||
| }
|
||||
| goto bar
|
||||
| }
|
||||
? IllegalJumpError
|
||||
= ok
|
||||
|
||||
Can't `goto` a routine that outputs or trashes more than the current routine.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user