summaryrefslogtreecommitdiff
path: root/src/GF/Compile
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF/Compile')
-rw-r--r--src/GF/Compile/Compile.hs13
-rw-r--r--src/GF/Compile/ShellState.hs10
2 files changed, 16 insertions, 7 deletions
diff --git a/src/GF/Compile/Compile.hs b/src/GF/Compile/Compile.hs
index d5874d0e2..13710791d 100644
--- a/src/GF/Compile/Compile.hs
+++ b/src/GF/Compile/Compile.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/06/10 21:04:01 $
+-- > CVS $Date: 2005/09/18 22:55:46 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.41 $
+-- > CVS $Revision: 1.42 $
--
-- The top-level compilation chain from source file to gfc\/gfr.
-----------------------------------------------------------------------------
@@ -38,6 +38,7 @@ import GF.Compile.CheckGrammar
import GF.Compile.Optimize
import GF.Compile.GrammarToCanon
import GF.Canon.Share
+import GF.Canon.Subexpressions (elimSubtermsMod)
import qualified GF.Canon.CanonToGrammar as CG
@@ -283,7 +284,7 @@ generateModuleCode opts path minfo@(name,info) = do
minfo0 <- ioeErr $ redModInfo minfo
let oopts = addOptions opts (iOpts (flagsModule minfo))
optim = maybe "share" id $ getOptVal oopts useOptimizer
- minfo' <- return $
+ minfo1 <- return $
case optim of
"parametrize" -> shareModule paramOpt minfo0 -- parametrization and sharing
"values" -> shareModule valOpt minfo0 -- tables as courses-of-values
@@ -292,6 +293,12 @@ generateModuleCode opts path minfo@(name,info) = do
"none" -> minfo0 -- no optimization
_ -> shareModule shareOpt minfo0 -- sharing; default
+ -- do common subexpression elimination if required by flag "subs"
+ minfo' <-
+ if oElem elimSubs opts
+ then ioeErr $ elimSubtermsMod minfo1
+ else return minfo1
+
-- for resource, also emit gfr.
--- Also for incomplete, to create timestamped gfc/gfr files
case info of
diff --git a/src/GF/Compile/ShellState.hs b/src/GF/Compile/ShellState.hs
index a484b50e8..0d4c59652 100644
--- a/src/GF/Compile/ShellState.hs
+++ b/src/GF/Compile/ShellState.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/09/01 09:53:18 $
--- > CVS $Author: peb $
--- > CVS $Revision: 1.46 $
+-- > CVS $Date: 2005/09/18 22:55:46 $
+-- > CVS $Author: aarne $
+-- > CVS $Revision: 1.47 $
--
-- (Description of the module)
-----------------------------------------------------------------------------
@@ -21,6 +21,7 @@ import GF.Grammar.Macros
import GF.Grammar.MMacros
import GF.Canon.Look
+import GF.Canon.Subexpressions
import GF.Grammar.LookAbs
import GF.Compile.ModDeps
import qualified GF.Infra.Modules as M
@@ -185,7 +186,8 @@ updateShellState opts mcnc sh ((_,sgr,gr),rts) = do
let concrs = maybe [] (M.allConcretes cgr) abstr0
concr0 = ifNull Nothing (return . head) concrs
notInrts f = notElem f $ map fst rts
- cfs <- mapM (canon2cf opts cgr) concrs --- would not need to update all...
+ sub = if oElem elimSubs opts then unSubelimCanon else id
+ cfs <- mapM (canon2cf opts (sub cgr)) concrs --- why need to update all...
let pinfosOld = map (CnvOld.pInfo opts cgr) concrs -- peb 18/6 (OBSOLETE)