Filtered out all non-defined names from the background knowledge for each node

Previously, replicators (and possibly other names) could appear at nodes where they weren't even in scope.
This commit is contained in:
Neil Brown 2009-02-08 18:42:01 +00:00
parent b08ac42547
commit a71499c268

View File

@ -102,9 +102,13 @@ followBK = map followBK'
addBK :: Map.Map Node (Map.Map Var (Set.Set (Maybe A.Expression))) ->
Map.Map Node [A.Expression] -> FlowGraph PassM UsageLabel ->
Node -> FNode PassM UsageLabel -> FNode PassM (BK, UsageLabel)
addBK mp mp2 g nid n = fmap ((,) $ followBK (map (Map.fromListWith (++)) $ productN $ conBK ++
repBK ++ values)) n
addBK mp mp2 g nid n = fmap ((,) $ followBK (map (keepDefined . Map.fromListWith (++)) $
productN $ conBK ++ repBK ++ values)) n
where
keepDefined :: Map.Map Var a -> Map.Map Var a
keepDefined m = Map.intersection m $ Map.fromList
[(Var (A.Variable emptyMeta (A.Name emptyMeta n)), ()) | n <- getNodeNames n]
nodeInQuestion :: Map.Map Var (Set.Set (Maybe A.Expression))
nodeInQuestion = fromMaybe Map.empty $ Map.lookup nid mp