summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar/Binary.hs
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2011-11-02 11:44:59 +0000
committerkr.angelov <kr.angelov@gmail.com>2011-11-02 11:44:59 +0000
commit5fe49ed9f7ac7089301e867e55bfedefcba230dd (patch)
tree3d49a4fbd3e3af5350b4e276d65ec3c17f0907c3 /src/compiler/GF/Grammar/Binary.hs
parent42af63414fae6cec2ea6d648464f9475501b2b28 (diff)
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.
Diffstat (limited to 'src/compiler/GF/Grammar/Binary.hs')
-rw-r--r--src/compiler/GF/Grammar/Binary.hs20
1 files changed, 15 insertions, 5 deletions
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"