Changeset 3443 for src/Pugs/Monads.hs

Show
Ignore:
Timestamp:
05/19/05 17:57:17 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
5016
Message:

* We have OUTER:: scope now.
* Closure (VCode) now captures over the entire Env, instead

of just the envLexical slot. This is currently only used to

restore the original OUTER
scope when calling a subroutine, but once we switch to oleg's CC_2CPST for Eval monad, this will get us rubyish coroutines (and serialised subcontinuations) for free.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Monads.hs

    r3291 r3443  
    147147    env <- ask 
    148148    exitRec <- genSubs env "&?BLOCK_EXIT" $ escSub esc 
    149     enterLex exitRec action 
     149    local (\e -> e{ envOuter = Just env }) $ enterLex exitRec action 
    150150    where 
    151151    escSub esc env = mkPrim 
     
    176176            blockRec <- genSym "&?BLOCK" (codeRef (orig sub)) 
    177177            return $ \e -> e 
    178                 { envLexical = combine [blockRec] 
     178                { envOuter = Just env 
     179                , envLexical = combine [blockRec] 
    179180                    (subPad sub `unionPads` envLexical env) } 
    180181        | otherwise = do 
     
    185186            callerRec <- genSubs env "&?CALLER_CONTINUATION" (ccSub cc) 
    186187            return $ \e -> e 
    187                 { envLexical = combine (concat [subRec, callerRec]) (subPad sub) } 
     188                { envLexical = combine (concat [subRec, callerRec]) (subPad sub) 
     189                , envOuter   = maybe Nothing envOuter (subEnv sub) 
     190                } 
    188191    ccSub cc env = mkPrim 
    189192        { subName = "CALLER_CONTINUATION"