mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-01-10 17:31:18 +00:00
Pretty-print usages
This commit is contained in:
parent
11265e3060
commit
a86738c387
@ -10,6 +10,7 @@ import SixtyPical.Model
|
|||||||
import SixtyPical.Parser (parseProgram)
|
import SixtyPical.Parser (parseProgram)
|
||||||
import SixtyPical.Checker (checkAndTransformProgram)
|
import SixtyPical.Checker (checkAndTransformProgram)
|
||||||
import SixtyPical.Analyzer (analyzeProgram)
|
import SixtyPical.Analyzer (analyzeProgram)
|
||||||
|
import SixtyPical.Context (ppAnalysis)
|
||||||
import SixtyPical.Emitter (emitProgram)
|
import SixtyPical.Emitter (emitProgram)
|
||||||
|
|
||||||
-- -- -- -- driver -- -- -- --
|
-- -- -- -- driver -- -- -- --
|
||||||
@ -33,7 +34,7 @@ main = do
|
|||||||
("analyze", Right program) ->
|
("analyze", Right program) ->
|
||||||
case checkAndTransformProgram program of
|
case checkAndTransformProgram program of
|
||||||
Just newprog ->
|
Just newprog ->
|
||||||
putStrLn $ show $ analyzeProgram newprog
|
ppAnalysis $ analyzeProgram newprog
|
||||||
("emit", Right program) ->
|
("emit", Right program) ->
|
||||||
case checkAndTransformProgram program of
|
case checkAndTransformProgram program of
|
||||||
Just newprog ->
|
Just newprog ->
|
||||||
|
@ -35,6 +35,7 @@ checkInstr (COPY src dst) progCtx routCtx =
|
|||||||
-- TODO check that src is not poisoned
|
-- TODO check that src is not poisoned
|
||||||
Map.insert dst (UpdatedWith src) routCtx
|
Map.insert dst (UpdatedWith src) routCtx
|
||||||
checkInstr (DELTA dst val) progCtx routCtx =
|
checkInstr (DELTA dst val) progCtx routCtx =
|
||||||
|
-- TODO check that dst is not poisoned
|
||||||
Map.insert dst (UpdatedWith (Immediate val)) routCtx
|
Map.insert dst (UpdatedWith (Immediate val)) routCtx
|
||||||
checkInstr (JSR name) progCtx routCtx =
|
checkInstr (JSR name) progCtx routCtx =
|
||||||
case Map.lookup name progCtx of
|
case Map.lookup name progCtx of
|
||||||
|
@ -42,3 +42,29 @@ mergeRoutCtxs routCtx calledRoutCtx =
|
|||||||
Map.insert location (PoisonedWith ulocation) routCtxAccum
|
Map.insert location (PoisonedWith ulocation) routCtxAccum
|
||||||
in
|
in
|
||||||
Map.foldrWithKey (poison) routCtx calledRoutCtx
|
Map.foldrWithKey (poison) routCtx calledRoutCtx
|
||||||
|
|
||||||
|
|
||||||
|
ppAnalysis :: ProgramContext -> IO ()
|
||||||
|
ppAnalysis progCtx =
|
||||||
|
let
|
||||||
|
li = Map.toList progCtx
|
||||||
|
in do
|
||||||
|
ppRoutines li
|
||||||
|
|
||||||
|
ppRoutines [] = return ()
|
||||||
|
ppRoutines ((name, routCtx):rest) = do
|
||||||
|
putStrLn $ name
|
||||||
|
ppRoutine routCtx
|
||||||
|
putStrLn ""
|
||||||
|
ppRoutines rest
|
||||||
|
|
||||||
|
ppRoutine routCtx =
|
||||||
|
let
|
||||||
|
li = Map.toList routCtx
|
||||||
|
in do
|
||||||
|
ppUsages li
|
||||||
|
|
||||||
|
ppUsages [] = return ()
|
||||||
|
ppUsages ((loc, usage):rest) = do
|
||||||
|
putStrLn $ (" " ++ (show loc) ++ ": " ++ (show usage))
|
||||||
|
ppUsages rest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user