1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-25 23:49:17 +00:00

Hey, passing tests. Cool.

This commit is contained in:
Cat's Eye Technologies 2014-04-04 14:22:19 +01:00
parent a86738c387
commit 827896cd68
2 changed files with 27 additions and 4 deletions

View File

@ -6,6 +6,18 @@ Anayzling SixtyPical Programs
-> Functionality "Analyze SixtyPical program" is implemented by
-> shell command "bin/sixtypical analyze %(test-file)"
Analysis determines what storage locations have been modified by a
routine.
| reserve byte score
| routine main {
| lda #4
| sta score
| }
= main
= A: UpdatedWith (Immediate 4)
= NamedLocation (Just Byte) "score": UpdatedWith A
A routine cannot expect registers which a called routine does not
preserve, to be preserved.
@ -21,7 +33,7 @@ preserve, to be preserved.
| jsr update_score
| sta border_colour
| }
? routine does not preserve register
? routine does not preserve 'A'
But if it does it can.
@ -38,4 +50,12 @@ But if it does it can.
| jsr update_score
| sta border_colour
| }
= True
= main
= A: UpdatedWith (Immediate 4)
= X: PoisonedWith (Immediate 1)
= NamedLocation (Just Byte) "border_colour": UpdatedWith A
= NamedLocation (Just Byte) "score": PoisonedWith X
=
= update_score
= X: UpdatedWith (Immediate 1)
= NamedLocation (Just Byte) "score": UpdatedWith X

View File

@ -32,8 +32,11 @@ checkBlock (instr:instrs) progCtx routCtx =
checkBlock instrs progCtx routCtx'
checkInstr (COPY src dst) progCtx routCtx =
-- TODO check that src is not poisoned
Map.insert dst (UpdatedWith src) routCtx
case Map.lookup src routCtx of
Just (PoisonedWith _) ->
error ("routine does not preserve '" ++ (show src) ++ "'")
_ ->
Map.insert dst (UpdatedWith src) routCtx
checkInstr (DELTA dst val) progCtx routCtx =
-- TODO check that dst is not poisoned
Map.insert dst (UpdatedWith (Immediate val)) routCtx