From 5fe49ed9f7ac7089301e867e55bfedefcba230dd Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Wed, 2 Nov 2011 11:44:59 +0000 Subject: Now the compiler maintains more precise information for the source locations of the different definitions. There is a --tags option which generates a list of all identifiers with their source locations. --- src/compiler/GF/Grammar/Binary.hs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/compiler/GF/Grammar/Binary.hs') diff --git a/src/compiler/GF/Grammar/Binary.hs b/src/compiler/GF/Grammar/Binary.hs index 32ddfe6ad..7c79be361 100644 --- a/src/compiler/GF/Grammar/Binary.hs +++ b/src/compiler/GF/Grammar/Binary.hs @@ -31,9 +31,9 @@ instance Binary a => Binary (MGrammar a) where get = fmap mGrammar get instance Binary a => Binary (ModInfo a) where - put mi = do put (mtype mi,mstatus mi,flags mi,extend mi,mwith mi,opens mi,mexdeps mi,jments mi) - get = do (mtype,mstatus,flags,extend,mwith,opens,med,jments) <- get - return (ModInfo mtype mstatus flags extend mwith opens med jments) + put mi = do put (mtype mi,mstatus mi,flags mi,extend mi,mwith mi,opens mi,mexdeps mi,msrc mi,jments mi) + get = do (mtype,mstatus,flags,extend,mwith,opens,med,src,jments) <- get + return (ModInfo mtype mstatus flags extend mwith opens med src jments) instance Binary ModuleType where put MTAbstract = putWord8 0 @@ -109,6 +109,16 @@ instance Binary Info where 8 -> get >>= \(x,y) -> return (AnyInd x y) _ -> decodingError +instance Binary Location where + put NoLoc = putWord8 0 + put (Local x y) = putWord8 1 >> put (x,y) + put (External x y) = putWord8 2 >> put (x,y) + get = do tag <- getWord8 + case tag of + 0 -> return NoLoc + 1 -> get >>= \(x,y) -> return (Local x y) + 2 -> get >>= \(x,y) -> return (External x y) + instance Binary a => Binary (L a) where put (L x y) = put (x,y) get = get >>= \(x,y) -> return (L x y) @@ -261,7 +271,7 @@ instance Binary Label where decodeModHeader :: FilePath -> IO SourceModule decodeModHeader fpath = do - (m,mtype,mstatus,flags,extend,mwith,opens,med) <- decodeFile fpath - return (m,ModInfo mtype mstatus flags extend mwith opens med Map.empty) + (m,mtype,mstatus,flags,extend,mwith,opens,med,src) <- decodeFile fpath + return (m,ModInfo mtype mstatus flags extend mwith opens med src Map.empty) decodingError = fail "This GFO file was compiled with different version of GF" -- cgit v1.2.3