diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2011-11-15 19:12:22 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2011-11-15 19:12:22 +0000 |
| commit | a2626e24dd9e468ee0c5ccd455e4a5f782d56522 (patch) | |
| tree | c222b77a1b7ccba40b3bd244ae00f1945eb3a3c8 /src/compiler/GF/Compile/ReadFiles.hs | |
| parent | 8a10aa5cf969caf482a7e852562caad815d74672 (diff) | |
now we store version number in every .gfo file. If the file is compiled with different compiler then we simply recompile it.
Diffstat (limited to 'src/compiler/GF/Compile/ReadFiles.hs')
| -rw-r--r-- | src/compiler/GF/Compile/ReadFiles.hs | 17 |
1 files changed, 13 insertions, 4 deletions
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) |
