Changeset 4871 for src/Pugs/Compile
- Timestamp:
- 06/20/05 16:11:39 (3 years ago)
- svk:copy_cache_prev:
- 6641
- Location:
- src/Pugs/Compile
- Files:
-
- 1 removed
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Compile/PIR.hs
r4869 r4871 1 1 {-# OPTIONS_GHC -fglasgow-exts -fno-warn-orphans -funbox-strict-fields -fallow-undecidable-instances -cpp #-} 2 2 3 module Pugs.Compile.PIR (genPIR') where 4 import Pugs.Compile.Parrot 3 module Pugs.Compile.PIR (genPIR) where 5 4 import Pugs.Internals 6 5 import Pugs.AST … … 20 19 PNoop :: PIL Stmt 21 20 22 PRaw :: !Exp -> PIL Stmt -- XXX HACK!23 21 PRawName :: !VarName -> PIL Expression -- XXX HACK! 24 22 … … 79 77 show (PThunk x) = "(PThunk " ++ show x ++ ")" 80 78 show (PBlock x) = "(PBlock " ++ show x ++ ")" 81 show (PRaw x) = "(PRaw " ++ show x ++ ")"82 79 show (PRawName x) = "(PRawName " ++ show x ++ ")" 83 80 show (PSub x y z) = "(PSub " ++ show x ++ " " ++ show y ++ " " ++ show z ++ ")" … … 175 172 compile (Stmts (Pad SMy pad exp) rest) = do 176 173 expC <- compile $ mergeStmts exp rest 177 padC <- mapM compile (padToList pad)174 padC <- compile $ padToList pad 178 175 return $ PPad ((map fst (padToList pad)) `zip` padC) expC 179 176 compile exp = compileStmts exp … … 494 491 tellLabel endC 495 492 return (ExpLV this) 496 trans (PRaw exp) = do497 env <- asks tEnv498 raw <- liftIO $ runEvalIO env{ envStash = "$P0" } $ do499 doc <- compile' exp500 return $ VStr (render doc)501 return $ StmtRaw (text $ vCast raw)502 493 trans (PRawName name) = do 503 494 -- generate fresh supply and things... … … 597 588 return $ reg (VAR var) 598 589 590 padSort :: (Var, [(TVar Bool, TVar VRef)]) -> (String, [(a, b)]) -> Ordering 591 padSort ((a::[Char]), [(_, _)]) ((b::[Char]), [(_, _)]) 592 | (head a == ':' && head b == '&') = LT 593 | (head b == ':' && head a == '&') = GT 594 | otherwise = GT 595 padSort _ _ = EQ 596 599 597 varText :: String -> Doc 600 598 varText ('$':name) = text $ "s__" ++ escaped name … … 611 609 612 610 {-| Compiles the current environment to PIR code. -} 613 genPIR ':: Eval Val614 genPIR '= do611 genPIR :: Eval Val 612 genPIR = do 615 613 tenv <- initTEnv 616 614 -- Load the PIR Prelude. 617 local (\env -> env{ envDebug = Nothing}) $ do615 local (\env -> env{ envDebug = Nothing }) $ do 618 616 opEval style "<prelude-pir>" preludeStr 619 617 glob <- askGlobal 620 618 main <- asks envBody 621 globPIL <- compile glob622 mainPIL <- compile main619 globPIL <- compile glob 620 mainPIL <- compile main 623 621 globPIR <- runTransGlob tenv globPIL :: Eval [Decl] 624 622 mainPIR <- runTransMain tenv mainPIL :: Eval [Stmt]
