From 8acde175ad044969f7a5a7d882b48ff0e9d8fe28 Mon Sep 17 00:00:00 2001 From: Cat's Eye Technologies Date: Sat, 12 Apr 2014 20:37:42 +0100 Subject: [PATCH] mergeRoutCtxs does not need to throw poisoning errors. --- eg/game.60p | 44 ++++++++++++++++++++++++-------------- src/SixtyPical/Analyzer.hs | 38 +++++++++++++------------------- src/SixtyPical/Context.hs | 15 ++++++++++--- 3 files changed, 55 insertions(+), 42 deletions(-) diff --git a/eg/game.60p b/eg/game.60p index dbd0175..442f972 100644 --- a/eg/game.60p +++ b/eg/game.60p @@ -26,11 +26,10 @@ reserve word delta reserve byte value reserve word compare_target -routine reset_position { - copy #$0400 position -} +reserve byte[16] actor_pos_hi +reserve byte[16] actor_pos_lo -routine advance_pos { +routine calculate_new_position outputs (new_position) { clc lda new_position } -routine install_new_position { - copy new_position position -} - routine compare_new_pos { lda >new_position cmp >compare_target @@ -117,7 +112,6 @@ routine read_stick { if beq { lda #255 // -1 sta delta } else { txa @@ -132,19 +126,30 @@ routine read_stick { } routine our_cinv { - lda #32 ldy #0 - sta (position), y + lda actor_pos_hi, y + sta >position + lda actor_pos_lo, y + sta position + sta actor_pos_hi, y + lda StorageLocation -> Usage -> RoutineContext -> RoutineContext -updateRoutCtx nm dst (UpdatedWith src) routCtx = +updateRoutCtxPoison :: String -> StorageLocation -> Usage -> RoutineContext -> RoutineContext +updateRoutCtxPoison nm dst (UpdatedWith src) routCtx = let s = untypedLocation src d = untypedLocation dst @@ -50,9 +50,18 @@ updateRoutCtx nm dst (UpdatedWith src) routCtx = (show s) ++ "' (in context: " ++ (show routCtx) ++ ")") _ -> Map.insert d (UpdatedWith s) routCtx -updateRoutCtx nm dst (PoisonedWith src) routCtx = +updateRoutCtxPoison nm dst (PoisonedWith src) routCtx = Map.insert (untypedLocation dst) (PoisonedWith $ untypedLocation src) routCtx +updateRoutCtx nm dst (UpdatedWith src) routCtx = + let + s = untypedLocation src + d = untypedLocation dst + in + Map.insert d (UpdatedWith s) routCtx +updateRoutCtx nm dst (PoisonedWith src) routCtx = + Map.insert (untypedLocation dst) (PoisonedWith $ untypedLocation src) routCtx + -- pretty printing ppAnalysis :: Program -> ProgramContext -> IO ()