From a2626e24dd9e468ee0c5ccd455e4a5f782d56522 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Tue, 15 Nov 2011 19:12:22 +0000 Subject: now we store version number in every .gfo file. If the file is compiled with different compiler then we simply recompile it. --- src/compiler/GF/Compile/ReadFiles.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/compiler/GF/Compile/ReadFiles.hs') diff --git a/src/compiler/GF/Compile/ReadFiles.hs b/src/compiler/GF/Compile/ReadFiles.hs index 5c3ac660d..a64bb2a06 100644 --- a/src/compiler/GF/Compile/ReadFiles.hs +++ b/src/compiler/GF/Compile/ReadFiles.hs @@ -108,13 +108,22 @@ getAllFiles opts ps env file = do let mb_envmod = Map.lookup name env (st,t) = selectFormat opts (fmap fst mb_envmod) gfTime gfoTime - (mname,imps) <- case st of - CSEnv -> return (name, maybe [] snd mb_envmod) - CSRead -> ioeIO $ fmap importsOfModule (decodeModHeader ((if isGFO file then id else gf2gfo opts) file)) + (st,(mname,imps)) <- + case st of + CSEnv -> return (st, (name, maybe [] snd mb_envmod)) + CSRead -> do mb_mo <- ioeIO $ decodeModuleHeader ((if isGFO file then id else gf2gfo opts) file) + case mb_mo of + Just mo -> return (st,importsOfModule mo) + Nothing + | isGFO file -> ioeErr $ Bad (file ++ " is compiled with different GF version and I cannot find the source file") + | otherwise -> do s <- ioeIO $ BS.readFile file + case runP pModHeader s of + Left (Pn l c,msg) -> ioeBad (file ++ ":" ++ show l ++ ":" ++ show c ++ ": " ++ msg) + Right mo -> return (CSComp,importsOfModule mo) CSComp -> do s <- ioeIO $ BS.readFile file case runP pModHeader s of Left (Pn l c,msg) -> ioeBad (file ++ ":" ++ show l ++ ":" ++ show c ++ ": " ++ msg) - Right mo -> return (importsOfModule mo) + Right mo -> return (st,importsOfModule mo) ioeErr $ testErr (mname == name) ("module name" +++ mname +++ "differs from file name" +++ name) return (name,st,t,isJust gfTime,imps,dropFileName file) -- cgit v1.2.3