[project @ 2002-11-22 06:54:05 by matthewc]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcSplice.lhs
index 18f6996..94e9c0e 100644 (file)
@@ -209,19 +209,17 @@ runMetaD :: TypecheckedHsExpr     -- Of type Q [Dec]
         -> TcM [Meta.Dec]      -- Of type [Dec]
 runMetaD e = runMeta e
 
--- Warning: if Q is anything other than IO, we need to change this
 tcRunQ :: Meta.Q a -> TcM a
-tcRunQ thing = ioToTcRn thing
-
+tcRunQ thing = ioToTcRn (Meta.runQ thing)
 
 runMeta :: TypecheckedHsExpr   -- Of type X
        -> TcM t                -- Of type t
 runMeta expr
   = getTopEnv          `thenM` \ top_env ->
+    getGblEnv          `thenM` \ tcg_env ->
     getEps             `thenM` \ eps ->
     getNameCache       `thenM` \ name_cache -> 
     getModule          `thenM` \ this_mod ->
-    getGlobalRdrEnv    `thenM` \ rdr_env -> 
     let
        ghci_mode = top_mode top_env
 
@@ -230,17 +228,12 @@ runMeta expr
 
        pcs = PCS { pcs_nc = name_cache, pcs_EPS = eps }
 
-       print_unqual = unQualInScope rdr_env
+       type_env = tcg_type_env tcg_env
+       rdr_env  = tcg_rdr_env tcg_env
     in
-    if (ghci_mode == OneShot) then
-       failWithTc (ptext SLIT("You must use --make or --interactive to run splice expressions"))
-       -- The reason for this is that the demand-linker doesn't have
-       -- enough information available to link all the things that
-       -- are needed when you try to run a splice
-    else
-
-    ioToTcRn (HscMain.compileExpr hsc_env pcs this_mod 
-                                 print_unqual expr) `thenM` \ hval ->
+    ioToTcRn (HscMain.compileExpr 
+               hsc_env pcs this_mod 
+               rdr_env type_env expr)  `thenM` \ hval ->
 
     tryM (tcRunQ (unsafeCoerce# hval)) `thenM` \ either_tval ->