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/AST/Internals.hs

    r3372 r3443  
    5454    retError, retControl, retEmpty, retIVar, readIVar, writeIVar, 
    5555    fromVals, refType, 
    56     mkPad, lookupPad, padToList, diffPads, unionPads, 
     56    mkPad, lookupPad, padToList, diffPads, unionPads, subPad, updateSubPad, 
    5757    mkPrim, mkSub, 
    5858    cxtOfSigil, typeOfSigil, 
     
    679679    , subName       :: !String      -- ^ Name of the closure 
    680680    , subType       :: !SubType     -- ^ Type of the closure 
    681     , subPad        :: !Pad        -- ^ Lexical pad for sub\/method 
     681    , subEnv        :: !(Maybe Env) -- ^ Lexical pad for sub\/method 
    682682    , subAssoc      :: !String      -- ^ Associativity 
    683683    , subParams     :: !Params      -- ^ Parameters list 
     
    700700    , subName = "&?" 
    701701    , subType = SubPrim 
    702     , subPad = mkPad [] 
     702    , subEnv = Nothing 
    703703    , subAssoc = "pre" 
    704704    , subParams = [] 
     
    715715    , subName = "&?" 
    716716    , subType = SubBlock 
    717     , subPad = mkPad [] 
     717    , subEnv = Nothing 
    718718    , subAssoc = "pre" 
    719719    , subParams = [] 
     
    913913    , envEval    :: !(Exp -> Eval Val)   -- ^ Active evaluator 
    914914    , envCaller  :: !(Maybe Env)         -- ^ Caller's env 
     915    , envOuter   :: !(Maybe Env)         -- ^ Outer block's env 
    915916    , envBody    :: !Exp                 -- ^ Current AST expression 
    916917    , envDepth   :: !Int                 -- ^ Recursion depth 
     
    10031004unionPads :: Pad -> Pad -> Pad 
    10041005unionPads (MkPad map1) (MkPad map2) = MkPad $ Map.union map1 map2 
     1006 
     1007updateSubPad :: VCode -> (Pad -> Pad) -> VCode 
     1008updateSubPad sub f = sub 
     1009    { subEnv = fmap (\e -> e{ envLexical = f (subPad sub) }) (subEnv sub)  
     1010    } 
     1011 
     1012subPad :: VCode -> Pad 
     1013subPad sub = maybe (mkPad []) envLexical (subEnv sub) 
    10051014 
    10061015type Eval x = EvalT (ContT Val (ReaderT Env SIO)) x