From 1aa03f745146c2d364e418c99bbd9ecb828536f0 Mon Sep 17 00:00:00 2001 From: Cat's Eye Technologies Date: Fri, 11 Apr 2014 11:22:54 +0100 Subject: [PATCH] A slightly better understanding of what we're dealing with. --- src/SixtyPical/Analyzer.hs | 18 +++++++----------- src/SixtyPical/Context.hs | 3 ++- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/SixtyPical/Analyzer.hs b/src/SixtyPical/Analyzer.hs index 184480d..0b86055 100644 --- a/src/SixtyPical/Analyzer.hs +++ b/src/SixtyPical/Analyzer.hs @@ -63,18 +63,8 @@ analyzeProgram program@(Program decls routines) = routCtx checkInstr nm (IF _ branch b1 b2) progCtx routCtx = let - -- This works, but I worry about it. - -- It doesn't work if we pass routCtx to both blocks, - -- because when we go to merge them, there is apparently - -- too much information, and we end up checking things - -- we don't need to check. - -- Leaving the second one empty results in the right amount - -- of information. - -- But what are we depriving the else block context of? - -- More tests are needed. - -- Possibly the merge needs to be redone. routCtx1 = checkBlock nm b1 progCtx routCtx - routCtx2 = checkBlock nm b2 progCtx Map.empty + routCtx2 = checkBlock nm b2 progCtx routCtx in mergeAlternateRoutCtxs nm routCtx1 routCtx2 checkInstr nm (REPEAT _ branch blk) progCtx routCtx = @@ -137,6 +127,12 @@ mergeRoutCtxs nm routCtx calledRoutCtx calledRout@(Routine name outputs _) = -- Take 2 routine contexts -- one from each branch of an `if` -- and merge -- them to create a new context for the remainder of the routine. -- +-- TODO: this merge is "too sensitive" in a way that needs to be better +-- understood and documented. It is that it is using updateRoutCtx to +-- make the merged resultant context, but that routine raises an error +-- if the new usage is replacing a poisoned entry. It should be "more OK" +-- with replacing a poisoned entry, here. +-- mergeAlternateRoutCtxs nm routCtx1 routCtx2 = let -- go through all the Usages in routCtx2 diff --git a/src/SixtyPical/Context.hs b/src/SixtyPical/Context.hs index ffa5cc9..6f7aae2 100644 --- a/src/SixtyPical/Context.hs +++ b/src/SixtyPical/Context.hs @@ -44,7 +44,8 @@ updateRoutCtx nm dst (UpdatedWith src) routCtx = in case Map.lookup s routCtx of Just (PoisonedWith _) -> - error ("routine '" ++ nm ++ "' does not preserve '" ++ (show s) ++ "'") + error ("routine '" ++ nm ++ "' does not preserve '" ++ + (show s) ++ "' (in context: " ++ (show routCtx) ++ ")") _ -> Map.insert d (UpdatedWith s) routCtx updateRoutCtx nm dst (PoisonedWith src) routCtx =