Changeset 16378

Show
Ignore:
Timestamp:
05/17/07 23:41:38 (18 months ago)
Author:
audreyt
Message:

* Fix trait blocks and their interactions.

Location:
src/Pugs
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST/Internals.hs

    r16373 r16378  
    4242 
    4343    IVar(..), -- uses *Class and V* 
    44     IArray, IArraySlice, IHash, IScalar, IScalarProxy, 
     44    IArray(..), IArraySlice, IHash, IScalar, IScalarProxy, 
    4545    IScalarLazy, IPairHashSlice, IRule, IHandle, IHashEnv(..), 
    4646    IScalarCwd(..), 
     
    14631463refreshPad pad = do 
    14641464    fmap listToPad $ forM (padToList pad) $ \(name, entry) -> do 
     1465        -- warn "Refreshing pad entry" (name, entry) 
    14651466        entry' <- case entry of 
    14661467            PELexical{ pe_proto = proto } -> stm $ do 
  • src/Pugs/AST/SIO.hs

    r15765 r16378  
    5454    liftSIO :: SIO a -> m a 
    5555    liftSIO = fail "liftSIO not detailed for this monad" 
     56    {-# SPECIALISE liftSTM :: STM a -> STM a #-} 
     57    {-# SPECIALISE liftSTM :: STM a -> IO a #-} 
     58    {-# SPECIALISE liftSTM :: STM a -> SIO a #-} 
    5659    liftSTM :: STM a -> m a 
    5760 
     
    7174    liftIO io = MkIO io 
    7275 
     76{-# INLINE stm #-} 
    7377stm :: (MonadSTM m) => STM a -> m a 
    7478stm = liftSTM 
  • src/Pugs/Eval.hs

    r16376 r16378  
    451451 
    452452reduceSyn "sub" [exp] = do 
    453     (VCode sub) <- enterEvalContext (cxtItem "Code") exp 
     453    sub  <- fromCodeExp exp 
    454454    env  <- ask 
    455455    cont <- if subType sub /= SubCoroutine then return Nothing else stm $ do 
  • src/Pugs/Monads.hs

    r16376 r16378  
    2626    reclosePad, recloseCode, 
    2727     
    28     MaybeT, runMaybeT, 
     28    MaybeT, runMaybeT 
    2929) where 
    3030import Pugs.Internals 
     
    278278                local doFix runAction 
    279279        runBlocks (filter (rejectKeepUndo rv . subName) . subLeaveBlocks) 
    280  
    281280    when (rv == VControl (ControlLoop LoopLast)) $ 
    282281        -- We won't have a chance to run the LAST block 
    283282        -- once we exit outside the lexical block, so do it now 
    284283        runBlocks subLastBlocks 
    285  
    286284    assertBlocks subPostBlocks "POST" 
    287285    case rv of 
     
    311309        rv <- fromVal =<< (evalExp . Syn "block" . (:[]) . Syn "sub" . (:[]) . Val . castV $ cv) 
    312310        if rv then return () else die (name ++ " assertion failed") (subName sub) 
     311    runBlocks' f = mapM_ (evalExp . Syn "block'" . (:[]) . Syn "sub" . (:[]) . Val . castV) (f (subTraitBlocks sub)) 
     312    assertBlocks' f name = forM_ (f (subTraitBlocks sub)) $ \cv -> do 
     313        rv <- fromVal =<< (evalExp . Syn "block'" . (:[]) . Syn "sub" . (:[]) . Val . castV $ cv) 
     314        if rv then return () else die (name ++ " assertion failed") (subName sub) 
    313315    typ = subType sub 
    314316    doCC :: (Val -> Eval b) -> [Val] -> Eval b 
     
    328330            return $ \e -> e 
    329331                { envLexical = subRec (envLexical env `mappend` pad) 
     332                , envPackage = subPackage sub 
     333                , envLexPads = (PRuntime pad:envLexPads env) 
     334                } 
     335        | AKInline <- appKind = do 
     336            -- Entering an inline call. 
     337            subRec    <- genRecSym 
     338            return $ \e -> e 
     339                { envLexical = subRec (pad `mappend` envLexical env) 
    330340                , envPackage = subPackage sub 
    331341                , envLexPads = (PRuntime pad:envLexPads env) 
  • src/Pugs/Parser.hs

    r16374 r16378  
    10381038 
    10391039vcode2initBlock :: Val -> RuleParser Exp 
    1040 vcode2initBlock code = do 
    1041     body    <- vcode2startBlock code 
    1042     let fstcode = Syn "sub" [ Val $ VCode mkSub { subBody = body } ] 
     1040vcode2initBlock ~(VCode code) = do 
     1041    code'   <- vcode2memoized code 
    10431042    Val res <- unsafeEvalExp $ 
    1044         App (_Var "&push") (Just $ _Var "@*INIT") [ fstcode ] 
    1045     return (res `seq` App fstcode Nothing []) 
     1043        App (_Var "&push") (Just $ _Var "@*INIT") [ Val (VCode code') ] 
     1044    return (res `seq` App (Val (VCode code')) Nothing []) 
    10461045 
    10471046vcode2checkBlock :: Val -> RuleParser Exp 
     
    10501049    let fstcode = Syn "sub" [ checkForIOLeak mkSub{ subBody = body } ] 
    10511050    Val res <- unsafeEvalExp $ 
    1052         App (_Var "&unshift") (Just $ _Var "@*CHECK") [ fstcode ] 
    1053     return (res `seq` App fstcode Nothing []) 
     1051        App (_Var "&unshift") (Just $ _Var "@*CHECK") [ Val (VCode code') ] 
     1052    return (res `seq` App (Val (VCode code')) Nothing []) 
    10541053 
    10551054-- Constructs ------------------------------------------------ 
  • src/Pugs/Parser/Program.hs

    r16377 r16378  
    195195        { envBody       = App (Syn "block" [main']) Nothing (replicate (length $ subParams vc) (_Var "$*_")) -- _Var "@*ARGS"] 
    196196        , envPackage    = envPackage env 
     197        , envCompPad    = Nothing 
    197198        } 
    198199