git @ Cat's Eye Technologies UampirNexol / 6a92500
Add --debug-extraction option for `extract` subcommand. Chris Pressey a month ago
2 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
0 let
1 bumpupx = routine (INX; INX; INX)
2 in
3 LDA# 40 ; TAX ; (call bumpupx) ; (call bumpupx) ; INX
1919
2020 data Flags = Flags {
2121 typeCheck :: String,
22 debugExtraction :: Maybe String,
2223 outputPrg :: Maybe String
2324 } deriving (Show, Ord, Eq)
2425
2526 defaultFlags = Flags{
2627 typeCheck = "yes",
28 debugExtraction = Nothing,
2729 outputPrg = Nothing
2830 }
2931
3032 parseFlags flags ("--type-check":s:rest) =
3133 parseFlags flags{ typeCheck = s } rest
34 parseFlags flags ("--debug-extraction":s:rest) =
35 parseFlags flags{ debugExtraction = Just s } rest
3236 parseFlags flags ("--output-prg":s:rest) =
3337 parseFlags flags{ outputPrg = Just s } rest
3438 parseFlags flags other = (flags, other)
8185 return $ extract program initialEEnv
8286 other ->
8387 abortWith $ "illegal option: --type-check: " ++ other
84 case outputPrg flags of
88 case debugExtraction flags of
89 Just "dump" ->
90 putStrLn $ show extracted
91 Just other ->
92 abortWith $ "illegal option: --debug-extraction: " ++ other
8593 Nothing ->
86 putStrLn $ hexDump $ serialize extracted "main" 0x0200
87 Just filename ->
88 writeBinaryFile filename $ serialize extracted "main" 0x0200
94 case outputPrg flags of
95 Nothing ->
96 putStrLn $ hexDump $ serialize extracted "main" 0x0200
97 Just filename ->
98 writeBinaryFile filename $ serialize extracted "main" 0x0200
8999 _ -> do
90100 abortWith $
91101 "Usage: uampirnexol {flags} parse <filename>\n" ++
94104 " uampirnexol {flags} extract <filename>\n" ++
95105 " where {flags} can be:\n" ++
96106 " --type-check yes|no (default yes)\n" ++
107 " --debug-extraction dump\n" ++
97108 " --output-prg <filename>"
98109
99110