Changeset 7866 for src/Pugs/CodeGen

Show
Ignore:
Timestamp:
11/06/05 01:28:07 (3 years ago)
Author:
autrijus
Message:

* New compiler backend targets around PIL2:

./pugs -C PIL2-Perl5
./pugs -C PIL2-JSON
./pugs -C PIL2-Binary

The dash is optional (all nonalphanum is dropped), and
it's case insensitive. Eventually these will replace
the PIL1 variants when our p5/js codegens finishes the
migration.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/CodeGen/PIL2.hs

    r7849 r7866  
    22{-# OPTIONS_GHC -#include "../../UnicodeC.h" #-} 
    33 
    4 module Pugs.CodeGen.PIL2 (genPIL2) where 
     4module Pugs.CodeGen.PIL2 ( 
     5    genPIL2, 
     6    genPIL2Perl5, genPIL2Binary, genPIL2JSON 
     7) where 
    58import Pugs.Internals 
    69import Pugs.AST 
    7 import Pugs.PIL1 
    8 import Pugs.Compile 
     10import Pugs.PIL2 
     11import Pugs.Compile.PIL2 
     12import System.IO 
     13import System.Directory 
     14import DrIFT.Perl5 
     15import DrIFT.Binary 
     16import DrIFT.JSON 
    917 
    1018genPIL2 :: Eval Val 
     
    1725        , "    }" 
    1826        ] 
     27 
     28genPIL2Perl5 :: Eval Val 
     29genPIL2Perl5 = do 
     30    penv <- compile () :: Eval PIL_Environment 
     31    return . VStr . unlines $ [showPerl5 penv] 
     32 
     33genPIL2Binary :: Eval Val 
     34genPIL2Binary = do 
     35    penv <- compile () :: Eval PIL_Environment 
     36    liftIO $ do 
     37        tmp         <- getTemporaryDirectory 
     38        (file, fh)  <- openBinaryTempFile tmp "pugs.bin" 
     39        bh          <- openBinIO fh 
     40        put_ bh penv 
     41        hClose fh 
     42        return $ VStr (unlines [file]) 
     43 
     44genPIL2JSON :: Eval Val 
     45genPIL2JSON = do 
     46    penv <- compile () :: Eval PIL_Environment 
     47    return . VStr . unlines $ [showJSON penv]