-
-closureSingleEntry (MkClosureInfo _ (LFThunk _ _ upd _) _) = not upd
-closureSingleEntry other_closure = False
-\end{code}
-
-Note: @closureType@ returns appropriately specialised tycon and
-datacons.
-\begin{code}
-closureType :: ClosureInfo -> Maybe (TyCon, [Type], [Id])
-
--- First, a turgid special case. When we are generating the
--- standard code and info-table for Vaps (which is done when the function
--- defn is encountered), we don't have a convenient Id to hand whose
--- type is that of (f x y z). So we need to figure out the type
--- rather than take it from the Id. The Id is probably just "f"!
-
-closureType (MkClosureInfo id (LFThunk _ _ _ (VapThunk fun_id args _)) _)
- = splitAlgTyConApp_maybe (fun_result_ty (length args) (idType fun_id))
-
-closureType (MkClosureInfo id lf _) = splitAlgTyConApp_maybe (idType id)
-\end{code}
-
-@closureReturnsUnpointedType@ is used to check whether a closure, {\em
-once it has eaten its arguments}, returns an unboxed type. For
-example, the closure for a function:
-\begin{verbatim}
- f :: Int -> Int#
-\end{verbatim}
-returns an unboxed type. This is important when dealing with stack
-overflow checks.
-\begin{code}
-closureReturnsUnpointedType :: ClosureInfo -> Bool
-
-closureReturnsUnpointedType (MkClosureInfo fun_id (LFReEntrant _ arity _) _)
- = isUnpointedType (fun_result_ty arity (idType fun_id))
-
-closureReturnsUnpointedType other_closure = False
- -- All non-function closures aren't functions,
- -- and hence are boxed, since they are heap alloc'd
-
--- fun_result_ty is a disgusting little bit of code that finds the result
--- type of a function application. It looks "through" new types.
--- We don't have type args available any more, so we are pretty cavilier,
--- and quite possibly plain wrong. Let's hope it doesn't matter if we are!
-
-fun_result_ty arity ty
- | arity <= n_arg_tys
- = mkFunTys (drop arity arg_tys) res_ty
-
- | otherwise
- = case splitAlgTyConApp_maybe res_ty of
- Nothing -> pprPanic "fun_result_ty:" (hsep [int arity,
- ppr ty])
-
- Just (tycon, tycon_arg_tys, [con]) | isNewTyCon tycon
- -> fun_result_ty (arity - n_arg_tys) rep_ty
- where
- ([rep_ty], _) = splitFunTys (applyTys (idType con) tycon_arg_tys)
- Just _ ->
- pprPanic "fun_result_ty:" (hsep [int arity,
- ppr ty,
- ppr res_ty])
- where
- (_, rho_ty) = splitForAllTys ty
- (arg_tys, res_ty) = splitFunTys rho_ty
- n_arg_tys = length arg_tys
-\end{code}
-
-\begin{code}
-closureSemiTag :: ClosureInfo -> Int
-
-closureSemiTag (MkClosureInfo _ lf_info _)
- = case lf_info of
- LFCon data_con _ -> dataConTag data_con - fIRST_TAG
- LFTuple _ _ -> 0
- _ -> fromInteger oTHER_TAG
+closureSingleEntry (ClosureInfo { closureLFInfo = LFThunk _ _ upd _ _}) = not upd
+closureSingleEntry other_closure = False
+
+closureReEntrant :: ClosureInfo -> Bool
+closureReEntrant (ClosureInfo { closureLFInfo = LFReEntrant _ _ _ _ }) = True
+closureReEntrant other_closure = False
+
+isConstrClosure_maybe :: ClosureInfo -> Maybe DataCon
+isConstrClosure_maybe (ConInfo { closureCon = data_con }) = Just data_con
+isConstrClosure_maybe _ = Nothing
+
+closureFunInfo :: ClosureInfo -> Maybe (Int, ArgDescr)
+closureFunInfo (ClosureInfo { closureLFInfo = LFReEntrant _ arity _ arg_desc})
+ = Just (arity, arg_desc)
+closureFunInfo _
+ = Nothing