Changeset 4876

Show
Ignore:
Timestamp:
06/20/05 19:23:02 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
6641
Message:

* loop and bare blocks at value position now Really Works (tm).

Location:
src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Emit/PIR.hs

    r4874 r4876  
    521521parrotBrokenXXX = True 
    522522 
    523 -- calls and place result in tempPMC 
    524 callBlock :: VarName -> Expression -> [Ins] 
    525 callBlock label fun = 
    526     [ "newsub" .- [funPMC, bare ".Continuation", bare label] 
    527     ] ++ callBlockCC fun ++ collectCC label 
    528  
    529523collectCC :: LabelName -> [Ins] 
    530524collectCC label = 
     
    535529    ] 
    536530 
    537 callBlockCC :: Expression -> [Ins] 
    538 callBlockCC fun | parrotBrokenXXX = 
     531callThunkCC :: Expression -> [Ins] 
     532callThunkCC fun | parrotBrokenXXX = 
    539533    [ tempINT   <-- "get_addr" $ [fun] 
    540534    , tempSTR   <:= tempINT 
     
    542536    , "invoke" .- [fun] 
    543537    ] 
    544 callBlockCC fun = 
     538callThunkCC fun = 
    545539    [ "set_args" .- sigList [funPMC] 
    546540    , "invoke" .- [fun] 
     
    554548    [ "newsub" .- [funPMC, bare ".Continuation", bare postL] 
    555549    , comp .- [arg0, bare altL] 
    556     ] ++ callBlockCC arg1 ++ 
     550    ] ++ callThunkCC arg1 ++ 
    557551    [ InsLabel altL 
    558     ] ++ callBlockCC arg2 ++ collectCC postL) --> [tempPMC] 
     552    ] ++ callThunkCC arg2 ++ collectCC postL) --> [tempPMC] 
    559553    where 
    560554    altL = ("sc_" ++ name ++ "_alt") 
     
    572566    , "returncc" .- [] 
    573567    , InsLabel altL 
    574     ] ++ callBlockCC arg1 ++ collectCC postL) --> [tempPMC] 
     568    ] ++ callThunkCC arg1 ++ collectCC postL) --> [tempPMC] 
    575569    where 
    576570    altL = ("sc_" ++ escaped name ++ "_alt") 
     
    612606    , sub "&statement_control:loop" [arg0, arg1, arg2, arg3] $ 
    613607        [ InsLabel "sc_loop_next" 
    614         ] ++ callBlock "loopCond" arg1 ++ 
    615         [ "unless" .- [tempPMC, bare "sc_loop_last"] 
    616         ] ++ callBlock "loopBody" arg2 ++ 
    617         [ -- ..throw away the result of body... 
    618         ] ++ callBlock "loopPost" arg3 ++ 
    619         [ "goto" .- [bare "sc_loop_next"] 
     608        , [reg tempPMC] <-& arg1 $ [] 
     609        , "unless" .- [tempPMC, bare "sc_loop_last"] 
     610        , [] <-& arg2 $ [] -- throw away the result of body... 
     611        , [] <-& arg3 $ [] -- ...and the post-condition 
     612        , "goto" .- [bare "sc_loop_next"] 
    620613        , InsLabel "sc_loop_last" 
    621614        , "returncc" .- [] 
  • src/Pugs/Compile/PIR.hs

    r4875 r4876  
    335335    compile (Cxt cxt rest) = enter cxt $ compile rest 
    336336    compile (Var name) = return . PExp $ PVar name 
     337    compile exp@(Val (VCode _)) = compile (Syn "sub" [exp]) 
    337338    compile (Val val) = fmap PLit (compile val) 
    338339    compile Noop = compile (Val undef) 
     
    436437    trans (PApp _ exp@(PBlock _) []) = do 
    437438        blockC  <- trans exp 
    438         [appC] <- genLabel ["invokeBlock"] 
    439         tell $ map StmtIns $ callBlock appC blockC  
     439        tellIns $ [reg tempPMC] <-& blockC $ [] 
    440440        return tempPMC 
    441441    trans (PApp (TCxtLValue _) (PExp (PVar "&postcircumfix:[]")) [(PExp lhs), rhs]) = do