1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2025-02-16 15:30:26 +00:00

Get routine outputs nominally working.

This commit is contained in:
Cat's Eye Technologies 2014-04-04 15:05:58 +01:00
parent 64e50a905f
commit af05d77d2d
4 changed files with 33 additions and 22 deletions

View File

@ -14,7 +14,7 @@ routine.
| lda #4
| sta score
| }
= main
= main ([])
= A: UpdatedWith (Immediate 4)
= NamedLocation (Just Byte) "score": UpdatedWith A
@ -50,13 +50,13 @@ But if it does it can.
| jsr update_score
| sta border_colour
| }
= main
= main ([])
= A: UpdatedWith (Immediate 4)
= X: PoisonedWith (Immediate 1)
= NamedLocation (Just Byte) "border_colour": UpdatedWith A
= NamedLocation (Just Byte) "score": PoisonedWith X
=
= update_score
= update_score ([])
= X: UpdatedWith (Immediate 1)
= NamedLocation (Just Byte) "score": UpdatedWith X
@ -90,12 +90,11 @@ modifying score, as an "output" of the routine.
| jsr update_score
| ldx score
| }
= main
= A: UpdatedWith (Immediate 4)
= X: PoisonedWith (Immediate 1)
= NamedLocation (Just Byte) "border_colour": UpdatedWith A
= NamedLocation (Just Byte) "score": PoisonedWith X
= main ([])
= A: PoisonedWith (Immediate 8)
= X: UpdatedWith (NamedLocation (Just Byte) "score")
= NamedLocation (Just Byte) "score": UpdatedWith A
=
= update_score
= X: UpdatedWith (Immediate 1)
= NamedLocation (Just Byte) "score": UpdatedWith X
= update_score ([NamedLocation Nothing "score"])
= A: UpdatedWith (Immediate 8)
= NamedLocation (Just Byte) "score": UpdatedWith A

View File

@ -34,7 +34,7 @@ main = do
("analyze", Right program) ->
case checkAndTransformProgram program of
Just newprog ->
ppAnalysis $ analyzeProgram newprog
ppAnalysis newprog (analyzeProgram newprog)
("emit", Right program) ->
case checkAndTransformProgram program of
Just newprog ->

View File

@ -81,6 +81,15 @@ mergeRoutCtxs routCtx calledRoutCtx calledRout@(Routine name outputs _) =
poison location usage routCtxAccum =
case usage of
UpdatedWith ulocation ->
Map.insert location (PoisonedWith ulocation) routCtxAccum
case (untypedLocation location) `elem` outputs of
True ->
Map.insert location usage routCtxAccum
False ->
Map.insert location (PoisonedWith ulocation) routCtxAccum
in
Map.foldrWithKey (poison) routCtx calledRoutCtx
untypedLocation (NamedLocation (Just _) name) =
NamedLocation Nothing name
untypedLocation x = x

View File

@ -26,19 +26,22 @@ type RoutineContext = Map.Map StorageLocation Usage
type ProgramContext = Map.Map RoutineName RoutineContext
ppAnalysis :: ProgramContext -> IO ()
ppAnalysis progCtx =
ppAnalysis :: Program -> ProgramContext -> IO ()
ppAnalysis program progCtx =
let
li = Map.toList progCtx
in do
ppRoutines li
ppRoutines program li
ppRoutines [] = return ()
ppRoutines ((name, routCtx):rest) = do
putStrLn $ name
ppRoutine routCtx
putStrLn ""
ppRoutines rest
ppRoutines program [] = return ()
ppRoutines program ((name, routCtx):rest) =
let
Just (Routine rname outputs _) = lookupRoutine program name
in do
putStrLn (rname ++ " (" ++ (show outputs) ++ ")")
ppRoutine routCtx
putStrLn ""
ppRoutines program rest
ppRoutine routCtx =
let