+ locals <- readLEnv local_vars
+ let
+ (vars, vals) = unzip
+ [(var, (Var v, Var v')) | var <- varSetElems fvs
+ , Just (v,v') <- [lookupVarEnv locals var]]
+ vtys <- mapM (vectType . varType) vars
+
+ (vty, repr_tycon, repr_tyargs, repr_datacon) <- mk_env_ty vtys
+ lty <- mkPArrayType vty
+
+ return $ CEnvInfo {
+ cenv_vars = vars
+ , cenv_values = vals
+ , cenv_vty = vty
+ , cenv_lty = lty
+ , cenv_repr_tycon = repr_tycon
+ , cenv_repr_tyargs = repr_tyargs
+ , cenv_repr_datacon = repr_datacon
+ }
+ where
+ mk_env_ty [vty]
+ = return (vty, error "absent cinfo_repr_tycon"
+ , error "absent cinfo_repr_tyargs"
+ , error "absent cinfo_repr_datacon")
+
+ mk_env_ty vtys
+ = do
+ let ty = mkCoreTupTy vtys
+ (repr_tc, repr_tyargs) <- lookupPArrayFamInst ty
+ let [repr_con] = tyConDataCons repr_tc
+ return (ty, repr_tc, repr_tyargs, repr_con)
+
+
+
+mkClosureEnvs :: CEnvInfo -> CoreExpr -> (CoreExpr, CoreExpr)
+mkClosureEnvs info lc
+ | [] <- vals
+ = (Var unitDataConId, mkApps (Var $ dataConWrapId (cenv_repr_datacon info))
+ [lc, Var unitDataConId])
+
+ | [(vval, lval)] <- vals
+ = (vval, lval)