More wibbles to deriving error messages
[ghc-hetmet.git] / compiler / stgSyn / CoreToStg.lhs
index 6dd0255..370393b 100644 (file)
@@ -34,6 +34,8 @@ import Outputable
 import MonadUtils
 import FastString
 import Util
+import ForeignCall
+import PrimOp          ( PrimCall(..) )
 \end{code}
 
 %************************************************************************
@@ -435,7 +437,7 @@ mkStgAltType bndr alts
                    | isUnLiftedTyCon tc     -> PrimAlt tc
                    | isHiBootTyCon tc       -> look_for_better_tycon
                    | isAlgTyCon tc          -> AlgAlt tc
-                   | otherwise              -> ASSERT( _is_poly_alt_tycon tc )
+                   | otherwise              -> ASSERT2( _is_poly_alt_tycon tc, ppr tc )
                                                PolyAlt
        Nothing                              -> PolyAlt
 
@@ -443,7 +445,7 @@ mkStgAltType bndr alts
    _is_poly_alt_tycon tc
        =  isFunTyCon tc
         || isPrimTyCon tc   -- "Any" is lifted but primitive
-       || isOpenTyCon tc   -- Type family; e.g. arising from strict
+       || isFamilyTyCon tc   -- Type family; e.g. arising from strict
                            -- function application where argument has a
                            -- type-family type
 
@@ -526,10 +528,20 @@ coreToStgApp _ f args = do
        res_ty = exprType (mkApps (Var f) args)
        app = case idDetails f of
                DataConWorkId dc | saturated -> StgConApp dc args'
+
+               -- Some primitive operator that might be implemented as a library call.
                PrimOpId op      -> ASSERT( saturated )
                                    StgOpApp (StgPrimOp op) args' res_ty
+
+               -- A call to some primitive Cmm function.
+               FCallId (CCall (CCallSpec (StaticTarget lbl (Just pkgId)) PrimCallConv _))
+                                -> ASSERT( saturated )
+                                   StgOpApp (StgPrimCallOp (PrimCall lbl pkgId)) args' res_ty
+
+               -- A regular foreign call.
                FCallId call     -> ASSERT( saturated )
                                    StgOpApp (StgFCallOp call (idUnique f)) args' res_ty
+
                 TickBoxOpId {}   -> pprPanic "coreToStg TickBox" $ ppr (f,args')
                _other           -> StgApp f args'
 
@@ -1108,7 +1120,7 @@ myCollectArgs expr
     go (Cast e _)       as = go e as
     go (Note _ e)       as = go e as
     go (Lam b e)        as
-       | isTyVar b         = go e as   -- Note [Collect args]
+       | isTyCoVar b         = go e as -- Note [Collect args]
     go _                _  = pprPanic "CoreToStg.myCollectArgs" (ppr expr)
 \end{code}