X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Frename%2FRnExpr.lhs;h=99d0767a8e786e6f167922a2eda08f251096c933;hb=70f6cbd1695128f2685085d423c09e4cb889d91e;hp=716a85a3b3ad4ad094c8ecc0b11d58211e9b99bb;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/rename/RnExpr.lhs b/compiler/rename/RnExpr.lhs index 716a85a..99d0767 100644 --- a/compiler/rename/RnExpr.lhs +++ b/compiler/rename/RnExpr.lhs @@ -30,20 +30,21 @@ import RnTypes ( rnHsTypeFVs, rnLPat, rnOverLit, rnPatsAndThen, rnLit, dupFieldErr, checkTupSize ) import DynFlags ( DynFlag(..) ) import BasicTypes ( FixityDirection(..) ) +import SrcLoc ( SrcSpan ) import PrelNames ( thFAKE, hasKey, assertIdKey, assertErrorName, loopAName, choiceAName, appAName, arrAName, composeAName, firstAName, negateName, thenMName, bindMName, failMName ) #if defined(GHCI) && defined(BREAKPOINT) -import PrelNames ( breakpointJumpName, undefined_RDR, breakpointIdKey ) +import PrelNames ( breakpointJumpName, breakpointCondJumpName + , undefined_RDR, breakpointIdKey, breakpointCondIdKey ) import UniqFM ( eltsUFM ) import DynFlags ( GhcMode(..) ) -import SrcLoc ( srcSpanFile, srcSpanStartLine ) import Name ( isTyVarName ) #endif import Name ( Name, nameOccName, nameIsLocalOrFrom ) import NameSet import RdrName ( RdrName, emptyGlobalRdrEnv, extendLocalRdrEnv, lookupLocalRdrEnv ) -import LoadIface ( loadHomeInterface ) +import LoadIface ( loadInterfaceForName ) import UniqFM ( isNullUFM ) import UniqSet ( emptyUniqSet ) import List ( nub ) @@ -99,20 +100,25 @@ rnExpr (HsVar v) lclEnv <- getLclEnv ignore_asserts <- doptM Opt_IgnoreAsserts ignore_breakpoints <- doptM Opt_IgnoreBreakpoints + ghcMode <- getGhcMode let conds = [ (name `hasKey` assertIdKey && not ignore_asserts, do (e, fvs) <- mkAssertErrorExpr return (e, fvs `addOneFV` name)) #if defined(GHCI) && defined(BREAKPOINT) , (name `hasKey` breakpointIdKey - && not ignore_breakpoints, - do ghcMode <- getGhcMode - case ghcMode of - Interactive - -> do let isWantedName = not.isTyVarName - (e, fvs) <- mkBreakPointExpr (filter isWantedName (eltsUFM localRdrEnv)) - return (e, fvs `addOneFV` name) - _ -> return (HsVar name, unitFV name) + && not ignore_breakpoints + && ghcMode == Interactive, + do let isWantedName = not.isTyVarName + (e, fvs) <- mkBreakpointExpr (filter isWantedName (eltsUFM localRdrEnv)) + return (e, fvs `addOneFV` name) + ) + , (name `hasKey` breakpointCondIdKey + && not ignore_breakpoints + && ghcMode == Interactive, + do let isWantedName = not.isTyVarName + (e, fvs) <- mkBreakpointCondExpr (filter isWantedName (eltsUFM localRdrEnv)) + return (e, fvs `addOneFV` name) ) #endif ] @@ -453,7 +459,7 @@ methodNamesCmd other = emptyFVs -- The type checker will complain later --------------------------------------------------- -methodNamesMatch (MatchGroup ms ty) +methodNamesMatch (MatchGroup ms _) = plusFVs (map do_one ms) where do_one (L _ (Match pats sig_ty grhss)) = methodNamesGRHSs grhss @@ -544,7 +550,7 @@ rnRbinds str rbinds rnBracket (VarBr n) = do { name <- lookupOccRn n ; this_mod <- getModule ; checkM (nameIsLocalOrFrom this_mod name) $ -- Reason: deprecation checking asumes the - do { loadHomeInterface msg name -- home interface is loaded, and this is the + do { loadInterfaceForName msg name -- home interface is loaded, and this is the ; return () } -- only way that is going to happen ; returnM (VarBr name, unitFV name) } where @@ -941,8 +947,14 @@ segsToStmts ((defs, uses, fwds, ss) : segs) fvs_later \begin{code} #if defined(GHCI) && defined(BREAKPOINT) -mkBreakPointExpr :: [Name] -> RnM (HsExpr Name, FreeVars) -mkBreakPointExpr scope +mkBreakpointExpr :: [Name] -> RnM (HsExpr Name, FreeVars) +mkBreakpointExpr = mkBreakpointExpr' breakpointJumpName + +mkBreakpointCondExpr :: [Name] -> RnM (HsExpr Name, FreeVars) +mkBreakpointCondExpr = mkBreakpointExpr' breakpointCondJumpName + +mkBreakpointExpr' :: Name -> [Name] -> RnM (HsExpr Name, FreeVars) +mkBreakpointExpr' breakpointFunc scope = do sloc <- getSrcSpanM undef <- lookupOccRn undefined_RDR let inLoc = L sloc @@ -951,12 +963,17 @@ mkBreakPointExpr scope mkExpr' fnName [] = inLoc (HsVar fnName) mkExpr' fnName (arg:args) = lHsApp (mkExpr' fnName args) (inLoc arg) - expr = unLoc $ mkExpr breakpointJumpName [mkScopeArg scope, HsVar undef, HsLit msg] - mkScopeArg args - = unLoc $ mkExpr undef (map HsVar args) - msg = HsString (mkFastString (unpackFS (srcSpanFile sloc) ++ ":" ++ show (srcSpanStartLine sloc))) + expr = unLoc $ mkExpr breakpointFunc [mkScopeArg scope, HsVar undef, msg] + mkScopeArg args = unLoc $ mkExpr undef (map HsVar args) + msg = srcSpanLit sloc return (expr, emptyFVs) #endif + +srcSpanLit :: SrcSpan -> HsExpr Name +srcSpanLit span = HsLit (HsString (mkFastString (showSDoc (ppr span)))) + +srcSpanPrimLit :: SrcSpan -> HsExpr Name +srcSpanPrimLit span = HsLit (HsStringPrim (mkFastString (showSDoc (ppr span)))) \end{code} %************************************************************************ @@ -971,8 +988,8 @@ mkAssertErrorExpr :: RnM (HsExpr Name, FreeVars) mkAssertErrorExpr = getSrcSpanM `thenM` \ sloc -> let - expr = HsApp (L sloc (HsVar assertErrorName)) (L sloc (HsLit msg)) - msg = HsStringPrim (mkFastString (showSDoc (ppr sloc))) + expr = HsApp (L sloc (HsVar assertErrorName)) + (L sloc (srcSpanPrimLit sloc)) in returnM (expr, emptyFVs) \end{code}