Skip to content
This repository was archived by the owner on Nov 1, 2018. It is now read-only.

Commit

Permalink
refactorization of flow of datatype info (dataGam) and function info …
Browse files Browse the repository at this point in the history
…(lamMp) into separate toplevel statestructure, independent of backend usage
  • Loading branch information
atzedijkstra committed Oct 13, 2015
1 parent a81d583 commit a1a85e5
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 63 deletions.
3 changes: 3 additions & 0 deletions EHC/configure
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ CFLAGS
CC
GCC_CMD
gccCmd
RULER_EXISTS
RULER_CMD
rulerCmd
SHUFFLE_CMD
Expand Down Expand Up @@ -4298,6 +4299,8 @@ else
fi
RULER_CMD=$rulerCmd
RULER_EXISTS=$rulerExists
# gcc
Expand Down
1 change: 1 addition & 0 deletions EHC/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ else
rulerExists="no"
fi
AC_SUBST(RULER_CMD,$rulerCmd)
AC_SUBST(RULER_EXISTS,$rulerExists)

# gcc
AC_ARG_WITH(gcc,
Expand Down
8 changes: 8 additions & 0 deletions EHC/mk/shared.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ SHELL_FILTER_NONEMP_FILES := $(BINABS_PREFIX)filterOutEmptyFiles
SHELL_AGDEPEND := $(BINABS_PREFIX)agdepend
TAR := @TAR_CMD@

#tool existence
ifeq (@RULER_EXISTS@,yes)
RULER_EXISTS := yes
else
# just leave empty
RULER_EXISTS :=
endif

# lhs2TeX
LHS2TEX_ENV := $(LHS2TEX)
LHS2TEX_CMD := LHS2TEX=".$(PATHS_SEP)../../$(FMT_SRC_PREFIX)$(PATHS_SEP)$(LHS2TEX_ENV)" lhs2TeX
Expand Down
67 changes: 38 additions & 29 deletions EHC/src/ehc/EHC/BuildFunction/Run.chs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ bcall bfun = do
return $ \crsi ->
let opts = crsi ^. crsiOpts
ehInh = crsi ^. crsiEHInh
cenv = crsi ^. crsiCEnv
cenv' = cenvDataGam ^$= (EHSem.gathDataGam_Syn_AGItf ehSem `gamUnion`) $ cenv
ehInh' = ehInh
%%[[(50 hmtyinfer)
{ EHSem.dataGam_Inh_AGItf = EHSem.gathDataGam_Syn_AGItf ehSem `gamUnion` EHSem.dataGam_Inh_AGItf ehInh
{ -- EHSem.dataGam_Inh_AGItf = EHSem.gathDataGam_Syn_AGItf ehSem `gamUnion` EHSem.dataGam_Inh_AGItf ehInh
EHSem.dataGam_Inh_AGItf = cenv' ^. cenvDataGam
, EHSem.valGam_Inh_AGItf = EHSem.gathValGam_Syn_AGItf ehSem `gamUnion` EHSem.valGam_Inh_AGItf ehInh
, EHSem.tyGam_Inh_AGItf = EHSem.gathTyGam_Syn_AGItf ehSem `gamUnion` EHSem.tyGam_Inh_AGItf ehInh
, EHSem.tyKiGam_Inh_AGItf = EHSem.gathTyKiGam_Syn_AGItf ehSem `gamUnion` EHSem.tyKiGam_Inh_AGItf ehInh
Expand All @@ -221,7 +224,7 @@ bcall bfun = do
%%]]
in -- From: cpFlowEHSem1
( ( crsiEHInh ^= ehInh' )
. ( (crsiCEnv ^* cenvDataGam) ^$= (EHSem.gathDataGam_Syn_AGItf ehSem `gamUnion`) )
. ( crsiCEnv ^= cenv' )
) $ crsi

%%[[(50 core corein)
Expand All @@ -234,14 +237,17 @@ bcall bfun = do
bcall $ FoldCoreModPlMb modSearchKey pl
) (return id) $ \_ (coreChkSem, _, _, _, _, _) -> do
-- 20151008 AD: TBD: dataGam needs independent passing around
return ( ( crsiCEnv ^* cenvDataGam ^$= (`gamUnion` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreChkSem)
)
return $ \crsi ->
let cenv = cenvDataGam ^$= (`gamUnion` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreChkSem) $ crsi ^. crsiCEnv
in ( ( crsiCEnv ^= cenv )
%%[[(50 grin)
. ( crsiCoreInh ^$= \coreInh ->
coreInh
{ Core2GrSem.dataGam_Inh_CodeAGItf = Core2GrSem.dataGam_Inh_CodeAGItf coreInh `gamUnion` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreChkSem }
. ( crsiCoreInh ^$= \coreInh ->
coreInh
-- { Core2GrSem.dataGam_Inh_CodeAGItf = Core2GrSem.dataGam_Inh_CodeAGItf coreInh `gamUnion` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreChkSem }
{Core2GrSem.dataGam_Inh_CodeAGItf = cenv ^. cenvDataGam}
%%]]
) )
) )
$ crsi
%%][50
let updCoreSrc = id
%%]]
Expand Down Expand Up @@ -271,13 +277,17 @@ bcall bfun = do
cpTrPP TraceOn_BldFlow ["ASTSemFlowStage_BetweenModule astpMbFromCoreToGrin" >#< modSearchKey, pp pl]
bcall $ FoldCore2GrinPlMb bglob modSearchKey pl
) (return id) $ \_ core2GrinSem -> do
return $ ( (crsiCEnv ^* cenvLamMp) ^$= (Core2GrSem.gathLamMp_Syn_CodeAGItf core2GrinSem `lamMpUnionBindAspMp`) )
%%[[50
. ( crsiCoreInh ^$= \coreInh ->
-- assumption: old info can safely be overridden, otherwise merge should be done here
coreInh { Core2GrSem.lamMp_Inh_CodeAGItf = Core2GrSem.gathLamMp_Syn_CodeAGItf core2GrinSem `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh }
)
%%]]
return $ \crsi ->
let cenv = cenvLamMp ^$= (Core2GrSem.gathLamMp_Syn_CodeAGItf core2GrinSem `lamMpUnionBindAspMp`) $ crsi ^. crsiCEnv
in ( ( crsiCEnv ^= cenv )
. ( crsiCoreInh ^$= \coreInh ->
coreInh
-- assumption: old info can safely be overridden, otherwise merge should be done here
-- { Core2GrSem.lamMp_Inh_CodeAGItf = Core2GrSem.gathLamMp_Syn_CodeAGItf core2GrinSem `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh }
{ Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp }
) )
$ crsi

%%][50
let updCoreGrin = id
%%]]
Expand Down Expand Up @@ -404,24 +414,24 @@ bcall bfun = do
bcall $ FoldEHPlMb bglob modSearchKey pl
) (return ()) $ \_ ehSem -> do
cpUpdSI $ \crsi ->
let ehInh = crsi ^. crsiEHInh
coreInh= crsi ^. crsiCoreInh
cenv = crsi ^. crsiCEnv
coreInh' = coreInh
%%[[8
{ Core2GrSem.dataGam_Inh_CodeAGItf = EHSem.gathDataGam_Syn_AGItf ehSem
, Core2GrSem.lamMp_Inh_CodeAGItf = lm
%%][50
{ Core2GrSem.dataGam_Inh_CodeAGItf = EHSem.dataGam_Inh_AGItf ehInh
, Core2GrSem.lamMp_Inh_CodeAGItf = lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
}
let ehInh = crsi ^. crsiEHInh
coreInh = crsi ^. crsiCoreInh
cenv = crsi ^. crsiCEnv
lm = EHSem.gathLamMp_Syn_AGItf ehSem
cenv' = ( cenvDataGam ^$= (EHSem.gathDataGam_Syn_AGItf ehSem `gamUnion`) )
%%[[(8 core)
. ( cenvLamMp ^$= (EHSem.gathLamMp_Syn_AGItf ehSem `lamMpUnionBindAspMp`) ) -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
$ cenv
coreInh' = coreInh
%%[[8
{ Core2GrSem.dataGam_Inh_CodeAGItf = cenv' ^. cenvDataGam -- EHSem.gathDataGam_Syn_AGItf ehSem
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp -- lm
%%][50
{ Core2GrSem.dataGam_Inh_CodeAGItf = cenv' ^. cenvDataGam -- EHSem.dataGam_Inh_AGItf ehInh
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp -- lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
}
in crsi -- From: cpFlowEHSem1
{ _crsiCoreInh = coreInh', _crsiCEnv = cenv' }
%%]]
Expand Down Expand Up @@ -977,7 +987,7 @@ ecuIsHSNewerThanHI ecu
]
, mieimplHsName2FldMp = expNmFldMp
%%[[(50 grin)
, mieimplLamMp = Core2GrSem.lamMp_Inh_CodeAGItf $ _crsiCoreInh crsi
, mieimplLamMp = crsi ^. crsiCEnv ^. cenvLamMp -- Core2GrSem.lamMp_Inh_CodeAGItf $ _crsiCoreInh crsi
%%]]
}

Expand Down Expand Up @@ -1171,7 +1181,6 @@ ecuIsHSNewerThanHI ecu
let inh = Core2ChkSem.Inh_CodeAGItf
{ Core2ChkSem.opts_Inh_CodeAGItf = opts
, Core2ChkSem.moduleNm_Inh_CodeAGItf = modNm
-- , Core2ChkSem.dataGam_Inh_CodeAGItf = EHSem.dataGam_Inh_AGItf $ crsi ^. crsiEHInh
}
coreSem = Core2ChkSem.cmodCheck' inh core
hasMain = Core2ChkSem.hasMain_Syn_CodeAGItf coreSem
Expand Down
6 changes: 4 additions & 2 deletions EHC/src/ehc/EHC/CompilePhase/Common.chs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Translation to another AST
%%]

-- general imports
%%[(50 codegen) import(qualified Data.Map as Map, qualified Data.Set as Set, qualified UHC.Util.FastSeq as Seq)
%%[(50 codegen) import(qualified Data.Map as Map, qualified Data.Set as Set)
%%]
%%[(50 codegen) import(UHC.Util.Lens, qualified UHC.Util.FastSeq as Seq)
%%]
%%[(50 codegen) import(Control.Monad.State)
%%]
Expand Down Expand Up @@ -67,7 +69,7 @@ cpGenModuleImportExportImpl modNm
]
, mieimplHsName2FldMp = expNmFldMp
%%[[(50 grin)
, mieimplLamMp = Core2GrSem.lamMp_Inh_CodeAGItf $ _crsiCoreInh crsi
, mieimplLamMp = crsi ^. crsiCEnv ^. cenvLamMp -- Core2GrSem.lamMp_Inh_CodeAGItf $ _crsiCoreInh crsi
%%]]
}
}
Expand Down
59 changes: 35 additions & 24 deletions EHC/src/ehc/EHC/CompilePhase/FlowBetweenPhase.chs
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,15 @@ cpFlowEHSem1 modNm
= mentrelToFilterMp' False [modNm] (mmiExps mmi)
%%]]
usedImpS = mentrelFilterMpModuleNames mentrelFilterMp
cenv' = ( cenvDataGam ^$= (dg `gamUnionFlow`) )
%%[[(8 core)
. ( cenvLamMp ^$= (lm `lamMpUnionBindAspMp`) ) -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
$ cenv
ehInh' = ehInh
%%[[(50 hmtyinfer)
{ EHSem.dataGam_Inh_AGItf = dg `gamUnionFlow` EHSem.dataGam_Inh_AGItf ehInh
{ -- EHSem.dataGam_Inh_AGItf = dg `gamUnionFlow` EHSem.dataGam_Inh_AGItf ehInh
EHSem.dataGam_Inh_AGItf = cenv' ^. cenvDataGam
, EHSem.valGam_Inh_AGItf = vg `gamUnionFlow` EHSem.valGam_Inh_AGItf ehInh
, EHSem.tyGam_Inh_AGItf = tg `gamUnionFlow` EHSem.tyGam_Inh_AGItf ehInh
, EHSem.tyKiGam_Inh_AGItf = tkg `gamUnionFlow` EHSem.tyKiGam_Inh_AGItf ehInh
Expand Down Expand Up @@ -210,19 +216,14 @@ cpFlowEHSem1 modNm
%%]]
}
%%]]
cenv' = ( cenvDataGam ^$= (dg `gamUnionFlow`) )
%%[[(8 core)
. ( cenvLamMp ^$= (lm `lamMpUnionBindAspMp`) ) -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
$ cenv
%%[[(8 core grin)
coreInh' = coreInh
%%[[8
{ Core2GrSem.dataGam_Inh_CodeAGItf = EHSem.gathDataGam_Syn_AGItf ehSem
, Core2GrSem.lamMp_Inh_CodeAGItf = EHSem.gathLamMp_Syn_AGItf ehSem
{ Core2GrSem.dataGam_Inh_CodeAGItf = cenv' ^. cenvDataGam -- EHSem.gathDataGam_Syn_AGItf ehSem
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp -- EHSem.gathLamMp_Syn_AGItf ehSem
%%][50
{ Core2GrSem.dataGam_Inh_CodeAGItf = EHSem.dataGam_Inh_AGItf ehInh'
, Core2GrSem.lamMp_Inh_CodeAGItf = lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: no duplicates, otherwise merging as done later has to be done
{ Core2GrSem.dataGam_Inh_CodeAGItf = cenv' ^. cenvDataGam -- EHSem.dataGam_Inh_AGItf ehInh'
, Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp -- lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: no duplicates, otherwise merging as done later has to be done
%%]]
}
%%]]
Expand Down Expand Up @@ -266,14 +267,20 @@ cpFlowHISem modNm
hiInfo = panicJust "cpFlowHISem.hiInfo" $ _ecuMbPrevHIInfo ecu
ehInh = crsi ^. crsiEHInh
cenv = crsi ^. crsiCEnv
cenv' = ( cenvDataGam ^$= (HI.hiiDataGam hiInfo `gamUnionFlow`) )
%%[[(50 core)
. ( cenvLamMp ^$= (HI.hiiLamMp hiInfo `lamMpUnionBindAspMp`) )
%%]]
$ cenv
%%[[50
ehInh' = ehInh
%%[[(50 hmtyinfer)
{ EHSem.valGam_Inh_AGItf = (HI.hiiValGam hiInfo) `gamUnionFlow` EHSem.valGam_Inh_AGItf ehInh
, EHSem.tyGam_Inh_AGItf = (HI.hiiTyGam hiInfo) `gamUnionFlow` EHSem.tyGam_Inh_AGItf ehInh
, EHSem.tyKiGam_Inh_AGItf = (HI.hiiTyKiGam hiInfo) `gamUnionFlow` EHSem.tyKiGam_Inh_AGItf ehInh
, EHSem.polGam_Inh_AGItf = (HI.hiiPolGam hiInfo) `gamUnionFlow` EHSem.polGam_Inh_AGItf ehInh
, EHSem.dataGam_Inh_AGItf = (HI.hiiDataGam hiInfo) `gamUnionFlow` EHSem.dataGam_Inh_AGItf ehInh
-- , EHSem.dataGam_Inh_AGItf = (HI.hiiDataGam hiInfo) `gamUnionFlow` EHSem.dataGam_Inh_AGItf ehInh
, EHSem.dataGam_Inh_AGItf = cenv' ^. cenvDataGam
, EHSem.clGam_Inh_AGItf = (HI.hiiClGam hiInfo) `gamUnionFlow` EHSem.clGam_Inh_AGItf ehInh
, EHSem.clDfGam_Inh_AGItf = (HI.hiiClDfGam hiInfo) `gamUnionFlow` EHSem.clDfGam_Inh_AGItf ehInh
, EHSem.chrStore_Inh_AGItf = (HI.hiiCHRStore hiInfo) `chrStoreUnion` EHSem.chrStore_Inh_AGItf ehInh
Expand All @@ -285,15 +292,11 @@ cpFlowHISem modNm
{ HSSem.fixityGam_Inh_AGItf = (HI.hiiFixityGam hiInfo) `gamUnionFlow` HSSem.fixityGam_Inh_AGItf hsInh
, HSSem.idGam_Inh_AGItf = (HI.hiiIdDefOccGam hiInfo) `gamUnionFlow` HSSem.idGam_Inh_AGItf hsInh
}
cenv' = ( cenvDataGam ^$= (HI.hiiDataGam hiInfo `gamUnionFlow`) )
%%[[(8 core)
. ( cenvLamMp ^$= (HI.hiiLamMp hiInfo `lamMpUnionBindAspMp`) )
%%]]
$ cenv
%%[[(50 core grin)
coreInh = crsi ^. crsiCoreInh
coreInh' = coreInh
{ Core2GrSem.lamMp_Inh_CodeAGItf = (HI.hiiLamMp hiInfo) `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh
{ -- Core2GrSem.lamMp_Inh_CodeAGItf = (HI.hiiLamMp hiInfo) `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh
Core2GrSem.lamMp_Inh_CodeAGItf = cenv' ^. cenvLamMp
}
%%]]
optim = crsiOptim crsi
Expand Down Expand Up @@ -328,13 +331,15 @@ cpFlowCoreModSem modNm
-- 20151008 AD: TBD: dataGam should be passed independently of Core etc.
; when (isJust mbCoreModSem) $ do
{ let coreModSem = fromJust mbCoreModSem
cenv = cenvDataGam ^$= (`gamUnionFlow` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreModSem) $ crsi ^. crsiCEnv
%%[[(50 grin)
coreInh' = coreInh
{ Core2GrSem.dataGam_Inh_CodeAGItf = Core2GrSem.dataGam_Inh_CodeAGItf coreInh `gamUnionFlow` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreModSem
coreInh' = coreInh
{ -- Core2GrSem.dataGam_Inh_CodeAGItf = Core2GrSem.dataGam_Inh_CodeAGItf coreInh `gamUnionFlow` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreModSem
Core2GrSem.dataGam_Inh_CodeAGItf = cenv ^. cenvDataGam
}
%%]]
; cpUpdSI $
( (crsiCEnv ^* cenvDataGam) ^$= (`gamUnionFlow` Core2ChkSem.gathDataGam_Syn_CodeAGItf coreModSem) )
( crsiCEnv ^= cenv )
%%[[(50 grin)
. ( crsiCoreInh ^= coreInh' )
%%]]
Expand All @@ -351,19 +356,21 @@ cpFlowCoreSemAfterFold modNm
; let (ecu,crsi,opts,_) = crBaseInfo modNm cr
coreSem = panicJust "cpFlowCoreSemAfterFold.coreSem" $ _ecuMbCoreSem ecu
lm = prepFlow $! Core2GrSem.gathLamMp_Syn_CodeAGItf coreSem
cenv = cenvLamMp ^$= (lm `lamMpUnionBindAspMp`) $ crsi ^. crsiCEnv -- assumption: old info can be overridden, otherwise merge should be done here
%%[[50
coreInh = crsi ^. crsiCoreInh
hii = ecu ^. ecuHIInfo
coreInh' = coreInh
{ Core2GrSem.lamMp_Inh_CodeAGItf = lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: old info can be overridden, otherwise merge should be done here
{ -- Core2GrSem.lamMp_Inh_CodeAGItf = lm `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh -- assumption: old info can be overridden, otherwise merge should be done here
Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp
}
hii' = hii
{ HI.hiiLamMp = lm
}
%%]]
; when (isJust (_ecuMbCoreSem ecu))
(do { cpUpdSI $
( (crsiCEnv ^* cenvLamMp) ^$= (lm `lamMpUnionBindAspMp`) ) -- assumption: old info can be overridden, otherwise merge should be done here
( crsiCEnv ^= cenv )
%%[[50
. ( crsiCoreInh ^= coreInh')
; cpUpdCU modNm ( ecuStoreHIInfo hii'
Expand Down Expand Up @@ -413,13 +420,17 @@ cpFlowHILamMp modNm
%%[[(50 grin)
coreInh = crsi ^. crsiCoreInh
%%]]
cenv = cenvLamMp ^$= (HI.hiiLamMp hii `lamMpUnionBindAspMp`) $ crsi ^. crsiCEnv -- assumption: old info can be overridden, otherwise merge should be done here
hii = ecu ^. ecuHIInfo

-- put back result: call info map (lambda arity, ...), overwriting previous entries
; cpUpdSI $
( (crsiCEnv ^* cenvLamMp) ^$= (HI.hiiLamMp hii `lamMpUnionBindAspMp`) )
( crsiCEnv ^= cenv )
%%[[(50 grin)
. ( crsiCoreInh ^= coreInh {Core2GrSem.lamMp_Inh_CodeAGItf = HI.hiiLamMp hii `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh} )
. ( crsiCoreInh ^= coreInh
-- { Core2GrSem.lamMp_Inh_CodeAGItf = HI.hiiLamMp hii `lamMpUnionBindAspMp` Core2GrSem.lamMp_Inh_CodeAGItf coreInh }
{ Core2GrSem.lamMp_Inh_CodeAGItf = cenv ^. cenvLamMp }
)
%%]]
}
%%]
Expand Down
Loading

0 comments on commit a1a85e5

Please sign in to comment.