~ubuntu-branches/ubuntu/wily/agda/wily-proposed

« back to all changes in this revision

Viewing changes to src/full/Agda/Compiler/Epic/Compiler.hs

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-08-05 06:38:12 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140805063812-io8e77niomivhd49
Tags: 2.4.0.2-1
* [6e140ac] Imported Upstream version 2.4.0.2
* [2049fc8] Update Build-Depends to match control
* [93dc4d4] Install the new primitives
* [e48f40f] Fix typo dev→doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
{-# LANGUAGE CPP #-}
 
2
 
2
3
-- | Epic compiler backend.
3
4
module Agda.Compiler.Epic.Compiler(compilerMain) where
4
5
 
12
13
import qualified Data.Set as S
13
14
import Data.Maybe
14
15
import Data.Monoid
15
 
import qualified Language.Haskell.Exts.Syntax as Haskell
16
16
import System.Directory ( canonicalizePath, createDirectoryIfMissing
17
17
                        , getCurrentDirectory, setCurrentDirectory
18
18
                        )
22
22
 
23
23
import Paths_Agda
24
24
import Agda.Compiler.CallCompiler
25
 
import Agda.Compiler.MAlonzo.Pretty -- TODO: Move shared code to Compiler.*
26
 
import Agda.Compiler.MAlonzo.Primitives (checkTypeOfMain)
27
25
import Agda.Interaction.FindFile
28
26
import Agda.Interaction.Options
29
27
import Agda.Interaction.Imports
36
34
import Agda.Utils.FileName
37
35
import qualified Agda.Utils.HashMap as HMap
38
36
 
39
 
import qualified Agda.TypeChecking.Pretty as P
40
 
 
41
37
import Agda.Compiler.Epic.CompileState
42
38
import qualified Agda.Compiler.Epic.CaseOpts     as COpts
43
39
import qualified Agda.Compiler.Epic.ForceConstrs as ForceC
67
63
-- | Compile an interface into an executable using Epic
68
64
compilerMain :: Interface -> TCM ()
69
65
compilerMain inter = do
70
 
    epic_exist <- liftIO $ rawSystem "ghc-pkg" ["-v0", "field", "epic", "id"]
 
66
    (epic_exist, _, _) <-
 
67
       liftIO $ readProcessWithExitCode
 
68
                  "ghc-pkg"
 
69
                  ["-v0", "field", "epic", "id"]
 
70
                  ""
71
71
    case epic_exist of
72
72
        ExitSuccess -> flip evalStateT initCompileState $ do
73
73
            compilePrelude
105
105
        Just eifs -> return eifs
106
106
        Nothing  -> do
107
107
            imports <- map miInterface . catMaybes
108
 
                                      <$> mapM (lift . getVisitedModule . toTopLevelModuleName)
 
108
                                      <$> mapM (lift . getVisitedModule . toTopLevelModuleName . fst)
109
109
                                               (iImportedModules i)
110
110
            (ifaces, limps) <- mapAndUnzipM compileModule imports
111
111
            let imps = S.unions limps
175
175
      _ -> return ()
176
176
 
177
177
idPrint s m x = do
178
 
  -- liftIO $ putStrLn s
 
178
  lift $ reportSLn "epic.phases" 10 s
179
179
  m x
180
180
 
181
181
-- | Perform the chain of compilation stages, from definitions to epic code