forked from GitHub/gf-core
subex elim in gfr generation
This commit is contained in:
@@ -40,6 +40,7 @@ import GF.Compile.Optimize
|
|||||||
import GF.Compile.Evaluate
|
import GF.Compile.Evaluate
|
||||||
import GF.Compile.GrammarToCanon
|
import GF.Compile.GrammarToCanon
|
||||||
--import GF.Devel.GrammarToGFCC -----
|
--import GF.Devel.GrammarToGFCC -----
|
||||||
|
import GF.Devel.OptimizeGF (subexpModule,unsubexpModule)
|
||||||
import GF.Canon.Share
|
import GF.Canon.Share
|
||||||
import GF.Canon.Subexpressions (elimSubtermsMod,unSubelimModule)
|
import GF.Canon.Subexpressions (elimSubtermsMod,unSubelimModule)
|
||||||
import GF.UseGrammar.Linear (unoptimizeCanonMod) ----
|
import GF.UseGrammar.Linear (unoptimizeCanonMod) ----
|
||||||
@@ -202,7 +203,8 @@ compileOne opts env@((_,srcgr,cancgr0,eenv),_) file = do
|
|||||||
-- for compiled resource, parse and organize, then update environment
|
-- for compiled resource, parse and organize, then update environment
|
||||||
"gfr" -> do
|
"gfr" -> do
|
||||||
sm0 <- putp ("| reading" +++ file) $ getSourceModule opts file
|
sm0 <- putp ("| reading" +++ file) $ getSourceModule opts file
|
||||||
sm <- {- putp "creating indirections" $ -} ioeErr $ extendModule mos sm0
|
let sm1 = unsubexpModule sm0
|
||||||
|
sm <- {- putp "creating indirections" $ -} ioeErr $ extendModule mos sm1
|
||||||
---- experiment with not optimizing gfr
|
---- experiment with not optimizing gfr
|
||||||
---- sm:_ <- putp " optimizing " $ ioeErr $ evalModule mos sm1
|
---- sm:_ <- putp " optimizing " $ ioeErr $ evalModule mos sm1
|
||||||
let gfc = gfcFile name
|
let gfc = gfcFile name
|
||||||
@@ -330,7 +332,8 @@ generateModuleCode opts path minfo@(name,info) = do
|
|||||||
--- Also for incomplete, to create timestamped gfc/gfr files
|
--- Also for incomplete, to create timestamped gfc/gfr files
|
||||||
case info of
|
case info of
|
||||||
ModMod m | emitsGFR m && emit && nomulti -> do
|
ModMod m | emitsGFR m && emit && nomulti -> do
|
||||||
let rminfo = if isCompilable info then minfo
|
let rminfo = if isCompilable info
|
||||||
|
then subexpModule minfo
|
||||||
else (name, ModMod emptyModule)
|
else (name, ModMod emptyModule)
|
||||||
let (file,out) = (gfrFile pname, prGrammar (MGrammar [rminfo]))
|
let (file,out) = (gfrFile pname, prGrammar (MGrammar [rminfo]))
|
||||||
putp (" wrote file" +++ file) $ ioeIO $ writeFile file $ compactPrint out
|
putp (" wrote file" +++ file) $ ioeIO $ writeFile file $ compactPrint out
|
||||||
|
|||||||
@@ -95,7 +95,12 @@ selectFormat opts env (p,f) = do
|
|||||||
(_,_,Just tgfc,_) | fromComp -> (CSRead,Just tgfc)
|
(_,_,Just tgfc,_) | fromComp -> (CSRead,Just tgfc)
|
||||||
-- (Just tenv,_,_,Just tgf) | laterModTime tenv tgf -> (CSEnvR,Just tenv)
|
-- (Just tenv,_,_,Just tgf) | laterModTime tenv tgf -> (CSEnvR,Just tenv)
|
||||||
-- (_,Just tenv,_,Just tgf) | laterModTime tenv tgf -> (CSEnv, Just tenv)
|
-- (_,Just tenv,_,Just tgf) | laterModTime tenv tgf -> (CSEnv, Just tenv)
|
||||||
(_,_,Just tgfc,Just tgf) | laterModTime tgfc tgf -> (CSRead,Just tgfc)
|
(_,_,Just tgfc,Just tgf) | laterModTime tgfc tgf ->
|
||||||
|
case mtenv of
|
||||||
|
-- Just tenv | laterModTime tenv tgfc -> (CSEnv,Just tenv)
|
||||||
|
_ -> (CSRead,Just tgfc)
|
||||||
|
|
||||||
|
|
||||||
-- (_,Just tenv,_,Nothing) -> (CSEnv,Just tenv) -- source does not exist
|
-- (_,Just tenv,_,Nothing) -> (CSEnv,Just tenv) -- source does not exist
|
||||||
(_,_,_, Nothing) -> (CSRead,Nothing) -- source does not exist
|
(_,_,_, Nothing) -> (CSRead,Nothing) -- source does not exist
|
||||||
_ -> (CSComp,Nothing)
|
_ -> (CSComp,Nothing)
|
||||||
|
|||||||
Reference in New Issue
Block a user