-- The above warning supression flag is a temporary kludge.
-- While working on this module you are encouraged to remove it and fix
-- any warnings in the module. See
--- http://hackage.haskell.org/trac/ghc/wiki/CodingStyle#Warnings
+-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
-- for details
module IlxGen( ilxGen ) where
importsType2 env (TyConApp tc args) =importsTyCon env tc . importsTypeArgs2 env args
importsType2 env (FunTy arg res) = importsType env arg . importsType2 env res
importsType2 env (ForAllTy tv body_ty) = importsType2 env body_ty
-importsType2 env (NoteTy _ ty) = importsType2 env ty
importsType2 _ _ = panic "IlxGen.lhs: importsType2 ty"
importsTypeArgs2 env tys = foldR (importsType2 env) tys
importsTyConDataConType2 env (TyConApp tc args) = importsTyConDataConTypeTyCon env tc . importsTyConDataConTypeArgs2 env args
importsTyConDataConType2 env (FunTy arg res) = importsTyConDataConType env arg . importsTyConDataConType2 env res
importsTyConDataConType2 env (ForAllTy tv body_ty) = importsTyConDataConType2 env body_ty
-importsTyConDataConType2 env (NoteTy _ ty) = importsTyConDataConType2 env ty
importsTyConDataConType2 _ _ = panic "IlxGen.lhs: importsTyConDataConType2 ty"
importsTyConDataConTypeArgs2 env tys = foldR (importsTyConDataConType2 env) tys
-- This part strips off at most "max" term applications or one type application
get_type_args 0 args env funty = ([],[],env,args,funty)
- get_type_args max args env (NoteTy _ ty) =
- trace "IlxGen Internal Error: non representation type passed to get_args" (get_type_args max args env ty)
get_type_args max ((arg@(StgTypeArg v)):rest) env (ForAllTy tv rem_funty)
= if isIlxTyVar tv then
let env2 = extendIlxEnvWithFormalTyVars env [tv] in
get_type_args _ (StgTypeArg _:_) _ _ = trace "IlxGen Internal Error: get_type_args could not get ForAllTy for corresponding arg" ([],[],env,[],funty)
get_type_args _ args env funty = ([],[],env,args,funty)
- get_term_args n max args env (NoteTy _ ty)
- -- Skip NoteTy types
- = trace "IlxGen Internal Error: non representation type passed to get_term_args" (get_term_args n max args env ty)
get_term_args n 0 args env funty
-- Stop if we've hit the maximum number of ILX arguments to apply n one hit.
= ([],[],env,args,funty)
\begin{code}
-isVoidIlxRepType (NoteTy _ ty) = isVoidIlxRepType ty
isVoidIlxRepType (TyConApp tc _) | (tyConPrimRep tc == VoidRep) = True
isVoidIlxRepType (TyConApp tc tys)
= isUnboxedTupleTyCon tc && null (filter (not. isVoidIlxRepType) tys)
--- Get rid of all NoteTy and NewTy artifacts
+-- Get rid of all NewTy artifacts
deepIlxRepType :: Type -> Type
deepIlxRepType (FunTy l r)
= FunTy (deepIlxRepType l) (deepIlxRepType r)
TyConApp tc (map deepIlxRepType tys)
deepIlxRepType (AppTy f x) = AppTy (deepIlxRepType f) (deepIlxRepType x)
deepIlxRepType (ForAllTy b ty) = ForAllTy b (deepIlxRepType ty)
-deepIlxRepType (NoteTy _ ty) = deepIlxRepType ty
deepIlxRepType (PredTy p) = deepIlxRepType (predTypeRep p)
deepIlxRepType ty@(TyVarTy tv) = ty
= ilxComment (text "higher order type var " <+> pprId tv) <+>
pprIlxFunTy (text "class [mscorlib]System.Object") (ilxTypeR env body_ty)
-ilxTypeR env (NoteTy _ ty)
- = trace "WARNING! non-representation type given to ilxTypeR: see generated ILX for context where this occurs"
- (vcat [text "/* WARNING! non-representation type given to ilxTypeR! */",
- ilxTypeR env ty ])
-
pprIlxFunTy dom ran = parens (hsep [text "func",parens dom,text "-->", ran])
ilxTyConApp env tcon args =