-
Notifications
You must be signed in to change notification settings - Fork 244
/
Copy pathghcide-1.8-unboxed-tuple-fix-issue-1455.patch
77 lines (75 loc) · 3.12 KB
/
ghcide-1.8-unboxed-tuple-fix-issue-1455.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
diff --git a/src/Development/IDE/Core/Compile.hs b/src/Development/IDE/Core/Compile.hs
index e6094a47..c19b61f1 100644
--- a/src/Development/IDE/Core/Compile.hs
+++ b/src/Development/IDE/Core/Compile.hs
@@ -137,6 +137,15 @@ import GHC.Hs (LEpaComment)
import qualified GHC.Types.Error as Error
#endif
+import StgSyn
+import FastString
+import Unique
+import CostCentre
+import Data.Either
+import CoreSyn
+import CoreToStg
+import SimplStg
+
-- | Given a string buffer, return the string (after preprocessing) and the 'ParsedModule'.
parseModule
:: IdeOptions
@@ -272,9 +281,38 @@ captureSplicesAndDeps TypecheckHelpers{..} env k = do
stg_expr
[] Nothing
#else
+ {- Create a temporary binding and convert to STG -}
+ ; let bco_tmp_id = mkSysLocal (fsLit "BCO_toplevel")
+ (mkPseudoUniqueE 0)
+ (exprType prepd_expr)
+ ; (binds, _) <-
+ myCoreToStg hsc_env
+ (icInteractiveModule (hsc_IC hsc_env))
+ [NonRec bco_tmp_id prepd_expr]
+
+ ; let (_strings, lifted_binds) = partitionEithers $ do -- list monad
+ bnd <- binds
+ case bnd of
+ StgTopLifted (StgNonRec i expr) -> [Right (i, expr)]
+ StgTopLifted (StgRec bnds) -> map Right bnds
+ StgTopStringLit b str -> [Left (b, str)]
+
+ ; let stg_expr = case lifted_binds of
+ [(_i, e)] -> e
+ _ ->
+ StgRhsClosure noExtFieldSilent
+ dontCareCCS
+ ReEntrant
+ []
+ (StgLet noExtFieldSilent
+ (StgRec lifted_binds)
+ (StgApp bco_tmp_id []))
+
{- Convert to BCOs -}
; bcos <- coreExprToBCOs hsc_env
- (icInteractiveModule (hsc_IC hsc_env)) prepd_expr
+ (icInteractiveModule (hsc_IC hsc_env))
+ bco_tmp_id
+ stg_expr
#endif
-- Exclude wired-in names because we may not have read
@@ -1705,3 +1743,16 @@ pathToModuleName = mkModuleName . map rep
rep c | isPathSeparator c = '_'
rep ':' = '_'
rep c = c
+
+myCoreToStg :: HscEnv -> Module -> CoreProgram
+ -> IO ( [StgTopBinding] -- output program
+ , CollectedCCs ) -- CAF cost centre info (declared and used)
+myCoreToStg hsc_env this_mod prepd_binds = do
+ let (stg_binds, cost_centre_info)
+ = {-# SCC "Core2Stg" #-}
+ coreToStg (hsc_dflags hsc_env) this_mod prepd_binds
+ stg_binds2
+ <- {-# SCC "Stg2Stg" #-}
+ stg2stg hsc_env this_mod stg_binds
+
+ return (stg_binds2, cost_centre_info)