Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC
Commits:
-
d068471a
by Rodrigo Mesquita at 2026-05-12T16:00:01+01:00
-
261d1946
by Rodrigo Mesquita at 2026-05-12T16:49:58+01:00
10 changed files:
- compiler/GHC/Builtin.hs
- compiler/GHC/Builtin/KnownKeys.hs
- compiler/GHC/Builtin/KnownOccs.hs
- compiler/GHC/Builtin/TH.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/Iface/Binary.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Unit.hs
- compiler/GHC/Unit/Types.hs
- libraries/ghc-internal/src/GHC/Internal/Classes/IP.hs
Changes:
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | module GHC.Builtin (
|
| 24 | 24 | -- * Main exports
|
| 25 | - wiredInNames, wiredInIds, ghcPrimIds, allKnownOccs,
|
|
| 25 | + wiredInNames, wiredInIds, ghcPrimIds,
|
|
| 26 | 26 | knownKeyTable, knownKeyOccMap, knownKeyUniqMap,
|
| 27 | 27 | knownKeyOccName, knownKeyOccName_maybe,
|
| 28 | 28 | |
| ... | ... | @@ -53,9 +53,7 @@ import GHC.Builtin.WiredIn.Types |
| 53 | 53 | import GHC.Builtin.WiredIn.TypeLits ( typeNatTyCons )
|
| 54 | 54 | import GHC.Builtin.WiredIn.Ids ( wiredInIds, ghcPrimIds )
|
| 55 | 55 | import GHC.Builtin.WiredIn.Prim
|
| 56 | -import GHC.Builtin.TH ( templateHaskellNames, thKnownOccs )
|
|
| 57 | 56 | import GHC.Builtin.KnownKeys
|
| 58 | -import GHC.Builtin.KnownOccs( knownOccs, knownOccRdrNames )
|
|
| 59 | 57 | |
| 60 | 58 | import GHC.Core.ConLike ( ConLike(..) )
|
| 61 | 59 | import GHC.Core.DataCon
|
| ... | ... | @@ -64,7 +62,6 @@ import GHC.Core.TyCon |
| 64 | 62 | |
| 65 | 63 | import GHC.Types.Id
|
| 66 | 64 | import GHC.Types.Name
|
| 67 | -import GHC.Types.Name.Reader( rdrNameOcc )
|
|
| 68 | 65 | import GHC.Types.Name.Env
|
| 69 | 66 | import GHC.Types.Unique
|
| 70 | 67 | import GHC.Types.Unique.FM
|
| ... | ... | @@ -419,15 +416,6 @@ To make `wombat` into a known-key name, do the following. |
| 419 | 416 | in scope by saying `import M( wombat )`.
|
| 420 | 417 | -}
|
| 421 | 418 | |
| 422 | -allKnownOccs :: OccSet
|
|
| 423 | --- Used only for
|
|
| 424 | --- (a) sanity checks
|
|
| 425 | --- (b) suppressing unused-import warnings in `ghc-internal` and `base`
|
|
| 426 | -allKnownOccs
|
|
| 427 | - = mkOccSet thKnownOccs `unionOccSets`
|
|
| 428 | - mkOccSet knownOccs `unionOccSets`
|
|
| 429 | - mkOccSet (map rdrNameOcc knownOccRdrNames)
|
|
| 430 | - |
|
| 431 | 419 | {-
|
| 432 | 420 | ************************************************************************
|
| 433 | 421 | * *
|
| ... | ... | @@ -565,10 +553,6 @@ wiredInNames |
| 565 | 553 | , map (idName . primOpWrapperId) allThePrimOps
|
| 566 | 554 | -- Actually the primop wrapper Ids have External Names, not WiredIn,
|
| 567 | 555 | -- but we still want to populate the OrigNameCache with them
|
| 568 | - |
|
| 569 | - -- ToDo: get rid of these
|
|
| 570 | - , basicKnownKeyNames
|
|
| 571 | - , templateHaskellNames
|
|
| 572 | 556 | ]
|
| 573 | 557 | -- All of the names associated with a wired-in TyCon.
|
| 574 | 558 | -- This includes the TyCon itself, its DataCons and promoted TyCons.
|
| ... | ... | @@ -24,52 +24,6 @@ the big-num package or (for plugins) the ghc package. |
| 24 | 24 | It's not necessary to know the uniques for these guys, only their names
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | -Note [Known-key names] <---- LEGACY VERSION
|
|
| 28 | -~~~~~~~~~~~~~~~~~~~~~~
|
|
| 29 | -It is *very* important that the compiler gives wired-in things and
|
|
| 30 | -things with "known-key" names the correct Uniques wherever they
|
|
| 31 | -occur. We have to be careful about this in exactly two places:
|
|
| 32 | - |
|
| 33 | - 1. When we parse some source code, renaming the AST better yield an
|
|
| 34 | - AST whose Names have the correct uniques
|
|
| 35 | - |
|
| 36 | - 2. When we read an interface file, the read-in gubbins better have
|
|
| 37 | - the right uniques
|
|
| 38 | - |
|
| 39 | -This is accomplished through a combination of mechanisms:
|
|
| 40 | - |
|
| 41 | - 1. When parsing source code, the RdrName-decorated AST has some
|
|
| 42 | - RdrNames which are Exact. These are wired-in RdrNames where
|
|
| 43 | - we could directly tell from the parsed syntax what Name to
|
|
| 44 | - use. For example, when we parse a [] in a type and ListTuplePuns
|
|
| 45 | - are enabled, we can just insert (Exact listTyConName :: RdrName).
|
|
| 46 | - |
|
| 47 | - This is just an optimisation: it would be equally valid to output
|
|
| 48 | - Orig RdrNames that correctly record the module (and package) that
|
|
| 49 | - we expect the final Name to come from. The name would be looked up
|
|
| 50 | - in the OrigNameCache (see point 3).
|
|
| 51 | - |
|
| 52 | - 2. The knownKeyNames (which consist of the basicKnownKeyNames from
|
|
| 53 | - the module, and those names reachable via the wired-in stuff from
|
|
| 54 | - GHC.Builtin.Types) are used to initialise the "OrigNameCache" in
|
|
| 55 | - GHC.Iface.Env. This initialization ensures that when the type checker
|
|
| 56 | - or renamer (both of which use GHC.Iface.Env) look up an original name
|
|
| 57 | - (i.e. a pair of a Module and an OccName) for a known-key name
|
|
| 58 | - they get the correct Unique.
|
|
| 59 | - |
|
| 60 | - This is the most important mechanism for ensuring that known-key
|
|
| 61 | - stuff gets the right Unique, and is why it is so important to
|
|
| 62 | - place your known-key names in the appropriate lists.
|
|
| 63 | - |
|
| 64 | - 3. For "infinite families" of known-key names (i.e. tuples and sums), we
|
|
| 65 | - have to be extra careful. Because there are an infinite number of
|
|
| 66 | - these things, we cannot add them to the list of known-key names
|
|
| 67 | - used to initialise the OrigNameCache. Instead, lookupOrigNameCache pretends
|
|
| 68 | - that these names are in the cache by using isInfiniteFamilyOrigName_maybe
|
|
| 69 | - before the actual lookup.
|
|
| 70 | - See Note [Infinite families of known-key names] for details.
|
|
| 71 | - |
|
| 72 | - |
|
| 73 | 27 | Note [Infinite families of known-key names]
|
| 74 | 28 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 75 | 29 | Infinite families of known-key things (e.g. tuples and sums) pose a tricky
|
| ... | ... | @@ -109,7 +63,6 @@ import GHC.Prelude |
| 109 | 63 | |
| 110 | 64 | import GHC.Builtin.Modules
|
| 111 | 65 | import GHC.Builtin.Uniques
|
| 112 | -import GHC.Builtin.TH( thKnownKeyTable )
|
|
| 113 | 66 | |
| 114 | 67 | import GHC.Unit.Types
|
| 115 | 68 | |
| ... | ... | @@ -169,8 +122,7 @@ See Note [Overview of known entities] in GHC.Builtin |
| 169 | 122 | |
| 170 | 123 | knownKeyTable :: [(OccName, KnownKey)]
|
| 171 | 124 | knownKeyTable
|
| 172 | - = thKnownKeyTable ++
|
|
| 173 | - [ (mkTcOcc "IO", ioTyConKey)
|
|
| 125 | + = [ (mkTcOcc "IO", ioTyConKey)
|
|
| 174 | 126 | |
| 175 | 127 | -- Classes
|
| 176 | 128 | , (mkTcOcc "Eq", eqClassKey)
|
| ... | ... | @@ -185,7 +137,8 @@ knownKeyTable |
| 185 | 137 | , (mkTcOcc "Ix", ixClassKey)
|
| 186 | 138 | , (mkTcOcc "Alternative", alternativeClassKey)
|
| 187 | 139 | , (mkTcOcc "Typeable", typeableClassKey)
|
| 188 | - , (mkTcOcc "Functor", functorClassKey)
|
|
| 140 | + , (mkTcOcc "Functor", functorClassKey)
|
|
| 141 | + , (mkTcOcc "Lift", liftClassKey)
|
|
| 189 | 142 | |
| 190 | 143 | -- Numeric classes
|
| 191 | 144 | , (mkTcOcc "Num", numClassKey)
|
| ... | ... | @@ -368,11 +321,6 @@ knownKeyTable |
| 368 | 321 | , (mkVarOcc "integerShiftR#", integerShiftRIdKey)
|
| 369 | 322 | ]
|
| 370 | 323 | |
| 371 | -basicKnownKeyNames :: [Name] -- See Note [Known-key names]
|
|
| 372 | -basicKnownKeyNames
|
|
| 373 | - = [
|
|
| 374 | - ]
|
|
| 375 | - |
|
| 376 | 324 | |
| 377 | 325 | {-
|
| 378 | 326 | ************************************************************************
|
| ... | ... | @@ -791,6 +739,9 @@ multMulTyConKey = mkPreludeTyConUnique 199 |
| 791 | 739 | -- GHC.Builtin.TH: USES TyConUniques 200-299
|
| 792 | 740 | -----------------------------------------------------
|
| 793 | 741 | |
| 742 | +liftClassKey :: Unique
|
|
| 743 | +liftClassKey = mkPreludeClassUnique 200
|
|
| 744 | + |
|
| 794 | 745 | ----------------------- SIMD ------------------------
|
| 795 | 746 | -- USES TyConUniques 300-399
|
| 796 | 747 | -----------------------------------------------------
|
| ... | ... | @@ -122,31 +122,6 @@ primOpRdrName op = getRdrName (primOpId op) |
| 122 | 122 | * *
|
| 123 | 123 | ********************************************************************* -}
|
| 124 | 124 | |
| 125 | -knownOccs :: [KnownOcc]
|
|
| 126 | --- Used only for sanity-checks
|
|
| 127 | --- Sadly incomplete .. is it worth it? See fromEnum_REDR etc....
|
|
| 128 | -knownOccs
|
|
| 129 | - = [ composeIdOcc
|
|
| 130 | - , rationalTyConOcc
|
|
| 131 | - |
|
| 132 | - -- Enum class ops
|
|
| 133 | - , enumFromClassOpOcc, enumFromThenClassOpOcc
|
|
| 134 | - , enumFromToClassOpOcc, enumFromThenToClassOpOcc
|
|
| 135 | - |
|
| 136 | - -- Static
|
|
| 137 | - , fromStaticPtrClassOpOcc
|
|
| 138 | - |
|
| 139 | - -- Typeable stuff
|
|
| 140 | - , someTypeRepTyConOcc, someTypeRepDataConOcc, mkTrConOcc, mkTrAppCheckedOcc
|
|
| 141 | - , mkTrFunOcc, typeRepIdOcc, typeNatTypeRepOcc, typeSymbolTypeRepOcc
|
|
| 142 | - , typeCharTypeRepOcc, typeLitSymbolDataConOcc, typeLitNatDataConOcc
|
|
| 143 | - , typeLitCharDataConOcc
|
|
| 144 | - , trModuleTyConOcc, trModuleDataConOcc, trNameSDataConOcc, trTyConTyConOcc
|
|
| 145 | - , trTyConDataConOcc, kindRepTyConOcc, kindRepTyConAppDataConOcc, kindRepVarDataConOcc
|
|
| 146 | - , kindRepAppDataConOcc, kindRepFunDataConOcc, kindRepTypeDataConOcc
|
|
| 147 | - , kindRepTypeLitSDataConOcc
|
|
| 148 | - ]
|
|
| 149 | - |
|
| 150 | 125 | eqClassOpOcc, negateClassOpOcc, minusClassOpOcc, geClassOpOcc, toListClassOpOcc,
|
| 151 | 126 | fromListNClassOpOcc, fromListClassOpOcc, fromLabelClassOpOcc,
|
| 152 | 127 | setFieldClassOpOcc, fromStringClassOpOcc :: KnownOcc
|
| ... | ... | @@ -355,18 +330,6 @@ emptyExceptionContextIdOcc = mkVarOcc "emptyExceptionContext" |
| 355 | 330 | * *
|
| 356 | 331 | ********************************************************************* -}
|
| 357 | 332 | |
| 358 | -knownOccRdrNames :: [RdrName]
|
|
| 359 | -knownOccRdrNames
|
|
| 360 | - = [ toDyn_RDR, compose_RDR
|
|
| 361 | - , appE_RDR, lift_RDR, liftTyped_RDR
|
|
| 362 | - , enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, enumFromThenTo_RDR
|
|
| 363 | - , fromEnum_RDR, toEnum_RDR, toEnumError_RDR, succError_RDR
|
|
| 364 | - , predError_RDR, enumIntToWord_RDR, succ_RDR, pred_RDR
|
|
| 365 | - , minBound_RDR, maxBound_RDR
|
|
| 366 | - , times_RDR, plus_RDR, and_RDR, not_RDR, range_RDR, inRange_RDR, index_RDR
|
|
| 367 | - , unsafeIndex_RDR, unsafeRangeSize_RDR
|
|
| 368 | - ]
|
|
| 369 | - |
|
| 370 | 333 | main_RDR_Unqual :: RdrName
|
| 371 | 334 | main_RDR_Unqual = mkUnqual varName (fsLit "main")
|
| 372 | 335 | -- We definitely don't want an Orig RdrName, because
|
| ... | ... | @@ -9,7 +9,7 @@ module GHC.Builtin.TH where |
| 9 | 9 | import GHC.Prelude ()
|
| 10 | 10 | |
| 11 | 11 | import GHC.Unit.Types
|
| 12 | -import GHC.Types.Name( Name, KnownOcc, KnownKey, mk_known_key_name )
|
|
| 12 | +import GHC.Types.Name( Name, KnownOcc, mk_known_key_name )
|
|
| 13 | 13 | import GHC.Types.Name.Occurrence
|
| 14 | 14 | import GHC.Types.Unique ( Unique )
|
| 15 | 15 | import GHC.Builtin.Uniques
|
| ... | ... | @@ -17,143 +17,6 @@ import GHC.Data.FastString |
| 17 | 17 | |
| 18 | 18 | import Language.Haskell.Syntax.Module.Name
|
| 19 | 19 | |
| 20 | -thKnownKeyTable :: [(OccName, KnownKey)]
|
|
| 21 | -thKnownKeyTable
|
|
| 22 | - = [ (liftClassOcc, liftClassKey)
|
|
| 23 | - ]
|
|
| 24 | - |
|
| 25 | -thKnownOccs :: [KnownOcc]
|
|
| 26 | -thKnownOccs
|
|
| 27 | - = [ qTyConOcc, nameTyConOcc, fieldExpTyConOcc, patTyConOcc
|
|
| 28 | - , fieldPatTyConOcc, expTyConOcc, decTyConOcc, typeTyConOcc
|
|
| 29 | - , matchTyConOcc, clauseTyConOcc, funDepTyConOcc, predTyConOcc
|
|
| 30 | - , codeTyConOcc, injAnnTyConOcc, overlapTyConOcc, decsTyConOcc
|
|
| 31 | - , modNameTyConOcc, quasiQuoterTyConOcc
|
|
| 32 | - , liftIdOcc, unsafeCodeCoerceOcc
|
|
| 33 | - , charLOcc, stringLOcc, integerLOcc, intPrimLOcc, wordPrimLOcc
|
|
| 34 | - , floatPrimLOcc, doublePrimLOcc, rationalLOcc, stringPrimLOcc
|
|
| 35 | - , charPrimLOcc
|
|
| 36 | - , litPOcc, varPOcc, tupPOcc, unboxedTupPOcc, unboxedSumPOcc, conPOcc
|
|
| 37 | - , infixPOcc, tildePOcc, bangPOcc, asPOcc, wildPOcc, recPOcc, listPOcc
|
|
| 38 | - , sigPOcc, viewPOcc, typePOcc, invisPOcc, orPOcc
|
|
| 39 | - , matchOcc, fieldPatOcc, clauseOcc
|
|
| 40 | - , varEOcc, conEOcc, litEOcc, appEOcc, appTypeEOcc, infixEOcc, infixAppOcc
|
|
| 41 | - , sectionLOcc, sectionROcc, lamEOcc, lamCaseEOcc, lamCasesEOcc, tupEOcc
|
|
| 42 | - , unboxedTupEOcc, unboxedSumEOcc, condEOcc, multiIfEOcc, letEOcc
|
|
| 43 | - , caseEOcc, doEOcc, mdoEOcc, compEOcc, staticEOcc, unboundVarEOcc
|
|
| 44 | - , labelEOcc, implicitParamVarEOcc, getFieldEOcc, projectionEOcc, typeEOcc
|
|
| 45 | - , forallEOcc, forallVisEOcc, constrainedEOcc
|
|
| 46 | - , fieldExpOcc
|
|
| 47 | - , funDOcc, valDOcc, dataDOcc, newtypeDOcc, typeDataDOcc, tySynDOcc, classDOcc
|
|
| 48 | - , instanceWithOverlapDOcc, sigDOcc, kiSigDOcc, forImpDOcc, pragInlDOcc
|
|
| 49 | - , pragSpecDOcc, pragSpecInlDOcc, pragSpecEDOcc, pragSpecInlEDOcc
|
|
| 50 | - , pragSpecInstDOcc, pragRuleDOcc
|
|
| 51 | - , pragAnnDOcc, pragSCCFunDOcc, pragSCCFunNamedDOcc
|
|
| 52 | - , standaloneDerivWithStrategyDOcc, defaultSigDOcc, defaultDOcc
|
|
| 53 | - , dataInstDOcc, newtypeInstDOcc, tySynInstDOcc, dataFamilyDOcc
|
|
| 54 | - , openTypeFamilyDOcc, closedTypeFamilyDOcc, infixLWithSpecDOcc
|
|
| 55 | - , infixRWithSpecDOcc, infixNWithSpecDOcc, roleAnnotDOcc, patSynDOcc
|
|
| 56 | - , patSynSigDOcc, pragCompleteDOcc, implicitParamBindDOcc, pragOpaqueDOcc
|
|
| 57 | - , patQTyConOcc, expQTyConOcc, stmtTyConOcc, conTyConOcc, bangTypeTyConOcc
|
|
| 58 | - , varBangTypeTyConOcc, typeQTyConOcc, decsQTyConOcc, ruleBndrTyConOcc
|
|
| 59 | - , tySynEqnTyConOcc, roleTyConOcc, derivClauseTyConOcc, kindTyConOcc
|
|
| 60 | - , tyVarBndrUnitTyConOcc, tyVarBndrSpecTyConOcc, tyVarBndrVisTyConOcc
|
|
| 61 | - , derivStrategyTyConOcc
|
|
| 62 | - , guardedBOcc, normalBOcc
|
|
| 63 | - , normalGEOcc, patGEOcc
|
|
| 64 | - , bindSOcc, letSOcc, noBindSOcc, parSOcc, recSOcc
|
|
| 65 | - ]
|
|
| 66 | - |
|
| 67 | -templateHaskellNames :: [Name]
|
|
| 68 | --- The names that are implicitly mentioned by ``bracket''
|
|
| 69 | --- Should stay in sync with the import list of GHC.HsToCore.Quote
|
|
| 70 | - |
|
| 71 | -templateHaskellNames = [
|
|
| 72 | - newNameName,
|
|
| 73 | - mkNameName, mkNameG_vName, mkNameG_dName, mkNameG_tcName, mkNameG_fldName,
|
|
| 74 | - mkNameLName,
|
|
| 75 | - mkNameSName, mkNameQName,
|
|
| 76 | - mkModNameName,
|
|
| 77 | - unTypeName, unTypeCodeName,
|
|
| 78 | - |
|
| 79 | - -- Cxt
|
|
| 80 | - cxtName,
|
|
| 81 | - |
|
| 82 | - -- SourceUnpackedness
|
|
| 83 | - noSourceUnpackednessName, sourceNoUnpackName, sourceUnpackName,
|
|
| 84 | - -- SourceStrictness
|
|
| 85 | - noSourceStrictnessName, sourceLazyName, sourceStrictName,
|
|
| 86 | - -- Con
|
|
| 87 | - normalCName, recCName, infixCName, forallCName, gadtCName, recGadtCName,
|
|
| 88 | - -- Bang
|
|
| 89 | - bangName,
|
|
| 90 | - -- BangType
|
|
| 91 | - bangTypeName,
|
|
| 92 | - -- VarBangType
|
|
| 93 | - varBangTypeName,
|
|
| 94 | - -- PatSynDir (for pattern synonyms)
|
|
| 95 | - unidirPatSynName, implBidirPatSynName, explBidirPatSynName,
|
|
| 96 | - -- PatSynArgs (for pattern synonyms)
|
|
| 97 | - prefixPatSynName, infixPatSynName, recordPatSynName,
|
|
| 98 | - -- Type
|
|
| 99 | - forallTName, forallVisTName, varTName, conTName, infixTName, appTName,
|
|
| 100 | - appKindTName, equalityTName, tupleTName, unboxedTupleTName,
|
|
| 101 | - unboxedSumTName, arrowTName, mulArrowTName, listTName, sigTName, litTName,
|
|
| 102 | - promotedTName, promotedTupleTName, promotedNilTName, promotedConsTName,
|
|
| 103 | - wildCardTName, implicitParamTName,
|
|
| 104 | - -- TyLit
|
|
| 105 | - numTyLitName, strTyLitName, charTyLitName,
|
|
| 106 | - -- TyVarBndr
|
|
| 107 | - plainTVName, kindedTVName,
|
|
| 108 | - plainInvisTVName, kindedInvisTVName,
|
|
| 109 | - plainBndrTVName, kindedBndrTVName,
|
|
| 110 | - -- Specificity
|
|
| 111 | - specifiedSpecName, inferredSpecName,
|
|
| 112 | - -- Visibility
|
|
| 113 | - bndrReqName, bndrInvisName,
|
|
| 114 | - -- Role
|
|
| 115 | - nominalRName, representationalRName, phantomRName, inferRName,
|
|
| 116 | - -- Kind
|
|
| 117 | - starKName, constraintKName,
|
|
| 118 | - -- FamilyResultSig
|
|
| 119 | - noSigName, kindSigName, tyVarSigName,
|
|
| 120 | - -- InjectivityAnn
|
|
| 121 | - injectivityAnnName,
|
|
| 122 | - -- Callconv
|
|
| 123 | - cCallName, stdCallName, cApiCallName, primCallName, javaScriptCallName,
|
|
| 124 | - -- Safety
|
|
| 125 | - unsafeName,
|
|
| 126 | - safeName,
|
|
| 127 | - interruptibleName,
|
|
| 128 | - -- Inline
|
|
| 129 | - noInlineDataConName, inlineDataConName, inlinableDataConName,
|
|
| 130 | - -- RuleMatch
|
|
| 131 | - conLikeDataConName, funLikeDataConName,
|
|
| 132 | - -- Phases
|
|
| 133 | - allPhasesDataConName, fromPhaseDataConName, beforePhaseDataConName,
|
|
| 134 | - -- Overlap
|
|
| 135 | - overlappableDataConName, overlappingDataConName, overlapsDataConName,
|
|
| 136 | - incoherentDataConName,
|
|
| 137 | - -- NamespaceSpecifier
|
|
| 138 | - noNamespaceSpecifierDataConName, typeNamespaceSpecifierDataConName,
|
|
| 139 | - dataNamespaceSpecifierDataConName,
|
|
| 140 | - -- DerivStrategy
|
|
| 141 | - stockStrategyName, anyclassStrategyName,
|
|
| 142 | - newtypeStrategyName, viaStrategyName,
|
|
| 143 | - -- RuleBndr
|
|
| 144 | - ruleVarName, typedRuleVarName,
|
|
| 145 | - -- FunDep
|
|
| 146 | - funDepName,
|
|
| 147 | - -- TySynEqn
|
|
| 148 | - tySynEqnName,
|
|
| 149 | - -- AnnTarget
|
|
| 150 | - valueAnnotationName, typeAnnotationName, moduleAnnotationName,
|
|
| 151 | - -- DerivClause
|
|
| 152 | - derivClauseName,
|
|
| 153 | - |
|
| 154 | - -- Quasiquoting
|
|
| 155 | - quoteDecName, quoteTypeName, quoteExpName, quotePatName]
|
|
| 156 | - |
|
| 157 | 20 | thSyn, thMonad, thLib, qqLib, liftLib :: Module
|
| 158 | 21 | thSyn = mkTHModule (fsLit "GHC.Internal.TH.Syntax")
|
| 159 | 22 | thMonad = mkTHModule (fsLit "GHC.Internal.TH.Monad")
|
| ... | ... | @@ -183,8 +46,7 @@ qqFld :: FastString -> Unique -> Name |
| 183 | 46 | qqFld = mk_known_key_name (fieldName (fsLit "QuasiQuoter")) qqLib
|
| 184 | 47 | |
| 185 | 48 | -------------------- TH.Syntax -----------------------
|
| 186 | -liftClassOcc, quoteClassOcc :: KnownOcc
|
|
| 187 | -liftClassOcc = mkTcOcc "Lift"
|
|
| 49 | +quoteClassOcc :: KnownOcc
|
|
| 188 | 50 | quoteClassOcc = mkTcOcc "Quote"
|
| 189 | 51 | |
| 190 | 52 | qTyConOcc, nameTyConOcc, fieldExpTyConOcc, patTyConOcc,
|
| ... | ... | @@ -664,9 +526,6 @@ dataNamespaceSpecifierDataConName = |
| 664 | 526 | liftClassKey :: Unique
|
| 665 | 527 | liftClassKey = mkPreludeClassUnique 200
|
| 666 | 528 | |
| 667 | -quoteClassKey :: Unique
|
|
| 668 | -quoteClassKey = mkPreludeClassUnique 201
|
|
| 669 | - |
|
| 670 | 529 | {- *********************************************************************
|
| 671 | 530 | * *
|
| 672 | 531 | TyCon keys
|
| ... | ... | @@ -719,21 +719,21 @@ moduleHasMagicDefn :: DsM Bool |
| 719 | 719 | moduleHasMagicDefn = do
|
| 720 | 720 | env <- getGblEnv
|
| 721 | 721 | this_mod <- getModule
|
| 722 | - -- Look for the magic names in scope. If found, check if this is the defining
|
|
| 723 | - -- module. Otherwise, it definitely isn't the defining module.
|
|
| 724 | - let
|
|
| 725 | - kes = KES_InScope { ke_mod = ds_mod env
|
|
| 726 | - , ke_rdr_env = ds_gbl_rdr_env env
|
|
| 727 | - , ke_gbl_type_env = ds_type_env env
|
|
| 728 | - , ke_lcl_type_env = emptyNameEnv }
|
|
| 729 | - definesMagicName magicKey = do
|
|
| 730 | - mb_res <- lookupKnownKeyName magicKey kes
|
|
| 731 | - case mb_res of
|
|
| 732 | - Succeeded name -> return (nameModule name == this_mod)
|
|
| 733 | - Failed _ -> return False
|
|
| 734 | - dfns_magic <- setEnvs (ds_if_env env) $
|
|
| 735 | - mapM (definesMagicName . fst) magicDefns
|
|
| 736 | - pure $ any id dfns_magic
|
|
| 722 | + -- If module -fdefines-known-key-names, look for the magic names in scope and
|
|
| 723 | + -- check if this module is the magic name's module. If module doesn't
|
|
| 724 | + -- -fdefines-known-key-names, it certainly doesn't define magic names.
|
|
| 725 | + kksource <- dsGetKnownKeySource
|
|
| 726 | + case kksource of
|
|
| 727 | + KES_FromModule -> return False
|
|
| 728 | + kes@KES_InScope{} -> do
|
|
| 729 | + let definesMagicName magicKey = do
|
|
| 730 | + mb_res <- lookupKnownKeyName magicKey kes
|
|
| 731 | + case mb_res of
|
|
| 732 | + Succeeded name -> return (nameModule name == this_mod)
|
|
| 733 | + Failed _ -> return False
|
|
| 734 | + dfns_magic <- setEnvs (ds_if_env env) $
|
|
| 735 | + mapM (definesMagicName . fst) magicDefns
|
|
| 736 | + pure $ any id dfns_magic
|
|
| 737 | 737 | |
| 738 | 738 | mkUnsafeCoercePrimPair :: Id -> CoreExpr -> DsM (Id, CoreExpr)
|
| 739 | 739 | -- See Note [Wiring in unsafeCoerce#] for the defn we are creating here
|
| ... | ... | @@ -703,6 +703,12 @@ getSymbolTable bh name_cache |
| 703 | 703 | ; writeArray mut_arr (fromIntegral i) name
|
| 704 | 704 | ; return new_cache }
|
| 705 | 705 | |
| 706 | +-- ROMES:TODO: KILL THIS from here to the end.
|
|
| 707 | +-- We no longer put uniques for known-occ names anymore, they'll be looked up
|
|
| 708 | +-- in the table.
|
|
| 709 | +-- No uniques in interface files!
|
|
| 710 | + |
|
| 711 | + |
|
| 706 | 712 | -- Note [Symbol table representation of names]
|
| 707 | 713 | -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 708 | 714 | -- An occurrence of a name in an interface file is serialized as a single 32-bit
|
| ... | ... | @@ -1128,7 +1128,7 @@ tcGetDefaultTys |
| 1128 | 1128 | ; user_defaults <- getDeclaredDefaultTys -- User-supplied defaults
|
| 1129 | 1129 | ; this_module <- tcg_mod <$> getGblEnv
|
| 1130 | 1130 | ; let this_unit = moduleUnit this_module
|
| 1131 | - ; if this_unit == ghcInternalUnit
|
|
| 1131 | + ; if this_unit == ghcInternalUnit -- if we wanted, this needn't be about ghc-internal
|
|
| 1132 | 1132 | -- see Remark [No built-in defaults in ghc-internal]
|
| 1133 | 1133 | -- in Note [Builtin class defaults] in GHC.Tc.Utils.Env
|
| 1134 | 1134 | then return (user_defaults, extended_defaults)
|
| ... | ... | @@ -59,16 +59,19 @@ UnitIds are important because they are used to generate internal names |
| 59 | 59 | Wired-in units
|
| 60 | 60 | --------------
|
| 61 | 61 | |
| 62 | -Certain libraries (ghc-prim, base, etc.) are known to the compiler and to the
|
|
| 63 | -RTS as they provide some basic primitives. Hence UnitIds of wired-in libraries
|
|
| 64 | -are fixed. Instead of letting Cabal choose the UnitId for these libraries, their
|
|
| 65 | -.cabal file uses the following stanza to force it to a specific value:
|
|
| 62 | +Wired-in names have wired-in modules, which have a wired-in unit-id.
|
|
| 63 | +Wired-in unit-ids, such as ghc-internal and the RTS, must be known to the
|
|
| 64 | +compiler, as they provide some basic primitives.
|
|
| 66 | 65 | |
| 67 | - ghc-options: -this-unit-id ghc-prim -- taken from ghc-prim.cabal
|
|
| 66 | +Hence wired-in unit-ids are fixed. Instead of letting Cabal choose
|
|
| 67 | +the UnitId for these libraries, their .cabal file uses the following stanza to
|
|
| 68 | +force it to a specific value:
|
|
| 68 | 69 | |
| 69 | -The RTS also uses entities of wired-in units by directly referring to symbols
|
|
| 70 | -such as "base_GHCziIOziException_heapOverflow_closure" where the prefix is
|
|
| 71 | -the UnitId of "base" unit.
|
|
| 70 | + ghc-options: -this-unit-id ghc-internal -- taken from ghc-internal.cabal
|
|
| 71 | + |
|
| 72 | +The RTS also uses entities of wired-in units by referring to symbols such as
|
|
| 73 | +"ghczminternal_GHCziInternalziTopHandler_runIO_closure" where the prefix is the
|
|
| 74 | +UnitId of "ghc-internal" unit (see Note [RTS/ghc-internal interface]).
|
|
| 72 | 75 | |
| 73 | 76 | Unit databases
|
| 74 | 77 | --------------
|
| ... | ... | @@ -590,7 +590,7 @@ ghcInternalUnitId, rtsUnitId, |
| 590 | 590 | ghcInternalUnit, rtsUnit,
|
| 591 | 591 | mainUnit, thisGhcUnit, interactiveUnit, interactiveGhciUnit, interactiveSessionUnit :: Unit
|
| 592 | 592 | |
| 593 | -ghcInternalUnitId = UnitId (fsLit "ghc-internal")
|
|
| 593 | +ghcInternalUnitId = UnitId (fsLit "ghc-internal") -- See Note [About units], section "Wired-in units"
|
|
| 594 | 594 | rtsUnitId = UnitId (fsLit "rts")
|
| 595 | 595 | thisGhcUnitId = UnitId (fsLit cProjectUnitId) -- See Note [GHC's Unit Id]
|
| 596 | 596 | interactiveUnitId = UnitId (fsLit "interactive")
|
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | --
|
| 26 | 26 | -----------------------------------------------------------------------------
|
| 27 | 27 | |
| 28 | -module GHC.Internal.Classes.IP( IP(..)) where
|
|
| 28 | +module GHC.Internal.Classes.IP( IP(..) ) where
|
|
| 29 | 29 | |
| 30 | 30 | import GHC.Internal.Types
|
| 31 | 31 |