diff --git a/gf.cabal b/gf.cabal index 3a5f2822e..11830ddf0 100644 --- a/gf.cabal +++ b/gf.cabal @@ -67,29 +67,15 @@ flag network-uri description: Get Network.URI from the network-uri package default: True ---flag new-comp --- Description: Make -new-comp the default --- Default: True - -flag c-runtime - Description: Include functionality from the C run-time library (which must be installed already) - Default: False - - executable gf - hs-source-dirs: src/programs, src/runtime/haskell/binary + hs-source-dirs: src/programs main-is: gf-main.hs default-language: Haskell2010 - build-depends: base, filepath, directory, time, time-compat, old-locale, pretty, mtl, array, random, + build-depends: pgf2, base, filepath, directory, time, time-compat, old-locale, pretty, mtl, array, random, process, haskeline, parallel>=3, exceptions, bytestring, utf8-string, containers ghc-options: -threaded - if flag(c-runtime) - build-depends: pgf2 - else - build-depends: pgf - if impl(ghc>=7.0) ghc-options: -rtsopts -with-rtsopts=-I5 if impl(ghc<7.8) @@ -223,9 +209,6 @@ executable gf Data.Binary.Builder Data.Binary.IEEE754 - if flag(c-runtime) - cpp-options: -DC_RUNTIME - if flag(server) build-depends: httpd-shed>=0.4.0.3, network>=2.3 && <2.7, json, cgi>=3001.2.2.0 diff --git a/src/compiler/GF/Compile/GenerateBC.hs b/src/compiler/GF/Compile/GenerateBC.hs index d6d6f255c..d89792677 100644 --- a/src/compiler/GF/Compile/GenerateBC.hs +++ b/src/compiler/GF/Compile/GenerateBC.hs @@ -9,7 +9,6 @@ import qualified Data.Map as Map import Data.List(nub,mapAccumL) import Data.Maybe(fromMaybe) -#if C_RUNTIME generateByteCode :: SourceGrammar -> Int -> [L Equation] -> [[Instr]] generateByteCode gr arity eqs = let (bs,instrs) = compileEquations gr arity (arity+1) is @@ -302,7 +301,3 @@ freeVars xs e = collectOp (freeVars xs) e push_is :: Int -> Int -> [IVal] -> [IVal] push_is i 0 is = is push_is i n is = ARG_VAR i : push_is (i-1) (n-1) is - -#else -generateByteCode = error "generateByteCode is not implemented" -#endif diff --git a/src/compiler/GF/Infra/BuildInfo.hs b/src/compiler/GF/Infra/BuildInfo.hs index f0230246b..cba9bc0d0 100644 --- a/src/compiler/GF/Infra/BuildInfo.hs +++ b/src/compiler/GF/Infra/BuildInfo.hs @@ -14,9 +14,3 @@ buildInfo = #ifdef SERVER_MODE ++" server" #endif -#ifdef NEW_COMP - ++" new-comp" -#endif -#ifdef C_RUNTIME - ++" c-runtime" -#endif diff --git a/src/compiler/GF/Infra/SIO.hs b/src/compiler/GF/Infra/SIO.hs index 75c57601b..453b94348 100644 --- a/src/compiler/GF/Infra/SIO.hs +++ b/src/compiler/GF/Infra/SIO.hs @@ -12,9 +12,6 @@ module GF.Infra.SIO( newStdGen,print,putStr,putStrLn, -- ** Specific to GF importGrammar,importSource, -#ifdef C_RUNTIME - readPGF2, -#endif putStrLnFlush,runInterruptibly,lazySIO, -- * Restricted accesss to arbitrary (potentially unsafe) IO operations -- | If the environment variable GF_RESTRICTED is defined, these @@ -39,9 +36,6 @@ import qualified System.Random as IO(newStdGen) import qualified GF.Infra.UseIO as IO(getLibraryDirectory) import qualified GF.System.Signal as IO(runInterruptibly) import qualified GF.Command.Importing as GF(importGrammar, importSource) -#ifdef C_RUNTIME -import qualified PGF2 -#endif -- * The SIO monad @@ -123,7 +117,3 @@ lazySIO = lift1 lazyIO importGrammar pgf opts files = lift0 $ GF.importGrammar pgf opts files importSource opts files = lift0 $ GF.importSource opts files - -#ifdef C_RUNTIME -readPGF2 = lift0 . PGF2.readPGF -#endif diff --git a/src/compiler/GF/Server.hs b/src/compiler/GF/Server.hs index de0ec6abc..477f41e7c 100644 --- a/src/compiler/GF/Server.hs +++ b/src/compiler/GF/Server.hs @@ -179,7 +179,7 @@ handle logLn documentroot state0 cache execute1 stateVar translatePath rpath = root>rpath -- hmm, check for ".." - versionInfo (c1,c2) = + versionInfo c = html200 . unlines $ "": "": @@ -187,8 +187,7 @@ handle logLn documentroot state0 cache execute1 stateVar "": ("
":repeat "
") buildinfo)++
- sh "Haskell run-time system" c1++
- sh "C run-time system" c2
+ sh "Run-time system" c
where
hdr:buildinfo = lines gf_version
rel = makeRelative documentroot
diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs
index 1774a8cff..23ecba22c 100644
--- a/src/server/PGFService.hs
+++ b/src/server/PGFService.hs
@@ -4,6 +4,7 @@ module PGFService(cgiMain,cgiMain',getPath,
Caches,pgfCache,newPGFCache,flushPGFCache,listPGFCache) where
import PGF (PGF,Labels,CncLabels)
+import PGF2
import GF.Text.Lexing
import qualified PGF
import Cache
@@ -15,11 +16,6 @@ import CGI(CGI,readInput,getInput,getVarWithDefault,
Accept(..),Language(..),negotiate,liftIO)
import URLEncoding
-#if C_RUNTIME
-import qualified PGF2 as C
---import Data.Time.Clock(getCurrentTime,diffUTCTime)
-#endif
-
import Data.Time.Clock(UTCTime)
import Data.Time.Format(formatTime)
#if MIN_VERSION_time(1,5,0)
@@ -60,43 +56,18 @@ withQSem qsem = bracket_ (liftIO $ waitQSem qsem) (liftIO $ signalQSem qsem)
logFile :: FilePath
logFile = "pgf-error.log"
-#ifdef C_RUNTIME
-data Caches = Caches { pgfCache::Cache PGF,
- labelsCache::Cache Labels,
- cncLabelsCache::Cache CncLabels,
- cpgfCache::(Cache (C.PGF,({-MVar ParseCache-})),QSem) }
---type Caches = (Cache PGF,Cache (C.PGF,({-MVar ParseCache-})))
---type ParseCache = Map.Map (String,String) (ParseResult,UTCTime)
---type ParseResult = Either String [(C.Expr,Float)]
+data Caches = Caches { qsem :: QSem,
+ pgfCache :: Cache PGF,
+ labelsCache :: Cache Labels }
-newPGFCache jobs = do pgfCache <- newCache' PGF.readPGF
- lblCache <- newCache' (fmap PGF.getDepLabels . readFile)
- clblCache <- newCache'(fmap PGF.getCncDepLabels .readFile)
- let n = maybe 4 id jobs
+newPGFCache jobs = do let n = maybe 4 id jobs
qsem <- newQSem n
- cCache <- newCache' $ \ path -> do pgf <- C.readPGF path
- --pc <- newMVar Map.empty
- return (pgf,({-pc-}))
- return $ Caches pgfCache lblCache clblCache (cCache,qsem)
+ pgfCache <- newCache' PGF.readPGF
+ lblCache <- newCache' (fmap PGF.getDepLabels . readFile)
+ return $ Caches qsem pgfCache lblCache
flushPGFCache c = do flushCache (pgfCache c)
flushCache (labelsCache c)
- flushCache (fst (cpgfCache c))
-listPGFCache c = (,) # listCache (pgfCache c) % listCache (fst (cpgfCache c))
-#else
-data Caches = Caches { pgfCache::Cache PGF,
- labelsCache::Cache Labels,
- cncLabelsCache::Cache CncLabels }
-newPGFCache _ = do pgfCache <- newCache' PGF.readPGF
- lblCache <- newCache' (fmap PGF.getDepLabels . readFile)
- clblCache <- newCache'(fmap PGF.getCncDepLabels .readFile)
- return $ Caches pgfCache lblCache clblCache
-flushPGFCache c = flushCache (pgfCache c)
-
-listPGFCache :: Caches -> IO ([(FilePath,UTCTime)],[(FilePath,UTCTime)])
-listPGFCache c = (,) # listCache (pgfCache c) % return []
-#endif
-
-labelsCaches c = (labelsCache c,cncLabelsCache c)
+listPGFCache c = listCache (pgfCache c)
newCache' rd = do c <- newCache rd
forkIO $ forever $ clean c
@@ -121,20 +92,8 @@ cgiMain' cache path =
(getInput "command")
case command of
"download" -> outputBinary =<< getFile BS.readFile path
- 'c':'-':_ -> optionalCpgfMain cache path command
_ -> do tpgf <- getFile (readCache' (pgfCache cache)) path
- pgfMain (labelsCaches cache) path command tpgf
-
-optionalCpgfMain cache path command =
-#ifdef C_RUNTIME
- cpgfMain (snd (cpgfCache cache)) command
- =<< getFile (readCache' (fst (cpgfCache cache))) path
-#else
- serverError "Server configured without C run-time support" ""
-
-serverError = throw 500
-
-#endif
+ pgfMain (qsem cache) command tpgf
getFile get path =
either failed return =<< liftIO (E.try (get path))
@@ -143,38 +102,34 @@ getFile get path =
then notFound path
else liftIO $ ioError e
---------------------------------------------------------------------------------
--- * C run-time functionality
-#ifdef C_RUNTIME
---cpgfMain :: String -> (C.PGF,MVar ParseCache) -> CGI CGIResult
-cpgfMain qsem command (t,(pgf,pc)) =
+pgfMain qsem command (t,pgf) =
case command of
- "c-parse" -> withQSem qsem $
+ "parse" -> withQSem qsem $
out t=<< join (parse # input % start % limit % treeopts)
- "c-linearize" -> out t=<< lin # tree % to
- "c-linearizeAll"-> out t=<< linAll # tree % to
- "c-translate" -> withQSem qsem $
+ "linearize" -> out t=<< lin # tree % to
+ "linearizeAll"-> out t=<< linAll # tree % to
+ "translate" -> withQSem qsem $
out t=<"++(unwords pns)++"
"
where pns = ["