From 4b46c310ce14a1a2627fc2c44d5765e2bbd0aa88 Mon Sep 17 00:00:00 2001 From: aarne Date: Thu, 10 Feb 2005 09:43:33 +0000 Subject: [PATCH] gfc generation to incomplete modules --- src/GF/Compile/BackOpt.hs | 4 ++-- src/GF/Compile/Compile.hs | 11 +++++++---- src/GF/Compile/GrammarToCanon.hs | 5 +++-- src/GF/Infra/ReadFiles.hs | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/GF/Compile/BackOpt.hs b/src/GF/Compile/BackOpt.hs index 1c030f8e1..64068e93b 100644 --- a/src/GF/Compile/BackOpt.hs +++ b/src/GF/Compile/BackOpt.hs @@ -27,10 +27,10 @@ import qualified Modules as M type OptSpec = [Integer] --- -doOptFactor :: OptSpec +doOptFactor :: OptSpec -> Bool doOptFactor opt = elem 2 opt -doOptValues :: OptSpec +doOptValues :: OptSpec -> Bool doOptValues opt = elem 3 opt shareOpt :: OptSpec diff --git a/src/GF/Compile/Compile.hs b/src/GF/Compile/Compile.hs index c1d33ed8e..f555de440 100644 --- a/src/GF/Compile/Compile.hs +++ b/src/GF/Compile/Compile.hs @@ -282,22 +282,25 @@ generateModuleCode opts path minfo@(name,info) = do "none" -> minfo0 -- no optimization _ -> shareModule shareOpt minfo0 -- sharing; default - -- for resource, also emit gfr + -- for resource, also emit gfr. + --- Also for incomplete, to create timestamped gfc/gfr files case info of ModMod m | emitsGFR m && emit && nomulti -> do - let (file,out) = (gfrFile pname, prGrammar (MGrammar [minfo])) + let rminfo = if isCompilable info then minfo + else (name,emptyModInfo) + let (file,out) = (gfrFile pname, prGrammar (MGrammar [rminfo])) ioeIO $ writeFile file out >> putStr (" wrote file" +++ file) _ -> return () (file,out) <- do code <- return $ MkGFC.prCanonModInfo minfo' return (gfcFile pname, code) - if isCompilable info && emit && nomulti + if emit && nomulti ---- && isCompilable info then ioeIO (writeFile file out) >> ioeIOIf (putStr (" wrote file" +++ file)) else ioeIOIf $ putStrFlush $ "no need to save module" +++ prt name return minfo' where ioeIOIf = if oElem beSilent opts then (const (return ())) else ioeIO - emitsGFR m = isModRes m && isCompilable info + emitsGFR m = isModRes m ---- && isCompilable info ---- isModRes m || (isModCnc m && mstatus m == MSIncomplete) isCompilable mi = case mi of ModMod m -> not $ isModCnc m && mstatus m == MSIncomplete diff --git a/src/GF/Compile/GrammarToCanon.hs b/src/GF/Compile/GrammarToCanon.hs index 08542ec16..2b3e31250 100644 --- a/src/GF/Compile/GrammarToCanon.hs +++ b/src/GF/Compile/GrammarToCanon.hs @@ -52,7 +52,7 @@ redModInfo (c,info) = do let isIncompl = not $ isCompleteModule m (e,os) <- if isIncompl then return ([],[]) else redExtOpen m ---- flags <- mapM redFlag $ flags m - (a,mt) <- case mtype m of + (a,mt0) <- case mtype m of MTConcrete a -> do a' <- redIdent a return (a', MTConcrete a') @@ -62,8 +62,9 @@ redModInfo (c,info) = do MTInstance _ -> return (c',MTResource) --- c' not needed MTTransfer x y -> return (c',MTTransfer (om x) (om y)) --- c' not needed - ---- this generates empty GFC. Better: none + --- this generates empty GFC reosurce for interface and incomplete let js = if isIncompl then NT else jments m + mt = mt0 ---- if isIncompl then MTResource else mt0 defss <- mapM (redInfo a) $ tree2list $ js defs <- return $ sorted2tree $ concat defss -- sorted, but reduced diff --git a/src/GF/Infra/ReadFiles.hs b/src/GF/Infra/ReadFiles.hs index 65b52e602..380c0cfb5 100644 --- a/src/GF/Infra/ReadFiles.hs +++ b/src/GF/Infra/ReadFiles.hs @@ -9,7 +9,7 @@ -- > CVS $Author $ -- > CVS $Revision $ -- --- (Description of the module) +-- Decide what files to read as function of dependencies and time stamps. ----------------------------------------------------------------------------- module ReadFiles