forked from GitHub/gf-core
A pgf doesn't always have a file location
This commit is contained in:
@@ -111,11 +111,13 @@ type CompileEnv = (Grammar,ModEnv)
|
|||||||
emptyCompileEnv :: Maybe PGF -> IOE CompileEnv
|
emptyCompileEnv :: Maybe PGF -> IOE CompileEnv
|
||||||
emptyCompileEnv mb_pgf = do
|
emptyCompileEnv mb_pgf = do
|
||||||
case mb_pgf of
|
case mb_pgf of
|
||||||
Just pgf -> do let fpath = pgfFilePath pgf
|
Just pgf -> do let abs_name = abstractName pgf
|
||||||
abs_name = abstractName pgf
|
env <- case pgfFilePath pgf of
|
||||||
t <- getModificationTime fpath
|
Just fpath -> do t <- getModificationTime fpath
|
||||||
|
return (Map.singleton abs_name (fpath,t,[]))
|
||||||
|
Nothing -> return Map.empty
|
||||||
return ( prependModule emptyGrammar (moduleNameS abs_name, ModPGF pgf)
|
return ( prependModule emptyGrammar (moduleNameS abs_name, ModPGF pgf)
|
||||||
, Map.singleton abs_name (fpath,t,[])
|
, env
|
||||||
)
|
)
|
||||||
Nothing -> return (emptyGrammar,Map.empty)
|
Nothing -> return (emptyGrammar,Map.empty)
|
||||||
|
|
||||||
|
|||||||
@@ -279,8 +279,12 @@ cookie_write cookie buf size = do
|
|||||||
fmap fromIntegral $ (callback :: Ptr Word8 -> Int -> IO Int) buf (fromIntegral size)
|
fmap fromIntegral $ (callback :: Ptr Word8 -> Int -> IO Int) buf (fromIntegral size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pgfFilePath :: PGF -> FilePath
|
pgfFilePath :: PGF -> Maybe FilePath
|
||||||
pgfFilePath p = unsafePerformIO (pgf_file_path (a_db p) >>= peekCString)
|
pgfFilePath p = unsafePerformIO $ do
|
||||||
|
c_fpath <- pgf_file_path (a_db p)
|
||||||
|
if c_fpath == nullPtr
|
||||||
|
then return Nothing
|
||||||
|
else fmap Just $ peekCString c_fpath
|
||||||
|
|
||||||
showPGF :: PGF -> String
|
showPGF :: PGF -> String
|
||||||
showPGF p =
|
showPGF p =
|
||||||
|
|||||||
Reference in New Issue
Block a user