+%************************************************************************
+%* *
+\subsubsection{Literals}
+%* *
+%************************************************************************
+
+When literals occur we have to make sure
+that the types and classes they involve
+are made available.
+
+\begin{code}
+litFVs (HsChar c)
+ = checkRn (inCharRange c) (bogusCharError c) `thenRn_`
+ returnRn (unitFV charTyCon_name)
+
+litFVs (HsCharPrim c) = returnRn (unitFV (getName charPrimTyCon))
+litFVs (HsString s) = returnRn (mkFVs [listTyCon_name, charTyCon_name])
+litFVs (HsStringPrim s) = returnRn (unitFV (getName addrPrimTyCon))
+litFVs (HsInt i) = returnRn (unitFV (getName intTyCon))
+litFVs (HsIntPrim i) = returnRn (unitFV (getName intPrimTyCon))
+litFVs (HsFloatPrim f) = returnRn (unitFV (getName floatPrimTyCon))
+litFVs (HsDoublePrim d) = returnRn (unitFV (getName doublePrimTyCon))
+litFVs (HsLitLit l bogus_ty) = lookupOrigName cCallableClass_RDR `thenRn` \ cc ->
+ returnRn (unitFV cc)
+litFVs lit = pprPanic "RnExpr.litFVs" (ppr lit) -- HsInteger and HsRat only appear
+ -- in post-typechecker translations
+
+rnOverLit (HsIntegral i from_integer_name)
+ = lookupSyntaxName from_integer_name `thenRn` \ from_integer_name' ->
+ if inIntRange i then
+ returnRn (HsIntegral i from_integer_name', unitFV from_integer_name')
+ else
+ lookupOrigNames [plusInteger_RDR, timesInteger_RDR] `thenRn` \ ns ->
+ -- Big integer literals are built, using + and *,
+ -- out of small integers (DsUtils.mkIntegerLit)
+ -- [NB: plusInteger, timesInteger aren't rebindable...
+ -- they are used to construct the argument to fromInteger,
+ -- which is the rebindable one.]
+ returnRn (HsIntegral i from_integer_name', ns `addOneFV` from_integer_name')
+
+rnOverLit (HsFractional i from_rat_name)
+ = lookupSyntaxName from_rat_name `thenRn` \ from_rat_name' ->
+ lookupOrigNames [ratioDataCon_RDR, plusInteger_RDR, timesInteger_RDR] `thenRn` \ ns ->
+ -- We have to make sure that the Ratio type is imported with
+ -- its constructor, because literals of type Ratio t are
+ -- built with that constructor.
+ -- The Rational type is needed too, but that will come in
+ -- when fractionalClass does.
+ -- The plus/times integer operations may be needed to construct the numerator
+ -- and denominator (see DsUtils.mkIntegerLit)
+ returnRn (HsFractional i from_rat_name', ns `addOneFV` from_rat_name')
+\end{code}
+
+%************************************************************************
+%* *
+\subsubsection{Assertion utils}
+%* *
+%************************************************************************
+
+\begin{code}
+mkAssertExpr :: RnMS (RenamedHsExpr, FreeVars)
+mkAssertExpr =
+ lookupOrigName assertErr_RDR `thenRn` \ name ->
+ getSrcLocRn `thenRn` \ sloc ->
+
+ -- if we're ignoring asserts, return (\ _ e -> e)
+ -- if not, return (assertError "src-loc")
+
+ if opt_IgnoreAsserts then
+ getUniqRn `thenRn` \ uniq ->
+ let
+ vname = mkSysLocalName uniq SLIT("v")
+ expr = HsLam ignorePredMatch
+ loc = nameSrcLoc vname
+ ignorePredMatch = mkSimpleMatch [WildPatIn, VarPatIn vname] (HsVar vname) placeHolderType loc
+ in
+ returnRn (expr, unitFV name)
+ else
+ let
+ expr =
+ HsApp (HsVar name)
+ (HsLit (HsString (_PK_ (showSDoc (ppr sloc)))))
+
+ in
+ returnRn (expr, unitFV name)
+
+\end{code}
+
+%************************************************************************
+%* *
+\subsubsection{Errors}
+%* *
+%************************************************************************
+