1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-26 16:29:28 +00:00

A slightly better understanding of what we're dealing with.

This commit is contained in:
Cat's Eye Technologies 2014-04-11 11:22:54 +01:00
parent 5a49382ad4
commit 1aa03f7451
2 changed files with 9 additions and 12 deletions

View File

@ -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

View File

@ -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 =