From 584d589041f63fdd3ea777019679275657902c2d Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Mon, 11 Aug 2014 10:59:10 +0000 Subject: a partial support for def rules in the C runtime The def rules are now compiled to byte code by the compiler and then to native code by the JIT compiler in the runtime. Not all constructions are implemented yet. The partial implementation is now in the repository but it is not activated by default since this requires changes in the PGF format. I will enable it only after it is complete. --- src/compiler/GFC.hs | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'src/compiler/GFC.hs') diff --git a/src/compiler/GFC.hs b/src/compiler/GFC.hs index 137a68895..4bd6ce25c 100644 --- a/src/compiler/GFC.hs +++ b/src/compiler/GFC.hs @@ -2,8 +2,8 @@ module GFC (mainGFC, writePGF) where -- module Main where import PGF -import PGF.Internal(PGF,abstract,concretes,code,funs,cats,optimizePGF,unionPGF) -import PGF.Internal(putSplitAbs) +import PGF.Internal(PGF,concretes,optimizePGF,unionPGF) +import PGF.Internal(putSplitAbs,encodeFile,runPut) import GF.Compile import GF.Compile.Export import GF.Compile.CFGtoPGF @@ -17,13 +17,10 @@ import GF.Data.ErrM import GF.System.Directory import Data.Maybe -import PGF.Internal(encode,encodeFile,runPut) import qualified Data.Map as Map import qualified Data.Set as Set -import qualified Data.ByteString as BSS import qualified Data.ByteString.Lazy as BSL import System.FilePath -import System.IO import Control.Monad(unless,forM_) mainGFC :: Options -> [FilePath] -> IO () @@ -55,7 +52,6 @@ compileSourceFiles opts fs = then putIfVerb opts $ pgfFile ++ " is up-to-date." else do pgf <- link opts cnc_gr writePGF opts pgf - writeByteCode opts pgf writeOutputs opts pgf compileCFFiles :: Options -> [FilePath] -> IOE () @@ -105,20 +101,6 @@ writeOutputs opts pgf = do | fmt <- outputFormats opts, (name,str) <- exportPGF opts fmt pgf] -writeByteCode :: Options -> PGF -> IOE () -writeByteCode opts pgf - | elem FmtByteCode (flag optOutputFormats opts) = - let path = outputPath opts (grammarName opts pgf <.> "bc") - in writing opts path $ - withBinaryFile path WriteMode - (\h -> do BSL.hPut h (encode addrs) - BSS.hPut h (code (abstract pgf))) - | otherwise = return () - where - addrs = - [(id,addr) | (id,(_,_,_,_,addr)) <- Map.toList (funs (abstract pgf))] ++ - [(id,addr) | (id,(_,_,_,addr)) <- Map.toList (cats (abstract pgf))] - writePGF :: Options -> PGF -> IOE () writePGF opts pgf = if flag optSplitPGF opts then writeSplitPGF else writeNormalPGF -- cgit v1.2.3