git @ Cat's Eye Technologies SixtyPical / af05d77
Get routine outputs nominally working. Cat's Eye Technologies 7 years ago
4 changed file(s) with 33 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
1313 | lda #4
1414 | sta score
1515 | }
16 = main
16 = main ([])
1717 = A: UpdatedWith (Immediate 4)
1818 = NamedLocation (Just Byte) "score": UpdatedWith A
1919
4949 | jsr update_score
5050 | sta border_colour
5151 | }
52 = main
52 = main ([])
5353 = A: UpdatedWith (Immediate 4)
5454 = X: PoisonedWith (Immediate 1)
5555 = NamedLocation (Just Byte) "border_colour": UpdatedWith A
5656 = NamedLocation (Just Byte) "score": PoisonedWith X
5757 =
58 = update_score
58 = update_score ([])
5959 = X: UpdatedWith (Immediate 1)
6060 = NamedLocation (Just Byte) "score": UpdatedWith X
6161
8989 | jsr update_score
9090 | ldx score
9191 | }
92 = main
93 = A: UpdatedWith (Immediate 4)
94 = X: PoisonedWith (Immediate 1)
95 = NamedLocation (Just Byte) "border_colour": UpdatedWith A
96 = NamedLocation (Just Byte) "score": PoisonedWith X
92 = main ([])
93 = A: PoisonedWith (Immediate 8)
94 = X: UpdatedWith (NamedLocation (Just Byte) "score")
95 = NamedLocation (Just Byte) "score": UpdatedWith A
9796 =
98 = update_score
99 = X: UpdatedWith (Immediate 1)
100 = NamedLocation (Just Byte) "score": UpdatedWith X
97 = update_score ([NamedLocation Nothing "score"])
98 = A: UpdatedWith (Immediate 8)
99 = NamedLocation (Just Byte) "score": UpdatedWith A
3333 ("analyze", Right program) ->
3434 case checkAndTransformProgram program of
3535 Just newprog ->
36 ppAnalysis $ analyzeProgram newprog
36 ppAnalysis newprog (analyzeProgram newprog)
3737 ("emit", Right program) ->
3838 case checkAndTransformProgram program of
3939 Just newprog ->
8080 poison location usage routCtxAccum =
8181 case usage of
8282 UpdatedWith ulocation ->
83 Map.insert location (PoisonedWith ulocation) routCtxAccum
83 case (untypedLocation location) `elem` outputs of
84 True ->
85 Map.insert location usage routCtxAccum
86 False ->
87 Map.insert location (PoisonedWith ulocation) routCtxAccum
8488 in
8589 Map.foldrWithKey (poison) routCtx calledRoutCtx
90
91 untypedLocation (NamedLocation (Just _) name) =
92 NamedLocation Nothing name
93 untypedLocation x = x
94
2525
2626 type ProgramContext = Map.Map RoutineName RoutineContext
2727
28 ppAnalysis :: ProgramContext -> IO ()
29 ppAnalysis progCtx =
28 ppAnalysis :: Program -> ProgramContext -> IO ()
29 ppAnalysis program progCtx =
3030 let
3131 li = Map.toList progCtx
3232 in do
33 ppRoutines li
33 ppRoutines program li
3434
35 ppRoutines [] = return ()
36 ppRoutines ((name, routCtx):rest) = do
37 putStrLn $ name
38 ppRoutine routCtx
39 putStrLn ""
40 ppRoutines rest
35 ppRoutines program [] = return ()
36 ppRoutines program ((name, routCtx):rest) =
37 let
38 Just (Routine rname outputs _) = lookupRoutine program name
39 in do
40 putStrLn (rname ++ " (" ++ (show outputs) ++ ")")
41 ppRoutine routCtx
42 putStrLn ""
43 ppRoutines program rest
4144
4245 ppRoutine routCtx =
4346 let