-- -----------------------------------------------------------------------------

rename :: Name -> MemoryMap -> Name
rename n mm = if (not ("source" `isPrefixOf` n)) 
                 then n' 
                 else n
    where 
      (j,at) = case Map.lookup n mm of 
               Nothing -> error $ "error: "++ n ++" not found in MemoryMap"  
               Just a -> a 
      n' = case at of 
             Global_Array t ->    
                 "(("++ptrStr t++")(gbase+"++ show j++"))"
             Shared_Array t ->    
                 "(("++ptrStr t++")(sbase+"++ show j++"))"
             Constant_Array t ->   
                 "(("++ptrStr t++")(cbase+"++ show j++"))"
rename :: Name -> MemoryMap -> Name
rename n mm = if (not ("source" `isPrefixOf` n)) 
                 then n' 
                 else n
    where 
      (j,at) = case Map.lookup n mm of 
               Nothing -> error $ "error: "++ n ++" not found in MemoryMap"  
               Just a -> a 
      n' = case at of 
             Global_Array t ->    
                 "(("++ptrStr t++")(gbase+"++ show j++"))"
             Shared_Array t ->    
                 "(("++ptrStr t++")(sbase+"++ show j++"))"
             Constant_Array t ->   
                 "(("++ptrStr t++")(cbase+"++ show j++"))"
rename n mm = if (not ("source" `isPrefixOf` n)) 
                 then n' 
                 else n
    where 
      (j,at) = case Map.lookup n mm of 
               Nothing -> error $ "error: "++ n ++" not found in MemoryMap"  
               Just a -> a 
      n' = case at of 
             Global_Array t ->    
                 "(("++ptrStr t++")(gbase+"++ show j++"))"
             Shared_Array t ->    
                 "(("++ptrStr t++")(sbase+"++ show j++"))"
             Constant_Array t ->   
                 "(("++ptrStr t++")(cbase+"++ show j++"))"