CompilerEnv.hs 1.78 KB
Newer Older
Björn Peemöller 's avatar
Björn Peemöller committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{- |
    Module      :  $Header$
    Description :  Environment containing the module's information
    Copyright   :  (c) 2011, Björn Peemöller (bjp@informatik.uni-kiel.de)
    License     :  OtherLicense

    Maintainer  :  bjp@informatik.uni-kiel.de
    Stability   :  experimental
    Portability :  portable

    This module defines an environment for a module containing the information
    needed throughout the compilation of the module.
-}

-- TODO: rename to Base.ModuleEnv ?

Björn Peemöller 's avatar
Björn Peemöller committed
17
18
19
20
21
22
module CompilerEnv where

import Curry.Base.Ident (ModuleIdent)

import Env.Arity
import Env.Eval
Björn Peemöller 's avatar
Björn Peemöller committed
23
import Env.Interface
Björn Peemöller 's avatar
Björn Peemöller committed
24
import Env.Label
Björn Peemöller 's avatar
Björn Peemöller committed
25
import Env.ModuleAlias
Björn Peemöller 's avatar
Björn Peemöller committed
26
27
28
29
import Env.OpPrec
import Env.TypeConstructors
import Env.Value

Björn Peemöller 's avatar
Björn Peemöller committed
30
31
32
-- |A compiler environment contains information about the module currently
--  compiled. The information is updated during the different stages of
--  compilation.
Björn Peemöller 's avatar
Björn Peemöller committed
33
data CompilerEnv = CompilerEnv
Björn Peemöller 's avatar
Björn Peemöller committed
34
35
36
37
38
39
40
41
42
  { moduleIdent  :: ModuleIdent  -- ^ identifier of the module
  , aliasEnv     :: AliasEnv     -- ^ aliases for imported modules
  , arityEnv     :: ArityEnv     -- ^ arity of functions and data constructors
  , evalAnnotEnv :: EvalEnv      -- ^ evaluation annotations
  , interfaceEnv :: InterfaceEnv -- ^ declarations of imported interfaces
  , labelEnv     :: LabelEnv     -- ^ record labels
  , opPrecEnv    :: PEnv         -- ^ operator precedences
  , tyConsEnv    :: TCEnv        -- ^ type constructors
  , valueEnv     :: ValueEnv     -- ^ functions, ...
Björn Peemöller 's avatar
Björn Peemöller committed
43
44
45
46
47
  }

initCompilerEnv :: ModuleIdent -> CompilerEnv
initCompilerEnv mid = CompilerEnv
  { moduleIdent  = mid
48
  , aliasEnv     = initAliasEnv
Björn Peemöller 's avatar
Björn Peemöller committed
49
50
  , arityEnv     = initAEnv
  , evalAnnotEnv = initEEnv
Björn Peemöller 's avatar
Björn Peemöller committed
51
  , interfaceEnv = initInterfaceEnv
Björn Peemöller 's avatar
Björn Peemöller committed
52
  , labelEnv     = initLabelEnv
Björn Peemöller 's avatar
Björn Peemöller committed
53
54
55
56
  , opPrecEnv    = initPEnv
  , tyConsEnv    = initTCEnv
  , valueEnv     = initDCEnv
  }