Skip to content
Snippets Groups Projects

compare-ticks: Fix package-less constructor name parsing

Open Sebastian Graf requested to merge sgraf812/ghc-utils:master into master
@@ -22,6 +22,12 @@ import Control.Applicative
import Data.Monoid
import qualified Data.Text as T
import Prelude
import Debug.Trace
_trcM :: Applicative f => String -> f ()
_trcM s
| id False = traceM s
| otherwise = pure ()
data TickyReport = TickyReport { frames :: [TickyFrame] }
deriving (Show)
@@ -150,19 +156,25 @@ parseClosureKind = choice
, Thunk True False <$ text "(thk,std)"
, Thunk True True <$ text "(thk,se,std)"
, Con "" <$ text "(con)" -- prior to 8.12 we didn't emit the constructor name
, do void $ text "(con: "
, do void $ text "(con: " -- e.g. (con: GHC.Num.Integer.IS{(w) d 65O})
_trcM ("pck")
conName <- parseConName
_trcM ("pck " ++ show conName)
void $ text ")"
return (Con conName)
]
-- e.g. GHC.Num.Integer.IS{(w) d 65O}
parseConName :: Parser String
parseConName = do
pkg <- some (noneOf ":")
c <- fmap (:[]) (char ':')
_trcM ("pcn")
pkg <- fromMaybe "" <$> optional (try (many (noneOf ":.{") <* char ':'))
_trcM ("pcn:pkg " ++ show pkg)
modAndCon <- some (noneOf "{")
_trcM ("pcn:modC " ++ show modAndCon)
annot <- braces $ some (noneOf "}")
return $ concat [pkg, c, modAndCon, "{", annot, "}"]
_trcM ("pcn:annot " ++ show annot)
return $ concat [pkg, modAndCon, "{", annot, "}"]
parseStgName :: Parser StgName
parseStgName = topName <|> try nonExportedName <|> exportedName
@@ -185,17 +197,20 @@ exportedName = named "exported name" $ do
void $ optional parseClosureKind
return $ StgName True modname _name _sig Nothing
-- e.g. sat_sbMg{v} (main@main:Main) in sbMh
-- e.g. sat_sbMg{v} (main@main:Main) (con: GHC.Num.Integer.IS{(w) d 65O}) in sbMh
nonExportedName :: Parser StgName
nonExportedName = named "non-exported name" $ do
--_name <- funcName
_trcM ("trying nen")
_name <- many $ noneOf "{"
_sig <- sig
spaces
modname <- fmap (fromMaybe noModule) $ optional $ try $ parens parseModuleName
_trcM ("nen:modname " ++ show modname)
spaces
void $ optional parseClosureKind
_clokind <- optional parseClosureKind
_trcM ("nen:clokind " ++ show _clokind)
parent <- optional $ spaces *> text "in" *> spaces *> funcName
_trcM ("nen:parent " ++ show parent)
return $ StgName False modname _name _sig parent
startsWith :: Parser a -> Parser a -> Parser [a]
Loading