Changeset 4888
- Timestamp:
- 06/20/05 22:13:19 (4 years ago)
- svk:copy_cache_prev:
- 6641
- Location:
- src
- Files:
-
- 2 modified
-
Emit/PIR.hs (modified) (3 diffs)
-
Pugs/Compile/PIR.hs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Emit/PIR.hs
r4886 r4888 2 2 3 3 module Emit.PIR where 4 import Text.PrettyPrint5 4 import Data.Char 5 import Data.List 6 6 import Data.Typeable 7 7 import Emit.Common 8 import Text.PrettyPrint 8 9 9 10 {-| PIR code consists of declarations. -} … … 540 541 , "invoke" .- [fun] 541 542 ] 543 544 {-| Creates appropriate @&statement_control:foo@ subroutines. -} 545 stmtControlLoop :: VarName -- ^ Perl 6 name of the new sub 546 -> PrimName -- ^ PIR opcode to use for branching 547 -> Decl -- ^ Final declaration of the sub 548 stmtControlLoop name comp = sub ("&statement_control:" ++ name) [arg0, arg1] $ 549 if isPost then ["goto" .- [bare redoL]] else [] ++ 550 [ InsLabel nextL 551 , [reg tempPMC] <-& arg0 $ [] 552 , comp .- [tempPMC, bare lastL] 553 , InsLabel redoL 554 , arg1 .& [] 555 , "goto" .- [bare nextL] 556 , InsLabel lastL 557 , "returncc" .- [] 558 ] 559 where 560 nextL = ("sc_" ++ name ++ "_next") 561 lastL = ("sc_" ++ name ++ "_last") 562 redoL = ("sc_" ++ name ++ "_redo") 563 isPost = "post" `isPrefixOf` name 542 564 543 565 {-| Creates appropriate @&statement_control:foo@ subroutines. -} … … 614 636 , "returncc" .- [] 615 637 ] 638 , stmtControlLoop "while" "unless" 639 , stmtControlLoop "until" "if" 616 640 , stmtControlCond "if" "unless" 617 641 , stmtControlCond "unless" "if" -
src/Pugs/Compile/PIR.hs
r4886 r4888 247 247 compile exp@(Syn "while" _) = compLoop exp 248 248 compile exp@(Syn "until" _) = compLoop exp 249 compile exp@(Syn "postwhile" _) = compLoop exp 250 compile exp@(Syn "postuntil" _) = compLoop exp 249 251 compile (Syn "for" [exp, body]) = do 250 252 expC <- compile exp … … 331 333 compLoop (Syn name [cond, body]) = do 332 334 cxt <- askTCxt 333 condC <- compile cond334 bodyC <- compile body335 condC <- enter (CxtItem $ mkType "Bool") $ compile cond 336 bodyC <- enter CxtVoid $ compile body 335 337 funC <- compile (Var $ "&statement_control:" ++ name) 336 338 return . PStmt . PExp $ PApp cxt funC [pBlock condC, pBlock bodyC]
