mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-21 04:29:14 +00:00
Get routine outputs nominally working.
This commit is contained in:
parent
64e50a905f
commit
af05d77d2d
@ -14,7 +14,7 @@ routine.
|
|||||||
| lda #4
|
| lda #4
|
||||||
| sta score
|
| sta score
|
||||||
| }
|
| }
|
||||||
= main
|
= main ([])
|
||||||
= A: UpdatedWith (Immediate 4)
|
= A: UpdatedWith (Immediate 4)
|
||||||
= NamedLocation (Just Byte) "score": UpdatedWith A
|
= NamedLocation (Just Byte) "score": UpdatedWith A
|
||||||
|
|
||||||
@ -50,13 +50,13 @@ But if it does it can.
|
|||||||
| jsr update_score
|
| jsr update_score
|
||||||
| sta border_colour
|
| sta border_colour
|
||||||
| }
|
| }
|
||||||
= main
|
= main ([])
|
||||||
= A: UpdatedWith (Immediate 4)
|
= A: UpdatedWith (Immediate 4)
|
||||||
= X: PoisonedWith (Immediate 1)
|
= X: PoisonedWith (Immediate 1)
|
||||||
= NamedLocation (Just Byte) "border_colour": UpdatedWith A
|
= NamedLocation (Just Byte) "border_colour": UpdatedWith A
|
||||||
= NamedLocation (Just Byte) "score": PoisonedWith X
|
= NamedLocation (Just Byte) "score": PoisonedWith X
|
||||||
=
|
=
|
||||||
= update_score
|
= update_score ([])
|
||||||
= X: UpdatedWith (Immediate 1)
|
= X: UpdatedWith (Immediate 1)
|
||||||
= NamedLocation (Just Byte) "score": UpdatedWith X
|
= NamedLocation (Just Byte) "score": UpdatedWith X
|
||||||
|
|
||||||
@ -90,12 +90,11 @@ modifying score, as an "output" of the routine.
|
|||||||
| jsr update_score
|
| jsr update_score
|
||||||
| ldx score
|
| ldx score
|
||||||
| }
|
| }
|
||||||
= main
|
= main ([])
|
||||||
= A: UpdatedWith (Immediate 4)
|
= A: PoisonedWith (Immediate 8)
|
||||||
= X: PoisonedWith (Immediate 1)
|
= X: UpdatedWith (NamedLocation (Just Byte) "score")
|
||||||
= NamedLocation (Just Byte) "border_colour": UpdatedWith A
|
= NamedLocation (Just Byte) "score": UpdatedWith A
|
||||||
= NamedLocation (Just Byte) "score": PoisonedWith X
|
|
||||||
=
|
=
|
||||||
= update_score
|
= update_score ([NamedLocation Nothing "score"])
|
||||||
= X: UpdatedWith (Immediate 1)
|
= A: UpdatedWith (Immediate 8)
|
||||||
= NamedLocation (Just Byte) "score": UpdatedWith X
|
= NamedLocation (Just Byte) "score": UpdatedWith A
|
||||||
|
@ -34,7 +34,7 @@ main = do
|
|||||||
("analyze", Right program) ->
|
("analyze", Right program) ->
|
||||||
case checkAndTransformProgram program of
|
case checkAndTransformProgram program of
|
||||||
Just newprog ->
|
Just newprog ->
|
||||||
ppAnalysis $ analyzeProgram newprog
|
ppAnalysis newprog (analyzeProgram newprog)
|
||||||
("emit", Right program) ->
|
("emit", Right program) ->
|
||||||
case checkAndTransformProgram program of
|
case checkAndTransformProgram program of
|
||||||
Just newprog ->
|
Just newprog ->
|
||||||
|
@ -81,6 +81,15 @@ mergeRoutCtxs routCtx calledRoutCtx calledRout@(Routine name outputs _) =
|
|||||||
poison location usage routCtxAccum =
|
poison location usage routCtxAccum =
|
||||||
case usage of
|
case usage of
|
||||||
UpdatedWith ulocation ->
|
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
|
in
|
||||||
Map.foldrWithKey (poison) routCtx calledRoutCtx
|
Map.foldrWithKey (poison) routCtx calledRoutCtx
|
||||||
|
|
||||||
|
untypedLocation (NamedLocation (Just _) name) =
|
||||||
|
NamedLocation Nothing name
|
||||||
|
untypedLocation x = x
|
||||||
|
|
||||||
|
@ -26,19 +26,22 @@ type RoutineContext = Map.Map StorageLocation Usage
|
|||||||
|
|
||||||
type ProgramContext = Map.Map RoutineName RoutineContext
|
type ProgramContext = Map.Map RoutineName RoutineContext
|
||||||
|
|
||||||
ppAnalysis :: ProgramContext -> IO ()
|
ppAnalysis :: Program -> ProgramContext -> IO ()
|
||||||
ppAnalysis progCtx =
|
ppAnalysis program progCtx =
|
||||||
let
|
let
|
||||||
li = Map.toList progCtx
|
li = Map.toList progCtx
|
||||||
in do
|
in do
|
||||||
ppRoutines li
|
ppRoutines program li
|
||||||
|
|
||||||
ppRoutines [] = return ()
|
ppRoutines program [] = return ()
|
||||||
ppRoutines ((name, routCtx):rest) = do
|
ppRoutines program ((name, routCtx):rest) =
|
||||||
putStrLn $ name
|
let
|
||||||
ppRoutine routCtx
|
Just (Routine rname outputs _) = lookupRoutine program name
|
||||||
putStrLn ""
|
in do
|
||||||
ppRoutines rest
|
putStrLn (rname ++ " (" ++ (show outputs) ++ ")")
|
||||||
|
ppRoutine routCtx
|
||||||
|
putStrLn ""
|
||||||
|
ppRoutines program rest
|
||||||
|
|
||||||
ppRoutine routCtx =
|
ppRoutine routCtx =
|
||||||
let
|
let
|
||||||
|
Loading…
x
Reference in New Issue
Block a user