diff options
author | Alec Theriault <alec.theriault@gmail.com> | 2018-12-11 13:47:35 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2018-12-11 14:23:22 -0500 |
commit | f582379de2c4ff7577235c926ad953debdae3cac (patch) | |
tree | df39b7a00d1730be04da120ca452517043478809 /compiler/utils | |
parent | 21339c9f6bfb952a3a0b8de5ee649d46dfbf0d9b (diff) | |
download | haskell-f582379de2c4ff7577235c926ad953debdae3cac.tar.gz |
Support generating HIE files
Adds a `-fenable-ide-info` flag which instructs GHC to generate `.hie`
files (see the wiki page:
https://ghc.haskell.org/trac/ghc/wiki/HIEFiles).
This is a rebased version of Zubin Duggal's (@wz1000) GHC changes for
his GSOC project, as posted here:
https://gist.github.com/wz1000/5ed4ddd0d3e96d6bc75e095cef95363d.
Test Plan: ./validate
Reviewers: bgamari, gershomb, nomeata, alanz, sjakobi
Reviewed By: alanz, sjakobi
Subscribers: alanz, hvr, sjakobi, rwbarton, wz1000, carter
Differential Revision: https://phabricator.haskell.org/D5239
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/Binary.hs | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index c8b4989bf3..4bd05da485 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -409,6 +409,15 @@ instance Binary a => Binary [a] where loop n = do a <- get bh; as <- loop (n-1); return (a:as) loop len +instance (Ix a, Binary a, Binary b) => Binary (Array a b) where + put_ bh arr = do + put_ bh $ bounds arr + put_ bh $ elems arr + get bh = do + bounds <- get bh + xs <- get bh + return $ listArray bounds xs + instance (Binary a, Binary b) => Binary (a,b) where put_ bh (a,b) = do put_ bh a; put_ bh b get bh = do a <- get bh @@ -1147,14 +1156,27 @@ instance Binary a => Binary (Located a) where x <- get bh return (L l x) +instance Binary RealSrcSpan where + put_ bh ss = do + put_ bh (srcSpanFile ss) + put_ bh (srcSpanStartLine ss) + put_ bh (srcSpanStartCol ss) + put_ bh (srcSpanEndLine ss) + put_ bh (srcSpanEndCol ss) + + get bh = do + f <- get bh + sl <- get bh + sc <- get bh + el <- get bh + ec <- get bh + return (mkRealSrcSpan (mkRealSrcLoc f sl sc) + (mkRealSrcLoc f el ec)) + instance Binary SrcSpan where put_ bh (RealSrcSpan ss) = do putByte bh 0 - put_ bh (srcSpanFile ss) - put_ bh (srcSpanStartLine ss) - put_ bh (srcSpanStartCol ss) - put_ bh (srcSpanEndLine ss) - put_ bh (srcSpanEndCol ss) + put_ bh ss put_ bh (UnhelpfulSpan s) = do putByte bh 1 @@ -1163,13 +1185,8 @@ instance Binary SrcSpan where get bh = do h <- getByte bh case h of - 0 -> do f <- get bh - sl <- get bh - sc <- get bh - el <- get bh - ec <- get bh - return (mkSrcSpan (mkSrcLoc f sl sc) - (mkSrcLoc f el ec)) + 0 -> do ss <- get bh + return (RealSrcSpan ss) _ -> do s <- get bh return (UnhelpfulSpan s) |