git @ Cat's Eye Technologies SixtyPical / 827896c
Hey, passing tests. Cool. Cat's Eye Technologies 7 years ago
2 changed file(s) with 27 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
44
55 -> Functionality "Analyze SixtyPical program" is implemented by
66 -> shell command "bin/sixtypical analyze %(test-file)"
7
8 Analysis determines what storage locations have been modified by a
9 routine.
10
11 | reserve byte score
12 | routine main {
13 | lda #4
14 | sta score
15 | }
16 = main
17 = A: UpdatedWith (Immediate 4)
18 = NamedLocation (Just Byte) "score": UpdatedWith A
719
820 A routine cannot expect registers which a called routine does not
921 preserve, to be preserved.
2032 | jsr update_score
2133 | sta border_colour
2234 | }
23 ? routine does not preserve register
35 ? routine does not preserve 'A'
2436
2537 But if it does it can.
2638
3749 | jsr update_score
3850 | sta border_colour
3951 | }
40 = True
52 = main
53 = A: UpdatedWith (Immediate 4)
54 = X: PoisonedWith (Immediate 1)
55 = NamedLocation (Just Byte) "border_colour": UpdatedWith A
56 = NamedLocation (Just Byte) "score": PoisonedWith X
57 =
58 = update_score
59 = X: UpdatedWith (Immediate 1)
60 = NamedLocation (Just Byte) "score": UpdatedWith X
3131 checkBlock instrs progCtx routCtx'
3232
3333 checkInstr (COPY src dst) progCtx routCtx =
34 -- TODO check that src is not poisoned
35 Map.insert dst (UpdatedWith src) routCtx
34 case Map.lookup src routCtx of
35 Just (PoisonedWith _) ->
36 error ("routine does not preserve '" ++ (show src) ++ "'")
37 _ ->
38 Map.insert dst (UpdatedWith src) routCtx
3639 checkInstr (DELTA dst val) progCtx routCtx =
3740 -- TODO check that dst is not poisoned
3841 Map.insert dst (UpdatedWith (Immediate val)) routCtx