-dsExpr (HsLitOut (HsString s) _)
- | _NULL_ s
- = returnDs (mk_nil_con charTy)
-
- | _LENGTH_ s == 1
- = let
- the_char = mkCon charDataCon [] [] [LitArg (MachChar (_HEAD_ s))]
- the_nil = mk_nil_con charTy
- in
- mkConDs consDataCon [charTy] [the_char, the_nil]
-
--- "_" => build (\ c n -> c 'c' n) -- LATER
-
--- "str" ==> build (\ c n -> foldr charTy T c n "str")
-
-{- LATER:
-dsExpr (HsLitOut (HsString str) _)
- = newTyVarsDs [alphaTyVar] `thenDs` \ [new_tyvar] ->
- let
- new_ty = mkTyVarTy new_tyvar
- in
- newSysLocalsDs [
- charTy `mkFunTy` (new_ty `mkFunTy` new_ty),
- new_ty,
- mkForallTy [alphaTyVar]
- ((charTy `mkFunTy` (alphaTy `mkFunTy` alphaTy))
- `mkFunTy` (alphaTy `mkFunTy` alphaTy))
- ] `thenDs` \ [c,n,g] ->
- returnDs (mkBuild charTy new_tyvar c n g (
- foldl App
- (CoTyApp (CoTyApp (Var foldrId) charTy) new_ty) *** ensure non-prim type ***
- [VarArg c,VarArg n,LitArg (NoRepStr str)]))
--}
-
--- otherwise, leave it as a NoRepStr;
--- the Core-to-STG pass will wrap it in an application of "unpackCStringId".
-
-dsExpr (HsLitOut (HsString str) _)
- = returnDs (Lit (NoRepStr str))
-
-dsExpr (HsLitOut (HsLitLit s) ty)
- = returnDs ( mkCon data_con [] [] [LitArg (MachLitLit s kind)] )
- where
- (data_con, kind)
- = case (maybeBoxedPrimType ty) of
- Just (boxing_data_con, prim_ty)
- -> (boxing_data_con, typePrimRep prim_ty)
- Nothing
- -> pprError "ERROR: ``literal-literal'' not a single-constructor type: "
- (ppBesides [ppPStr s, ppStr "; type: ", ppr PprDebug ty])
-
-dsExpr (HsLitOut (HsInt i) _)
- = returnDs (Lit (NoRepInteger i))
-
-dsExpr (HsLitOut (HsFrac r) _)
- = returnDs (Lit (NoRepRational r))
-
--- others where we know what to do:
-
-dsExpr (HsLitOut (HsIntPrim i) _)
- = if (i >= toInteger minInt && i <= toInteger maxInt) then
- returnDs (Lit (mkMachInt i))
- else
- error ("ERROR: Int constant " ++ show i ++ out_of_range_msg)
-
-dsExpr (HsLitOut (HsFloatPrim f) _)
- = returnDs (Lit (MachFloat f))
- -- ToDo: range checking needed!
-
-dsExpr (HsLitOut (HsDoublePrim d) _)
- = returnDs (Lit (MachDouble d))
- -- ToDo: range checking needed!
-
-dsExpr (HsLitOut (HsChar c) _)
- = returnDs ( mkCon charDataCon [] [] [LitArg (MachChar c)] )
-
-dsExpr (HsLitOut (HsCharPrim c) _)
- = returnDs (Lit (MachChar c))
-
-dsExpr (HsLitOut (HsStringPrim s) _)
- = returnDs (Lit (MachStr s))