[commit: ghc] ghc-8.2: Eliminate word-size dependence in HsDumpAst output (b8f16d8)

git at git.haskell.org git at git.haskell.org
Mon Mar 27 03:00:54 UTC 2017


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

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/b8f16d89d803913f124d26cfcaa02d2d6f0b26c8/ghc

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

commit b8f16d89d803913f124d26cfcaa02d2d6f0b26c8
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Fri Mar 24 12:05:23 2017 -0400

    Eliminate word-size dependence in HsDumpAst output
    
    Fixes DumpTypecheckedAst output on 32-bit platforms.
    
    (cherry picked from commit bc9f280acf82d34fea72199a34b00c414c3ef59e)


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

b8f16d89d803913f124d26cfcaa02d2d6f0b26c8
 compiler/hsSyn/HsDumpAst.hs                        | 16 ++++++-
 .../should_compile/DumpTypecheckedAst.stderr       | 54 +++++++++++-----------
 2 files changed, 42 insertions(+), 28 deletions(-)

diff --git a/compiler/hsSyn/HsDumpAst.hs b/compiler/hsSyn/HsDumpAst.hs
index f735488..b76b3fb 100644
--- a/compiler/hsSyn/HsDumpAst.hs
+++ b/compiler/hsSyn/HsDumpAst.hs
@@ -18,6 +18,7 @@ module HsDumpAst (
 import Data.Data hiding (Fixity)
 import Data.List
 import Bag
+import BasicTypes
 import FastString
 import NameSet
 import Name
@@ -46,7 +47,7 @@ showAstData b = showAstData' 0
     showAstData' n =
       generic
               `ext1Q` list
-              `extQ` string `extQ` fastString `extQ` srcSpan
+              `extQ` string `extQ` fastString `extQ` srcSpan `extQ` lit
               `extQ` bytestring
               `extQ` name `extQ` occName `extQ` moduleName `extQ` var
               `extQ` dataCon
@@ -76,6 +77,19 @@ showAstData b = showAstData' 0
                                 ++ intercalate "," (map (showAstData' (n+1)) l)
                                 ++ "]"
 
+            -- Eliminate word-size dependence
+            lit :: HsLit -> String
+            lit (HsWordPrim   s x) = numericLit "HsWord{64}Prim" x s
+            lit (HsWord64Prim s x) = numericLit "HsWord{64}Prim" x s
+            lit (HsIntPrim    s x) = numericLit "HsInt{64}Prim"  x s
+            lit (HsInt64Prim  s x) = numericLit "HsInt{64}Prim"  x s
+            lit l                  = generic l
+
+            numericLit :: String -> Integer -> SourceText -> String
+            numericLit tag x s = indent n ++ unwords [ "{" ++ tag
+                                                     , generic x
+                                                     , generic s ++ "}" ]
+
             name :: Name -> String
             name       = ("{Name: "++) . (++"}") . showSDocDebug_ . ppr
 
diff --git a/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr b/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr
index 3725b6f..4b10222 100644
--- a/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr
+++ b/testsuite/tests/parser/should_compile/DumpTypecheckedAst.stderr
@@ -21,14 +21,14 @@
                  ({abstract:ConLike}))) 
                ({ <no location info> }
                 (HsLit 
-                 (HsWordPrim 
-                  (NoSourceText) 
-                  (14073232900889011755)))))) 
+                 {HsWord{64}Prim 
+                 (14073232900889011755) 
+                 (NoSourceText)})))) 
              ({ <no location info> }
               (HsLit 
-               (HsWordPrim 
-                (NoSourceText) 
-                (2739668351064589274)))))) 
+               {HsWord{64}Prim 
+               (2739668351064589274) 
+               (NoSourceText)})))) 
            ({ <no location info> }
             (HsVar 
              ({ <no location info> }{Var: (main:DumpTypecheckedAst.$trModule{v} [lidx] :: ghc-prim:GHC.Types.Module{tc})}))))) 
@@ -45,9 +45,9 @@
                 (NoSourceText) "Peano"))))))))) 
        ({ <no location info> }
         (HsLit 
-         (HsIntPrim 
-          (SourceText "0") 
-          (0)))))) 
+         {HsInt{64}Prim 
+         (0) 
+         (SourceText "0")})))) 
      ({ <no location info> }
       (HsVar 
        ({ <no location info> }{Var: (ghc-prim:GHC.Types.krep$*{v} [gid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) 
@@ -71,14 +71,14 @@
                  ({abstract:ConLike}))) 
                ({ <no location info> }
                 (HsLit 
-                 (HsWordPrim 
-                  (NoSourceText) 
-                  (13760111476013868540)))))) 
+                 {HsWord{64}Prim 
+                 (13760111476013868540) 
+                 (NoSourceText)})))) 
              ({ <no location info> }
               (HsLit 
-               (HsWordPrim 
-                (NoSourceText) 
-                (12314848029315386153)))))) 
+               {HsWord{64}Prim 
+               (12314848029315386153) 
+               (NoSourceText)})))) 
            ({ <no location info> }
             (HsVar 
              ({ <no location info> }{Var: (main:DumpTypecheckedAst.$trModule{v} [lidx] :: ghc-prim:GHC.Types.Module{tc})}))))) 
@@ -95,9 +95,9 @@
                 (NoSourceText) "'Zero"))))))))) 
        ({ <no location info> }
         (HsLit 
-         (HsIntPrim 
-          (SourceText "0") 
-          (0)))))) 
+         {HsInt{64}Prim 
+         (0) 
+         (SourceText "0")})))) 
      ({ <no location info> }
       (HsVar 
        ({ <no location info> }{Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) 
@@ -121,14 +121,14 @@
                  ({abstract:ConLike}))) 
                ({ <no location info> }
                 (HsLit 
-                 (HsWordPrim 
-                  (NoSourceText) 
-                  (1143980031331647856)))))) 
+                 {HsWord{64}Prim 
+                 (1143980031331647856) 
+                 (NoSourceText)})))) 
              ({ <no location info> }
               (HsLit 
-               (HsWordPrim 
-                (NoSourceText) 
-                (14802086722010293686)))))) 
+               {HsWord{64}Prim 
+               (14802086722010293686) 
+               (NoSourceText)})))) 
            ({ <no location info> }
             (HsVar 
              ({ <no location info> }{Var: (main:DumpTypecheckedAst.$trModule{v} [lidx] :: ghc-prim:GHC.Types.Module{tc})}))))) 
@@ -145,9 +145,9 @@
                 (NoSourceText) "'Succ"))))))))) 
        ({ <no location info> }
         (HsLit 
-         (HsIntPrim 
-          (SourceText "0") 
-          (0)))))) 
+         {HsInt{64}Prim 
+         (0) 
+         (SourceText "0")})))) 
      ({ <no location info> }
       (HsVar 
        ({ <no location info> }{Var: ($krep{v} [lid] :: ghc-prim:GHC.Types.KindRep{tc})}))))) 



More information about the ghc-commits mailing list