projects
/
ghc-hetmet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
61e253e
)
Be more careful when calculating the enclosing top level declaration of a srcspan
author
Pepe Iborra
<mnislaih@gmail.com>
Mon, 27 Aug 2007 11:44:37 +0000
(11:44 +0000)
committer
Pepe Iborra
<mnislaih@gmail.com>
Mon, 27 Aug 2007 11:44:37 +0000
(11:44 +0000)
compiler/main/InteractiveEval.hs
patch
|
blob
|
history
diff --git
a/compiler/main/InteractiveEval.hs
b/compiler/main/InteractiveEval.hs
index
56dfbbd
..
e189a58
100644
(file)
--- a/
compiler/main/InteractiveEval.hs
+++ b/
compiler/main/InteractiveEval.hs
@@
-78,6
+78,7
@@
import GHC.Exts
import Data.Array
import Control.Exception as Exception
import Control.Concurrent
import Data.Array
import Control.Exception as Exception
import Control.Concurrent
+import Data.List (sortBy)
import Data.IORef
import Foreign.StablePtr
import Data.IORef
import Foreign.StablePtr
@@
-131,7
+132,7
@@
data History
= History {
historyApStack :: HValue,
historyBreakInfo :: BreakInfo,
= History {
historyApStack :: HValue,
historyBreakInfo :: BreakInfo,
- historyEnclosingDecl :: Name
+ historyEnclosingDecl :: Id
-- ^^ A cache of the enclosing top level declaration, for convenience
}
-- ^^ A cache of the enclosing top level declaration, for convenience
}
@@
-154,16
+155,18
@@
getHistorySpan hsc_env hist =
_ -> panic "getHistorySpan"
-- | Finds the enclosing top level function name
_ -> 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
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
-- | Find the Module corresponding to a FilePath
findModuleFromFile :: HscEnv -> FilePath -> Maybe Module