Changeset 7851
- Timestamp:
- 11/05/05 15:06:37 (3 years ago)
- Location:
- src
- Files:
-
- 2 modified
-
Emit/PIR.hs (modified) (3 diffs)
-
Pugs/CodeGen/PIR.hs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Emit/PIR.hs
r7277 r7851 87 87 = PerlScalar | PerlArray | PerlHash 88 88 | PerlInt | PerlPair | PerlRef | PerlEnv 89 | Closure | Continuation 89 90 | BareType String 90 91 deriving (Show, Eq, Typeable) … … 587 588 -> PrimName -- ^ PIR opcode to use for branching 588 589 -> Decl -- ^ Final declaration of the sub 589 stmtControlCond name comp = sub ("&statement_control:" ++ name) [arg0, arg1, arg2] ( 590 [ "newsub" .- [funPMC, bare ".Continuation", bare postL] 591 , comp .- [arg0, bare altL] 592 ] ++ callThunkCC arg1 ++ 593 [ InsLabel altL 594 ] ++ callThunkCC arg2 ++ collectCC postL) --> [tempPMC] 590 stmtControlCond name comp = 591 sub ("&statement_control:" ++ name) [arg0, arg1, arg2] body --> [tempPMC] 595 592 where 596 593 altL = ("sc_" ++ name ++ "_alt") 597 594 postL = ("sc_" ++ name ++ "_post") 595 body = concat 596 [ newCont postL 597 , [ comp .- [arg0, bare altL] ] 598 , callThunkCC arg1 599 , [ InsLabel altL ] 600 , callThunkCC arg2, 601 collectCC postL 602 ] 603 604 newCont :: VarName -> [Ins] 605 newCont label = 606 [ InsNew funPMC Continuation 607 , "set_addr" .- [funPMC, bare label] 608 ] 598 609 599 610 {-| Creates appropriate @&infix:foo@ subs for logical operators (@||@, @&&@, … … 602 613 -> PrimName -- ^ PIR opcode to use (@if@, @unless@) 603 614 -> Decl -- ^ Final declaration of the sub 604 op2Logical name comp = sub ("&infix:" ++ name) [arg0, arg1] ( 605 [ "newsub" .- [funPMC, bare ".Continuation", bare postL] 606 , comp .- [arg0, bare altL] 607 , "set_returns" .- retSigList [arg0] 608 , "returncc" .- [] 609 , InsLabel altL 610 ] ++ callThunkCC arg1 ++ collectCC postL) --> [tempPMC] 615 op2Logical name comp = sub ("&infix:" ++ name) [arg0, arg1] body --> [tempPMC] 611 616 where 612 617 altL = ("sc_" ++ escaped name ++ "_alt") 613 618 postL = ("sc_" ++ escaped name ++ "_post") 619 body = newCont postL ++ 620 [ comp .- [arg0, bare altL] 621 , "set_returns" .- retSigList [arg0] 622 , "returncc" .- [] 623 , InsLabel altL 624 ] ++ callThunkCC arg1 ++ collectCC postL 614 625 615 626 {-| Escapes characters which have a special meaning in PIR. -} -
src/Pugs/CodeGen/PIR.hs
r7579 r7851 89 89 [begL, sndL, retL, endL] <- genLabel ["thunkBegin", "thunkAgain", "thunkReturn", "thunkEnd"] 90 90 this <- genPMC "block" 91 tellIns $ "newsub" .- [reg this, bare ".Continuation", bare begL] 91 tellIns $ InsNew (reg this) Continuation 92 tellIns $ "set_addr" .- [reg this, bare begL] 92 93 tellIns $ "goto" .- [bare endL] 93 94 tellLabel begL … … 109 110 [begL, endL] <- genLabel ["blockBegin", "blockEnd"] 110 111 this <- genPMC "block" 111 tellIns $ "newsub" .- [reg this, bare ".Closure", bare begL] 112 tellIns $ InsNew (reg this) Closure 113 tellIns $ "set_addr" .- [reg this, bare begL] 112 114 tellIns $ "goto" .- [bare endL] 113 115 tellLabel begL
