Improved interface and instance compilation.

Improved interface and instance compilation.
Restored an optimization of the optimizer: up to 4x faster now.
This commit is contained in:
aarne
2003-11-13 16:02:25 +00:00
parent 25c8690586
commit c5146d0614
6 changed files with 20 additions and 8 deletions

View File

@@ -168,10 +168,11 @@ compileSourceModule opts env@(k,gr,can) mo@(i,mi) = do
mo1 <- ioeErr $ rebuildModule mos mo
mo1b <- ioeErr $ extendModule mos mo1
---- prDebug mo1b
---- prDebug mo1b
case mo1b of
(_,ModMod n) | not (isCompleteModule n) -> return (k,mo1b)
(_,ModMod n) | not (isCompleteModule n) -> do
return (k,mo1b) -- refresh would fail, since not renamed
_ -> do
mo2:_ <- putp " renaming " $ ioeErr $ renameModule mos mo1b

View File

@@ -29,8 +29,8 @@ evalModule :: [(Ident,SourceModInfo)] -> (Ident,SourceModInfo) ->
Err [(Ident,SourceModInfo)]
evalModule ms mo@(name,mod) = case mod of
ModMod (Module mt st fs me ops js) | st == MSComplete -> case mt of
MTResource -> do
ModMod m0@(Module mt st fs me ops js) | st == MSComplete -> case mt of
_ | isModRes m0 -> do
let deps = allOperDependencies name js
ids <- topoSortOpers deps
MGrammar (mod' : _) <- foldM evalOp gr ids

View File

@@ -32,7 +32,14 @@ rebuildModule ms mo@(i,mi) = do
testErr (isModRes m1) ("interface expected instead of" +++ prt i0)
m' <- do
js' <- extendMod False i0 (jments m1) (jments m)
return $ replaceJudgements m js'
--- to avoid double inclusions, in instance I of I0 = J0 ** ...
case extends m of
Nothing -> return $ replaceJudgements m js'
Just j0 -> do
m0 <- lookupModMod gr j0
let notInM0 c = not $ isInBinTree (fst c) $ mapTree fst $ jments m0
let js2 = sorted2tree $ filter notInM0 $ tree2list js'
return $ replaceJudgements m js2
return $ ModMod m'
_ -> return mi
@@ -40,7 +47,7 @@ rebuildModule ms mo@(i,mi) = do
ModWith mt stat ext ops -> do
let insts = [(inf,inst) | OQualif _ inf inst <- ops]
let infs = map fst insts
let stat' = ifNull MSComplete (const MSIncomplete)
let stat' = ifNull MSComplete (const MSIncomplete)
[i | i <- is, notElem i infs]
testErr (stat' == MSComplete || stat == MSIncomplete)
("module" +++ prt i +++ "remains incomplete")

View File

@@ -172,6 +172,10 @@ computeTerm gr = comp where
_ -> return $ ExtR r' s'
-- case-expand tables
T i@(TComp _) cs -> do
cs' <- mapPairsM (comp g) cs
return $ T i cs'
T i cs -> do
pty0 <- getTableType i
ptyp <- comp g pty0

View File

@@ -86,7 +86,7 @@ refreshGrammar = liftM (MGrammar . snd) . foldM refreshModule (0,[]) . modules
refreshModule :: (Int,[SourceModule]) -> SourceModule -> Err (Int,[SourceModule])
refreshModule (k,ms) mi@(i,m) = case m of
ModMod mo@(Module mt fs st me ops js) | (isModCnc mo || mt == MTResource) -> do
ModMod mo@(Module mt fs st me ops js) | (isModCnc mo || isModRes mo) -> do
(k',js') <- foldM refreshRes (k,[]) $ tree2list js
return (k', (i, ModMod(Module mt fs st me ops (buildTree js'))) : ms)
_ -> return (k, mi:ms)