<commit_before>-----------------------------------------------------------------------------
--
-- Support code for instrumentation and expansion of the breakpoint combinator
--
-- <NAME> (supported by Google SoC) 2006
--
-----------------------------------------------------------------------------

\begin{code}
module DsBreakpoint( 
                     dsAndThenMaybeInsertBreakpoint
                   , maybeInsertBreakpoint
                   , breakpoints_enabled
                   , mkBreakpointExpr
                   ) where

import IOEnv
import TysPrim
import TysWiredIn
import PrelNames        
import Module
import PackageConfig
import SrcLoc
import TyCon
import TypeRep
import DataCon          
import Type             
import MkId
import Name
import Var
import Id 

import IdInfo
import BasicTypes
import OccName

import TcRnMonad
import HsSyn            
import HsLit
import CoreSyn
import CoreUtils
import Outputable
import ErrUtils
import FastString
import DynFlags
 
import DsMonad 
import {-#SOURCE#-}DsExpr ( dsLExpr ) 
import Control.Monad
import Data.IORef
import Foreign.StablePtr
import GHC.Exts

#ifdef GHCI
mkBreakpointExpr :: SrcSpan -> Id -> DsM (LHsExpr Id)
mkBreakpointExpr loc bkptFuncId = do
        scope <- getScope
        mod   <- getModuleDs
        let mod_name = moduleNameFS$ moduleName mod
        when (not instrumenting) $
              warnDs (text "Extracted ids:" <+> (ppr scope $$ 
                                                   ppr (map idType scope)))
        stablePtr <- ioToIOEnv $ newStablePtr scope
        site <- if instrumenting
                   then recordBkpt (srcSpanStart loc)
                   else return 0
        ATyCon opaqueTyCon <- dsLookupGlobal opaqueTyConName
        jumpFuncId <- mkJumpFunc bkptFuncId
        let [opaqueDataCon] = tyConDataCons opaqueTyCon
            opaqueId = dataConWrapId opaqueDataCon
            opaqueTy = mkTyConApp opaqueTyCon []
            wrapInOpaque id = 
                  l(HsApp (l(HsWrap (WpTyApp (idType id)) (HsVar opaqueId)))
                          (l(HsVar id)))
           -- Yes, I know... I'm gonna burn in hell.
            Ptr addr# = castStablePtrToPtr stablePtr
            hvals = ExplicitList opaqueTy (map wrapInOpaque scope)<commit_msg>Fix imports<commit_after>-----------------------------------------------------------------------------
--
-- Support code for instrumentation and expansion of the breakpoint combinator
--
-- <NAME> (supported by Google SoC) 2006
--
-----------------------------------------------------------------------------

\begin{code}
module DsBreakpoint( 
                     dsAndThenMaybeInsertBreakpoint
                   , maybeInsertBreakpoint
                   , breakpoints_enabled
                   , mkBreakpointExpr
                   ) where

import TysPrim
import TysWiredIn
import PrelNames        
import Module
import PackageConfig
import SrcLoc
import TyCon
import TypeRep
import DataCon          
import Type             
import Id 

import IdInfo
import BasicTypes
import OccName

import TcRnMonad
import HsSyn            
import HsLit
import CoreSyn
import CoreUtils
import Outputable
import ErrUtils
import FastString
import DynFlags
 
import DsMonad 
import {-#SOURCE#-}DsExpr ( dsLExpr ) 
import Control.Monad
import Data.IORef
import Foreign.StablePtr
import GHC.Exts
#ifdef GHCI
mkBreakpointExpr :: SrcSpan -> Id -> DsM (LHsExpr Id)
mkBreakpointExpr loc bkptFuncId = do
        scope <- getScope
        mod   <- getModuleDs
        let mod_name = moduleNameFS$ moduleName mod
        when (not instrumenting) $
              warnDs (text "Extracted ids:" <+> (ppr scope $$ 
                                                   ppr (map idType scope)))
        stablePtr <- ioToIOEnv $ newStablePtr scope
        site <- if instrumenting
                   then recordBkpt (srcSpanStart loc)
                   else return 0
        ATyCon opaqueTyCon <- dsLookupGlobal opaqueTyConName
        jumpFuncId <- mkJumpFunc bkptFuncId
        let [opaqueDataCon] = tyConDataCons opaqueTyCon
            opaqueId = dataConWrapId opaqueDataCon
            opaqueTy = mkTyConApp opaqueTyCon []
            wrapInOpaque id = 
                  l(HsApp (l(HsWrap (WpTyApp (idType id)) (HsVar opaqueId)))
                          (l(HsVar id)))
           -- Yes, I know... I'm gonna burn in hell.
            Ptr addr# = castStablePtrToPtr stablePtr
            hvals = ExplicitList opaqueTy (map wrapInOpaque scope)
{'fraction_non_alphanumeric': 0.12096953524571936, 'fraction_numerical': 0.0022237046920169003, 'mean_word_length': 1.6568222090962788, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4990447', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1138, 'n_words': 366}