@@ -182,7 +182,7 @@ dispatch (Check filePath stats) = do
182182compileFile :: StatsEnabled -> FilePath -> IO (Term () (IO () ))
183183compileFile stats filePath = do
184184 t0 <- getTime
185- ! result <- parseFile filePath
185+ ! result <- parseFile (nestStat stats) filePath
186186 t1 <- getTime
187187 emitStat stats " parse" (t1- t0)
188188 case result of
@@ -2545,12 +2545,24 @@ data File = File
25452545 }
25462546
25472547-- Parse a file into a list of decls, but strip shebangs.
2548- parseFile :: String -> IO (Either String File )
2549- parseFile filePath = do
2548+ parseFile :: StatsEnabled -> String -> IO (Either String File )
2549+ parseFile stats filePath = do
2550+ t0 <- getTime
25502551 string <- ByteString. readFile filePath
2551- pure $ case HSE. parseModuleWithMode HSE. defaultParseMode {HSE. parseFilename = filePath, HSE. extensions = HSE. extensions HSE. defaultParseMode ++ [HSE. EnableExtension HSE. PatternSignatures , HSE. EnableExtension HSE. DataKinds , HSE. EnableExtension HSE. BlockArguments , HSE. EnableExtension HSE. TypeApplications , HSE. EnableExtension HSE. NamedFieldPuns ]} (Text. unpack (dropShebang (Text. decodeUtf8 string))) >>= parseModule of
2552- HSE. ParseFailed l e -> Left $ " Parse error: " <> HSE. prettyPrint l <> " : " <> e
2553- HSE. ParseOk file -> Right file
2552+ t1 <- getTime
2553+ emitStat stats " read_file" (t1- t0)
2554+ case HSE. parseModuleWithMode HSE. defaultParseMode {HSE. parseFilename = filePath, HSE. extensions = HSE. extensions HSE. defaultParseMode ++ [HSE. EnableExtension HSE. PatternSignatures , HSE. EnableExtension HSE. DataKinds , HSE. EnableExtension HSE. BlockArguments , HSE. EnableExtension HSE. TypeApplications , HSE. EnableExtension HSE. NamedFieldPuns ]} (Text. unpack (dropShebang (Text. decodeUtf8 string))) of
2555+ HSE. ParseFailed l e -> pure $ Left $ " Parse error: " <> HSE. prettyPrint l <> " : " <> e
2556+ HSE. ParseOk ! file -> do
2557+ t2 <- getTime
2558+ emitStat stats " parse_module_with_mode" (t2- t1)
2559+ case parseModule file of
2560+ HSE. ParseFailed l e ->
2561+ pure $ Left $ " Parse error: " <> HSE. prettyPrint l <> " : " <> e
2562+ HSE. ParseOk ! file' -> do
2563+ t3 <- getTime
2564+ emitStat stats " resolve_module" (t3- t2)
2565+ pure $ Right file'
25542566
25552567-- This should be quite efficient because it's essentially a pointer
25562568-- increase. It leaves the \n so that line numbers are intact.
0 commit comments