[project @ 2001-08-09 11:32:15 by simonmar]
[ghc-hetmet.git] / ghc / compiler / codeGen / CgCon.lhs
index 5ad6264..aa2aec3 100644 (file)
@@ -45,7 +45,8 @@ import ClosureInfo    ( mkConLFInfo, mkLFArgument,
 import CostCentre      ( currentOrSubsumedCCS, dontCareCCS, CostCentreStack,
                          currentCCS )
 import DataCon         ( DataCon, dataConName, dataConTag, 
-                         isUnboxedTupleCon, isNullaryDataCon, dataConId, dataConWrapId
+                         isUnboxedTupleCon, isNullaryDataCon, dataConId, 
+                         dataConWrapId, dataConRepArity
                        )
 import Id              ( Id, idName, idPrimRep )
 import Literal         ( Literal(..) )
@@ -68,7 +69,14 @@ cgTopRhsCon :: Id            -- Name of thing bound to this RHS
            -> [StgArg]         -- Args
            -> FCode (Id, CgIdInfo)
 cgTopRhsCon id con args
-  = ASSERT(not dynamic_con_or_args)    -- checks for litlit args too
+  = ASSERT(not (isDllConApp con args)) -- checks for litlit args too
+    ASSERT(length args == dataConRepArity con)
+    let
+       name          = idName id
+       closure_label = mkClosureLabel name
+       lf_info       = mkConLFInfo con
+    in
+
     (
        -- LAY IT OUT
     getArgAmodes args          `thenFC` \ amodes ->
@@ -82,22 +90,13 @@ cgTopRhsCon id con args
     absC (CStaticClosure
            closure_label               -- Labelled with the name on lhs of defn
            closure_info                -- Closure is static
-           top_ccc
+           (mkCCostCentreStack dontCareCCS) -- because it's static data
            (map fst amodes_w_offsets)) -- Sorted into ptrs first, then nonptrs
 
     ) `thenC`
 
        -- RETURN
     returnFC (id, stableAmodeIdInfo id (CLbl closure_label PtrRep) lf_info)
-  where
-    lf_info        = mkConLFInfo    con
-    closure_label   = mkClosureLabel name
-    name            = idName id
-
-    top_ccc = mkCCostCentreStack dontCareCCS -- because it's static data
-
-    -- stuff needed by the assert pred only.
-    dynamic_con_or_args = isDllConApp con args
 \end{code}
 
 %************************************************************************
@@ -271,7 +270,8 @@ sure the @amodes@ passed don't conflict with each other.
 cgReturnDataCon :: DataCon -> [CAddrMode] -> Code
 
 cgReturnDataCon con amodes
-  = getEndOfBlockInfo  `thenFC` \ (EndOfBlockInfo args_sp sequel) ->
+  = ASSERT(length amodes == dataConRepArity con)
+    getEndOfBlockInfo  `thenFC` \ (EndOfBlockInfo args_sp sequel) ->
 
     case sequel of