if a module is compiled with -no-pmcfg the PMCFG is generated on demand

This commit is contained in:
krangelov
2021-12-13 11:17:10 +01:00
parent 88ac47621a
commit 9efb6b002f
2 changed files with 18 additions and 9 deletions

View File

@@ -10,7 +10,7 @@
-----------------------------------------------------------------------------
module GF.Compile.GeneratePMCFG
(generatePMCFG, type2fields, addPMCFG
(generatePMCFG, type2fields
) where
import GF.Grammar hiding (VApp,VRecType)
@@ -28,10 +28,11 @@ import Data.List(mapAccumL,sortBy)
import Data.Maybe(fromMaybe)
generatePMCFG :: Options -> FilePath -> SourceGrammar -> SourceModule -> Check SourceModule
generatePMCFG opts cwd gr cmo@(cm,cmi) = do
let gr' = prependModule gr cmo
js <- mapM (addPMCFG opts cwd gr' cmi) (Map.toList (jments cmi))
return (cm,cmi{jments = (Map.fromAscList js)})
generatePMCFG opts cwd gr cmo@(cm,cmi)
| isModCnc cmi = do let gr' = prependModule gr cmo
js <- mapM (addPMCFG opts cwd gr' cmi) (Map.toList (jments cmi))
return (cm,cmi{jments = (Map.fromAscList js)})
| otherwise = return cmo
addPMCFG opts cwd gr cmi (id,CncCat mty@(Just (L loc ty)) mdef mref mprn Nothing) = do
defs <- case mdef of