mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Add more tests. Apparently our algorithm does not do a good job.
This commit is contained in:
parent
350bab42d7
commit
a5d946734a
@ -81,7 +81,7 @@ through to it.
|
|||||||
= ]
|
= ]
|
||||||
= ]
|
= ]
|
||||||
|
|
||||||
If main does a `goto foo`, then it can fall through to `foo`.
|
If `main` does a `goto foo`, then it can fall through to `foo`.
|
||||||
|
|
||||||
| define foo routine trashes a, z, n
|
| define foo routine trashes a, z, n
|
||||||
| {
|
| {
|
||||||
@ -102,9 +102,6 @@ If main does a `goto foo`, then it can fall through to `foo`.
|
|||||||
More than one routine can fall through to a routine. We pick one
|
More than one routine can fall through to a routine. We pick one
|
||||||
of them to fall through, when selecting the order of routines.
|
of them to fall through, when selecting the order of routines.
|
||||||
|
|
||||||
Also note, `main` is always serialized first, so that the entry
|
|
||||||
point of the entire program appears at the beginning of the code.
|
|
||||||
|
|
||||||
| define foo routine trashes a, z, n
|
| define foo routine trashes a, z, n
|
||||||
| {
|
| {
|
||||||
| ld a, 0
|
| ld a, 0
|
||||||
@ -130,6 +127,29 @@ point of the entire program appears at the beginning of the code.
|
|||||||
= ]
|
= ]
|
||||||
= ]
|
= ]
|
||||||
|
|
||||||
|
Because `main` is always serialized first (so that the entry
|
||||||
|
point of the entire program appears at the beginning of the code),
|
||||||
|
nothing ever falls through to `main`.
|
||||||
|
|
||||||
|
| define foo routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 0
|
||||||
|
| goto main
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define main routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 1
|
||||||
|
| }
|
||||||
|
= [
|
||||||
|
= [
|
||||||
|
= "main"
|
||||||
|
= ],
|
||||||
|
= [
|
||||||
|
= "foo"
|
||||||
|
= ]
|
||||||
|
= ]
|
||||||
|
|
||||||
There is nothing stopping two routines from tail-calling each
|
There is nothing stopping two routines from tail-calling each
|
||||||
other, but we will only be able to make one of them, at most,
|
other, but we will only be able to make one of them, at most,
|
||||||
fall through to the other.
|
fall through to the other.
|
||||||
@ -226,6 +246,61 @@ because we don't necessarily know what actual routine the vector contains.
|
|||||||
= ]
|
= ]
|
||||||
= ]
|
= ]
|
||||||
|
|
||||||
|
Our algorithm might not be strictly optimal, but it does a good job.
|
||||||
|
|
||||||
|
| define r1 routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 0
|
||||||
|
| goto r2
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define r2 routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 0
|
||||||
|
| goto r3
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define r3 routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 0
|
||||||
|
| goto r4
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define r4 routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 0
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define r5 routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 0
|
||||||
|
| goto r6
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define r6 routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| ld a, 0
|
||||||
|
| goto r3
|
||||||
|
| }
|
||||||
|
|
|
||||||
|
| define main routine trashes a, z, n
|
||||||
|
| {
|
||||||
|
| goto r1
|
||||||
|
| }
|
||||||
|
= [
|
||||||
|
= [
|
||||||
|
= "main",
|
||||||
|
= "r1",
|
||||||
|
= "r2",
|
||||||
|
= "r3",
|
||||||
|
= "r4"
|
||||||
|
= ],
|
||||||
|
= [
|
||||||
|
= "r5",
|
||||||
|
= "r6"
|
||||||
|
= ]
|
||||||
|
= ]
|
||||||
|
|
||||||
-> Tests for functionality "Compile SixtyPical program with fallthru optimization"
|
-> Tests for functionality "Compile SixtyPical program with fallthru optimization"
|
||||||
|
|
||||||
Basic test for actually applying this optimization when compiling SixtyPical programs.
|
Basic test for actually applying this optimization when compiling SixtyPical programs.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user