Changeset 4885
- Timestamp:
- 06/20/05 21:50:09 (4 years ago)
- svk:copy_cache_prev:
- 6641
- Location:
- src
- Files:
-
- 2 modified
-
Emit/PIR.hs (modified) (4 diffs)
-
Pugs/Compile/PIR.hs (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Emit/PIR.hs
r4882 r4885 219 219 (<-&) :: [Sig] -> Expression -> [Expression] -> Ins 220 220 {-| Calls an user-defined sub, ignoring any return values. -} 221 (.&) :: String-> [Expression] -> Ins221 (.&) :: Expression -> [Expression] -> Ins 222 222 223 223 namespace = DeclNS … … 229 229 (.-) = InsPrim Nothing 230 230 (<-&) = InsFun 231 (.&) = InsFun [] . lit231 (.&) = InsFun [] 232 232 233 233 {-| @$P0@ register -} … … 606 606 , sub "&leave" [slurpy arg0] 607 607 [] --> [arg0] 608 , sub "&statement_control:loop" [arg0, arg1, arg2, arg3] $ 608 , sub "&statement_control:for" [arg0, arg1] 609 [ tempPMC <-- "iter" $ [arg0] 610 , InsLabel "sc_for_next" 611 , "unless" .- [tempPMC, bare "sc_for_last"] 612 , tempPMC2 <-- "shift" $ [tempPMC] 613 , arg1 .& [tempPMC2] 614 , "goto" .- [bare "sc_for_next"] 615 , InsLabel "sc_for_last" 616 , "returncc" .- [] 617 ] 618 , sub "&statement_control:loop" [arg0, arg1, arg2, arg3] 609 619 [ InsLabel "sc_loop_next" 610 620 , [reg tempPMC] <-& arg1 $ [] 611 621 , "unless" .- [tempPMC, bare "sc_loop_last"] 612 , [] <-& arg2 $[] -- throw away the result of body...613 , [] <-& arg3 $[] -- ...and the post-condition622 , arg2 .& [] -- throw away the result of body... 623 , arg3 .& [] -- ...and the post-condition 614 624 , "goto" .- [bare "sc_loop_next"] 615 625 , InsLabel "sc_loop_last" … … 645 655 ] --> [lit True] 646 656 , sub "&Pugs::Internals::exit" [arg0] 647 [ "&*END" .& []657 [ lit "&*END" .& [] 648 658 , tempINT <:= arg0 649 659 , "exit" .- [tempINT] -
src/Pugs/Compile/PIR.hs
r4882 r4885 244 244 return $ PStmt $ PExp $ PApp TCxtVoid funC 245 245 [preC, pBlock condC, pBlock bodyC, pBlock postC] 246 compile exp@(Syn "unless" _) = fmap (PStmt . PExp) $ compConditional exp 247 compile exp@(Syn "while" _) = compLoop exp 248 compile exp@(Syn "until" _) = compLoop exp 249 compile (Syn "for" [exp, body]) = do 250 expC <- compile exp 251 bodyC <- compile body 252 funC <- compile (Var "&statement_control:for") 253 return $ PStmt $ PExp $ PApp TCxtVoid funC [expC, bodyC] 254 compile (Syn "given" _) = compile (Var "$_") -- XXX 255 compile (Syn "when" _) = compile (Var "$_") -- XXX 246 256 compile exp = fmap PStmt $ compile exp 247 257 … … 297 307 return $ PApp cxt funC argsC 298 308 compile exp@(Syn "if" _) = compConditional exp 299 compile exp@(Syn "unless" _) = compConditional exp300 compile exp@(Syn "while" _) = compLoop exp301 compile exp@(Syn "until" _) = compLoop exp302 compile (Syn "given" _) = compile (Var "$_") -- XXX303 compile (Syn "when" _) = compile (Var "$_") -- XXX304 309 compile (Syn "{}" (x:xs)) = compile (App (Var "&postcircumfix:{}") (Just x) xs) 305 310 compile (Syn "[]" (x:xs)) = do … … 323 328 compile exp = compError exp 324 329 325 compLoop :: Exp -> Comp (PIL LValue)330 compLoop :: Exp -> Comp (PIL Stmt) 326 331 compLoop (Syn name [cond, body]) = do 327 332 cxt <- askTCxt … … 329 334 bodyC <- compile body 330 335 funC <- compile (Var $ "&statement_control:" ++ name) 331 return $ PApp cxt funC [pBlock condC, pBlock bodyC]336 return . PStmt . PExp $ PApp cxt funC [pBlock condC, pBlock bodyC] 332 337 compLoop exp = compError exp 333 338 … … 362 367 paramsC <- compile $ subParams sub 363 368 return $ PCode (subType sub) paramsC bodyC 364 compile (Syn "for" _) = compile Noop -- XXX TODO365 369 compile (Syn "module" _) = compile Noop 366 370 compile (Syn "match" exp) = compile $ Syn "rx" exp -- wrong
