[commit: ghc] master: Clean up and remove todo. (9ebbdf3)

git at git.haskell.org git at git.haskell.org
Tue Oct 7 13:53:07 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9ebbdf3fa5d0d34d8b42fbd3e79ac2a1cfa9272d/ghc

>---------------------------------------------------------------

commit 9ebbdf3fa5d0d34d8b42fbd3e79ac2a1cfa9272d
Author: Joel Burget <joel at khanacademy.org>
Date:   Tue Oct 7 08:51:13 2014 -0500

    Clean up and remove todo.
    
    Summary:
    The code is equivalent, just formatted nicely and without the
    enthusiastic message to clean it up.
    
    Test Plan: None
    
    Reviewers: austin
    
    Reviewed By: austin
    
    Subscribers: simonmar, ezyang, carter, thomie
    
    Differential Revision: https://phabricator.haskell.org/D307


>---------------------------------------------------------------

9ebbdf3fa5d0d34d8b42fbd3e79ac2a1cfa9272d
 compiler/basicTypes/Module.lhs |  2 +-
 compiler/ghci/ByteCodeLink.lhs | 43 ++++++++++++++++++++++--------------------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/compiler/basicTypes/Module.lhs b/compiler/basicTypes/Module.lhs
index d403c87..edd2986 100644
--- a/compiler/basicTypes/Module.lhs
+++ b/compiler/basicTypes/Module.lhs
@@ -46,7 +46,7 @@ module Module
         wiredInPackageKeys,
 
         -- * The Module type
-        Module,
+        Module(Module),
         modulePackageKey, moduleName,
         pprModule,
         mkModule,
diff --git a/compiler/ghci/ByteCodeLink.lhs b/compiler/ghci/ByteCodeLink.lhs
index af31dc1..9656dfb 100644
--- a/compiler/ghci/ByteCodeLink.lhs
+++ b/compiler/ghci/ByteCodeLink.lhs
@@ -257,25 +257,28 @@ linkFail who what
                 , "  glasgow-haskell-bugs at haskell.org"
                 ])
 
--- HACKS!!!  ToDo: cleaner
-nameToCLabel :: Name -> String{-suffix-} -> String
-nameToCLabel n suffix
-   = if pkgid /= mainPackageKey
-        then package_part ++ '_': qual_name
-        else qual_name
-  where
-        pkgid = modulePackageKey mod
-        mod = ASSERT( isExternalName n ) nameModule n
-        package_part = zString (zEncodeFS (packageKeyFS (modulePackageKey mod)))
-        module_part  = zString (zEncodeFS (moduleNameFS (moduleName mod)))
-        occ_part     = zString (zEncodeFS (occNameFS (nameOccName n)))
-        qual_name = module_part ++ '_':occ_part ++ '_':suffix
-
-
-primopToCLabel :: PrimOp -> String{-suffix-} -> String
-primopToCLabel primop suffix
-   = let str = "ghczmprim_GHCziPrimopWrappers_" ++ zString (zEncodeFS (occNameFS (primOpOcc primop))) ++ '_':suffix
-     in --trace ("primopToCLabel: " ++ str)
-        str
+
+nameToCLabel :: Name -> String -> String
+nameToCLabel n suffix = label where
+    encodeZ = zString . zEncodeFS
+    (Module pkgKey modName) = ASSERT( isExternalName n ) nameModule n
+    packagePart = encodeZ (packageKeyFS pkgKey)
+    modulePart  = encodeZ (moduleNameFS modName)
+    occPart     = encodeZ (occNameFS (nameOccName n))
+
+    label = concat
+        [ if pkgKey == mainPackageKey then "" else packagePart ++ "_"
+        , modulePart
+        , '_':occPart
+        , '_':suffix
+        ]
+
+
+primopToCLabel :: PrimOp -> String -> String
+primopToCLabel primop suffix = concat
+    [ "ghczmprim_GHCziPrimopWrappers_"
+    , zString (zEncodeFS (occNameFS (primOpOcc primop)))
+    , '_':suffix
+    ]
 \end{code}
 



More information about the ghc-commits mailing list