Changeset 14152 for src/Pugs/Eval.hs

Show
Ignore:
Timestamp:
10/09/06 17:27:28 (2 years ago)
Author:
audreyt
Message:

* Revamp the "gather" structure, after discussion with TimToady?++

so that "take" is dynamic, although still fails if the callers
contains no "gather" frames.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval.hs

    r14123 r14152  
    7474        , envCaller  = Nothing 
    7575        , envOuter   = Nothing 
    76         , envDepth   = [] 
     76        , envFrames  = emptyFrames 
    7777        , envBody    = Val undef 
    7878        , envDebug   = Just ref -- Set to "Nothing" to disable debugging 
     
    500500reduceSyn "gather" [exp] = do 
    501501    sub     <- fromVal =<< evalExp exp 
    502     av      <- newArray [] 
    503     symTake <- genSym (cast "@?TAKE") (MkRef av) 
    504     apply (updateSubPad sub symTake) Nothing [] 
    505     fmap VList $ readIVar av 
     502    globTV  <- asks envGlobal 
     503    glob    <- liftSTM $ readTVar globTV 
     504    oldAV   <- findSymRef takeVar glob 
     505    oldSym  <- genSym takeVar oldAV 
     506    newAV   <- newObject (mkType "Array") 
     507    newSym  <- genSym takeVar newAV 
     508    liftSTM $ writeTVar globTV (newSym glob) 
     509    enterGather $ apply sub Nothing [] 
     510    readRef newAV `finallyM` liftSTM (modifyTVar globTV oldSym) 
     511    where 
     512    takeVar = cast "$*TAKE" 
    506513 
    507514reduceSyn "loop" exps = enterLoop $ do 
     
    733740    let varname = sigil:(concat . (intersperse "::") $ parts) 
    734741    -- Finally, eval the varname. 
    735     evalExp . _Var $ varname 
     742    reduceVar (possiblyFixOperatorName (cast varname)) 
    736743 
    737744reduceSyn "{}" [listExp, indexExp] = do 
     
    954961                   , envContext = envContext caller 
    955962                   , envLValue  = envLValue caller 
    956                    , envDepth   = envDepth caller 
     963                   , envFrames  = envFrames caller 
    957964                   , envPos     = envPos caller 
    958965                   } 
     
    968975                   , envContext = envContext caller 
    969976                   , envLValue  = envLValue caller 
    970                    , envDepth   = envDepth caller 
     977                   , envFrames  = envFrames caller 
    971978                   , envPos     = envPos caller 
    972979                   }