From 5f124636fbe384debbf57e480e30ef078d5ff5ab Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 3 Apr 2009 16:52:40 +0000 Subject: [PATCH] Fixed the name munged to be stable for #USE directives, but use the old name counter for #INCLUDE directives This is necessary because occam files often #INCLUDE something multiple times (e.g. cgtests) and want different names, but this is not the case for #USE. --- data/CompState.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/data/CompState.hs b/data/CompState.hs index 0402785..aae0f2e 100644 --- a/data/CompState.hs +++ b/data/CompState.hs @@ -263,7 +263,16 @@ nameSource n = lookupName n >>* A.ndNameSource -- | Make a name unique by appending a suffix to it. makeUniqueName :: CSM m => Meta -> String -> m String makeUniqueName m s - = let mungedFile = mungeMeta m in return $ s ++ "_" ++ mungedFile + = do cs <- getCompState + munged <- if maybe "" (++ ".tock.inc") (metaFile m) + `Set.member` csUsedFiles cs + -- For #USEd files, keep the filename stable: + then return $ mungeMeta m + -- For #INCLUDEd files, they might be included twice, so we + -- still need the extra suffixes: + else do put $ cs { csNameCounter = csNameCounter cs + 1 } + return $ "u" ++ show (csNameCounter cs) + return $ s ++ "_" ++ munged mungeMeta :: Meta -> String mungeMeta m = [if c `elem` (['A'..'Z'] ++ ['a'..'z'] ++ ['0'..'9'])