X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FVar.lhs;h=351082859297d5bba8a6629182eb476c15464e15;hb=1166c7d62f3fa9acd2084c90df6585cbbf868ceb;hp=e4aa8c23d65ae5c46a08433c3c9340ee246108c9;hpb=6fcf90065dc4e75b7dc6bbf238a9891a71ae5a86;p=ghc-hetmet.git diff --git a/compiler/basicTypes/Var.lhs b/compiler/basicTypes/Var.lhs index e4aa8c2..3510828 100644 --- a/compiler/basicTypes/Var.lhs +++ b/compiler/basicTypes/Var.lhs @@ -1,4 +1,5 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % \section{@Vars@: Variables} @@ -10,7 +11,7 @@ module Var ( setVarName, setVarUnique, -- TyVars - TyVar, mkTyVar, mkTcTyVar, mkWildTyVar, + TyVar, mkTyVar, mkTcTyVar, mkWildCoVar, tyVarName, tyVarKind, setTyVarName, setTyVarUnique, setTyVarKind, tcTyVarDetails, @@ -22,7 +23,7 @@ module Var ( Id, DictId, idName, idType, idUnique, idInfo, modifyIdInfo, maybeModifyIdInfo, setIdName, setIdUnique, setIdType, setIdInfo, lazySetIdInfo, - setIdExported, setIdNotExported, + setIdExported, setIdNotExported, globalIdDetails, globaliseId, @@ -35,17 +36,15 @@ module Var ( #include "HsVersions.h" -import {-# SOURCE #-} TypeRep( Type, Kind, isCoSuperKind ) +import {-# SOURCE #-} TypeRep( Type, Kind ) import {-# SOURCE #-} TcType( TcTyVarDetails, pprTcTyVarDetails ) -import {-# SOURCE #-} IdInfo( GlobalIdDetails, notGlobalId, IdInfo, seqIdInfo ) - -import Name ( Name, NamedThing(..), - setNameUnique, nameUnique, mkSysTvName - ) -import Unique ( Unique, Uniquable(..), mkUniqueGrimily, getKey#, - mkBuiltinUnique ) +import {-# SOURCE #-} IdInfo( GlobalIdDetails, notGlobalId, + IdInfo, seqIdInfo ) +import Name hiding (varName) +import Unique import FastTypes -import Outputable +import FastString +import Outputable \end{code} @@ -68,7 +67,9 @@ data Var realUnique :: FastInt, -- Key for fast comparison -- Identical to the Unique in the name, -- cached here for speed - tyVarKind :: Kind } + tyVarKind :: Kind, + isCoercionVar :: Bool + } | TcTyVar { -- Used only during type inference -- Used for kind variables during @@ -189,6 +190,7 @@ mkTyVar :: Name -> Kind -> TyVar mkTyVar name kind = TyVar { varName = name , realUnique = getKey# (nameUnique name) , tyVarKind = kind + , isCoercionVar = False } mkTcTyVar :: Name -> Kind -> TcTyVarDetails -> TyVar @@ -199,13 +201,16 @@ mkTcTyVar name kind details tcTyVarDetails = details } -mkWildTyVar :: Kind -> TyVar -mkWildTyVar kind +mkWildCoVar :: Kind -> TyVar +-- A type variable that is never referred to, +-- so its unique doesn't matter +mkWildCoVar kind = TyVar { varName = mkSysTvName wild_uniq FSLIT("co_wild"), realUnique = _ILIT(1), - tyVarKind = kind } + tyVarKind = kind, + isCoercionVar = True } where - wild_uniq = (mkBuiltinUnique 1) + wild_uniq = mkBuiltinUnique 1 \end{code} %************************************************************************ @@ -223,10 +228,12 @@ setCoVarUnique = setVarUnique setCoVarName = setVarName mkCoVar :: Name -> Kind -> CoVar -mkCoVar name kind = mkTyVar name kind +mkCoVar name kind = TyVar { varName = name + , realUnique = getKey# (nameUnique name) + , tyVarKind = kind + , isCoercionVar = True + } -isCoVar :: TyVar -> Bool -isCoVar ty = isCoSuperKind (tyVarKind ty) \end{code} %************************************************************************ @@ -342,6 +349,9 @@ isId other = False isLocalId (LocalId {}) = True isLocalId other = False +isCoVar (v@(TyVar {})) = isCoercionVar v +isCoVar other = False + -- isLocalVar returns True for type variables as well as local Ids -- These are the variables that we need to pay attention to when finding free -- variables, or doing dependency analysis.