isModuleInterpreted,
compileExpr, dynCompileExpr,
lookupName,
- Term(..), obtainTerm, obtainTerm1, reconstructType,
+ Term(..), obtainTerm, obtainTerm1, obtainTermB, reconstructType,
skolemiseSubst, skolemiseTy
#endif
) where
import Data.Array
import Control.Exception as Exception
import Control.Concurrent
+import Data.List (sortBy)
import Data.IORef
import Foreign.StablePtr
= History {
historyApStack :: HValue,
historyBreakInfo :: BreakInfo,
- historyEnclosingDecl :: Name
+ historyEnclosingDecl :: Id
-- ^^ A cache of the enclosing top level declaration, for convenience
}
_ -> panic "getHistorySpan"
-- | Finds the enclosing top level function name
-findEnclosingDecl :: HscEnv -> Module -> SrcSpan -> Name
+findEnclosingDecl :: HscEnv -> Module -> SrcSpan -> Id
findEnclosingDecl hsc_env mod span =
case lookupUFM (hsc_HPT hsc_env) (moduleName mod) of
Nothing -> panic "findEnclosingDecl"
Just hmi -> let
- globals = typeEnvIds (md_types (hm_details hmi))
- Just decl = find (\n -> nameSrcSpan n < span)
- (reverse $ map idName globals)
- -- ^^ assumes md_types is sorted
- in decl
+ globals = typeEnvIds (md_types (hm_details hmi))
+ Just decl =
+ find (\id -> let n = idName id in
+ nameSrcSpan n < span && isExternalName n)
+ (reverse$ sortBy (compare `on` (nameSrcSpan.idName))
+ globals)
+ in decl
-- | Find the Module corresponding to a FilePath
findModuleFromFile :: HscEnv -> FilePath -> Maybe Module
obtainTerm1 :: HscEnv -> Bool -> Maybe Type -> a -> IO Term
obtainTerm1 hsc_env force mb_ty x =
- cvObtainTerm hsc_env force mb_ty (unsafeCoerce# x)
+ cvObtainTerm hsc_env maxBound force mb_ty (unsafeCoerce# x)
+
+obtainTermB :: HscEnv -> Int -> Bool -> Id -> IO Term
+obtainTermB hsc_env bound force id = do
+ hv <- Linker.getHValue hsc_env (varName id)
+ cvObtainTerm hsc_env bound force (Just$ idType id) hv
obtainTerm :: HscEnv -> Bool -> Id -> IO Term
obtainTerm hsc_env force id = do
hv <- Linker.getHValue hsc_env (varName id)
- cvObtainTerm hsc_env force (Just$ idType id) hv
+ cvObtainTerm hsc_env maxBound force (Just$ idType id) hv
-- Uses RTTI to reconstruct the type of an Id, making it less polymorphic
reconstructType :: HscEnv -> Bool -> Id -> IO (Maybe Type)