Changeset 16378
- Timestamp:
- 05/17/07 23:41:38 (18 months ago)
- Location:
- src/Pugs
- Files:
-
- 6 modified
-
AST/Internals.hs (modified) (2 diffs)
-
AST/SIO.hs (modified) (2 diffs)
-
Eval.hs (modified) (1 diff)
-
Monads.hs (modified) (4 diffs)
-
Parser.hs (modified) (2 diffs)
-
Parser/Program.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/AST/Internals.hs
r16373 r16378 42 42 43 43 IVar(..), -- uses *Class and V* 44 IArray , IArraySlice, IHash, IScalar, IScalarProxy,44 IArray(..), IArraySlice, IHash, IScalar, IScalarProxy, 45 45 IScalarLazy, IPairHashSlice, IRule, IHandle, IHashEnv(..), 46 46 IScalarCwd(..), … … 1463 1463 refreshPad pad = do 1464 1464 fmap listToPad $ forM (padToList pad) $ \(name, entry) -> do 1465 -- warn "Refreshing pad entry" (name, entry) 1465 1466 entry' <- case entry of 1466 1467 PELexical{ pe_proto = proto } -> stm $ do -
src/Pugs/AST/SIO.hs
r15765 r16378 54 54 liftSIO :: SIO a -> m a 55 55 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 #-} 56 59 liftSTM :: STM a -> m a 57 60 … … 71 74 liftIO io = MkIO io 72 75 76 {-# INLINE stm #-} 73 77 stm :: (MonadSTM m) => STM a -> m a 74 78 stm = liftSTM -
src/Pugs/Eval.hs
r16376 r16378 451 451 452 452 reduceSyn "sub" [exp] = do 453 (VCode sub) <- enterEvalContext (cxtItem "Code")exp453 sub <- fromCodeExp exp 454 454 env <- ask 455 455 cont <- if subType sub /= SubCoroutine then return Nothing else stm $ do -
src/Pugs/Monads.hs
r16376 r16378 26 26 reclosePad, recloseCode, 27 27 28 MaybeT, runMaybeT ,28 MaybeT, runMaybeT 29 29 ) where 30 30 import Pugs.Internals … … 278 278 local doFix runAction 279 279 runBlocks (filter (rejectKeepUndo rv . subName) . subLeaveBlocks) 280 281 280 when (rv == VControl (ControlLoop LoopLast)) $ 282 281 -- We won't have a chance to run the LAST block 283 282 -- once we exit outside the lexical block, so do it now 284 283 runBlocks subLastBlocks 285 286 284 assertBlocks subPostBlocks "POST" 287 285 case rv of … … 311 309 rv <- fromVal =<< (evalExp . Syn "block" . (:[]) . Syn "sub" . (:[]) . Val . castV $ cv) 312 310 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) 313 315 typ = subType sub 314 316 doCC :: (Val -> Eval b) -> [Val] -> Eval b … … 328 330 return $ \e -> e 329 331 { 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) 330 340 , envPackage = subPackage sub 331 341 , envLexPads = (PRuntime pad:envLexPads env) -
src/Pugs/Parser.hs
r16374 r16378 1038 1038 1039 1039 vcode2initBlock :: Val -> RuleParser Exp 1040 vcode2initBlock code = do 1041 body <- vcode2startBlock code 1042 let fstcode = Syn "sub" [ Val $ VCode mkSub { subBody = body } ] 1040 vcode2initBlock ~(VCode code) = do 1041 code' <- vcode2memoized code 1043 1042 Val res <- unsafeEvalExp $ 1044 App (_Var "&push") (Just $ _Var "@*INIT") [ fstcode]1045 return (res `seq` App fstcodeNothing [])1043 App (_Var "&push") (Just $ _Var "@*INIT") [ Val (VCode code') ] 1044 return (res `seq` App (Val (VCode code')) Nothing []) 1046 1045 1047 1046 vcode2checkBlock :: Val -> RuleParser Exp … … 1050 1049 let fstcode = Syn "sub" [ checkForIOLeak mkSub{ subBody = body } ] 1051 1050 Val res <- unsafeEvalExp $ 1052 App (_Var "&unshift") (Just $ _Var "@*CHECK") [ fstcode]1053 return (res `seq` App fstcodeNothing [])1051 App (_Var "&unshift") (Just $ _Var "@*CHECK") [ Val (VCode code') ] 1052 return (res `seq` App (Val (VCode code')) Nothing []) 1054 1053 1055 1054 -- Constructs ------------------------------------------------ -
src/Pugs/Parser/Program.hs
r16377 r16378 195 195 { envBody = App (Syn "block" [main']) Nothing (replicate (length $ subParams vc) (_Var "$*_")) -- _Var "@*ARGS"] 196 196 , envPackage = envPackage env 197 , envCompPad = Nothing 197 198 } 198 199
