From: Matthijs Kooijman Date: Thu, 29 Jan 2009 10:42:50 +0000 (+0100) Subject: Add a uniqueName function. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=6bf116914c36c98e7f76ec9c20f993cd847a7ee8;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add a uniqueName function. This function appends a unique number to names to make the names unique. --- diff --git a/Translator.hs b/Translator.hs index ad4feeb..713698c 100644 --- a/Translator.hs +++ b/Translator.hs @@ -287,6 +287,15 @@ getHWFunc name = do (error $ "Function " ++ name ++ "is unknown? This should not happen!") (lookup name fs) +-- Makes the given name unique by appending a unique number. +-- This does not do any checking against existing names, so it only guarantees +-- uniqueness with other names generated by uniqueName. +uniqueName :: String -> VHDLState String +uniqueName name = do + count <- State.gets nameCount -- Get the funcs element from the session + State.modify (\s -> s {nameCount = count + 1}) + return $ name ++ "-" ++ (show count) + builtin_funcs = [ ("hwxor", HWFunction [Port "a", Port "b"] (Port "o")),