From: sof Date: Tue, 30 Mar 1999 11:26:24 +0000 (+0000) Subject: [project @ 1999-03-30 11:26:18 by sof] X-Git-Tag: Approximately_9120_patches~6337 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=db85bf1cc51d2e428175ccf2f3608014e9459ba8;p=ghc-hetmet.git [project @ 1999-03-30 11:26:18 by sof] New compiler option -fignore-asserts: Causes (PrelGHC.assert pred expr) to be rewritten to (expr). --- diff --git a/ghc/compiler/main/CmdLineOpts.lhs b/ghc/compiler/main/CmdLineOpts.lhs index 821882c..08aa38f 100644 --- a/ghc/compiler/main/CmdLineOpts.lhs +++ b/ghc/compiler/main/CmdLineOpts.lhs @@ -60,6 +60,7 @@ module CmdLineOpts ( opt_HiMap, opt_HiVersion, opt_IgnoreIfacePragmas, + opt_IgnoreAsserts, opt_IrrefutableTuples, opt_LiberateCaseThreshold, opt_MaxContextReductionDepth, @@ -328,6 +329,7 @@ opt_GlasgowExts = lookUp SLIT("-fglasgow-exts") opt_HiMap = lookup_str "-himap=" -- file saying where to look for .hi files opt_HiVersion = lookup_def_int "-fhi-version=" 0 -- what version we're compiling. opt_IgnoreIfacePragmas = lookUp SLIT("-fignore-interface-pragmas") +opt_IgnoreAsserts = lookUp SLIT("-fignore-asserts") opt_IrrefutableTuples = lookUp SLIT("-firrefutable-tuples") opt_MaxContextReductionDepth = lookup_def_int "-fcontext-stack" mAX_CONTEXT_REDUCTION_DEPTH opt_MultiParamClasses = opt_GlasgowExts diff --git a/ghc/compiler/rename/RnExpr.lhs b/ghc/compiler/rename/RnExpr.lhs index b990ab7..16f9da4 100644 --- a/ghc/compiler/rename/RnExpr.lhs +++ b/ghc/compiler/rename/RnExpr.lhs @@ -25,7 +25,7 @@ import RdrHsSyn import RnHsSyn import RnMonad import RnEnv -import CmdLineOpts ( opt_GlasgowExts ) +import CmdLineOpts ( opt_GlasgowExts, opt_IgnoreAsserts ) import BasicTypes ( Fixity(..), FixityDirection(..) ) import PrelInfo ( numClass_RDR, fractionalClass_RDR, eqClass_RDR, ccallableClass_RDR, creturnableClass_RDR, @@ -36,7 +36,9 @@ import PrelInfo ( numClass_RDR, fractionalClass_RDR, eqClass_RDR, import TysPrim ( charPrimTyCon, addrPrimTyCon, intPrimTyCon, floatPrimTyCon, doublePrimTyCon ) -import Name ( nameUnique, isLocallyDefined, NamedThing(..) ) +import Name ( nameUnique, isLocallyDefined, NamedThing(..) + , mkSysLocalName, nameSrcLoc + ) import NameSet import UniqFM ( isNullUFM ) import FiniteMap ( elemFM ) @@ -741,11 +743,30 @@ mkAssertExpr = newImportedGlobalFromRdrName assertErr_RDR `thenRn` \ name -> addOccurrenceName name `thenRn_` getSrcLocRn `thenRn` \ sloc -> - let - expr = HsApp (HsVar name) + + -- 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 = Match [] [WildPatIn, VarPatIn vname] Nothing + (GRHSs [GRHS [ExprStmt (HsVar vname) loc] loc] + EmptyBinds Nothing) + in + returnRn expr + else + let + expr = + HsApp (HsVar name) (HsLit (HsString (_PK_ (showSDoc (ppr sloc))))) - in - returnRn expr + + in + returnRn expr + \end{code} %************************************************************************ diff --git a/ghc/compiler/rename/RnMonad.lhs b/ghc/compiler/rename/RnMonad.lhs index 456ce08..1d3578a 100644 --- a/ghc/compiler/rename/RnMonad.lhs +++ b/ghc/compiler/rename/RnMonad.lhs @@ -705,6 +705,15 @@ newInstUniq key (RnDown {rn_ns = names_var}) l_down in writeMutVarSST names_var (us, mapInst', cache) `thenSST_` returnSST uniq + +getUniqRn :: RnM s d Unique +getUniqRn (RnDown {rn_ns = names_var}) l_down + = readMutVarSST names_var `thenSST` \ (us, mapInst, cache) -> + let + (us1,us') = splitUniqSupply us + in + writeMutVarSST names_var (us', mapInst, cache) `thenSST_` + returnSST (uniqFromSupply us1) \end{code} ================ Occurrences ===================== diff --git a/ghc/docs/users_guide/glasgow_exts.vsgml b/ghc/docs/users_guide/glasgow_exts.vsgml index 07f2049..9d0afcd 100644 --- a/ghc/docs/users_guide/glasgow_exts.vsgml +++ b/ghc/docs/users_guide/glasgow_exts.vsgml @@ -1,5 +1,5 @@ % -% $Id: glasgow_exts.vsgml,v 1.7 1999/03/26 19:50:31 sof Exp $ +% $Id: glasgow_exts.vsgml,v 1.8 1999/03/30 11:26:24 sof Exp $ % % GHC Language Extensions. % @@ -1493,8 +1493,8 @@ stands, unless there are convincing reasons to change it.