Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ghc/ghc
  • bgamari/ghc
  • syd/ghc
  • ggreif/ghc
  • watashi/ghc
  • RolandSenn/ghc
  • mpickering/ghc
  • DavidEichmann/ghc
  • carter/ghc
  • harpocrates/ghc
  • ethercrow/ghc
  • mijicd/ghc
  • adamse/ghc
  • alexbiehl/ghc
  • gridaphobe/ghc
  • trofi/ghc
  • supersven/ghc
  • ppk/ghc
  • ulysses4ever/ghc
  • AndreasK/ghc
  • ghuntley/ghc
  • shayne-fletcher-da/ghc
  • fgaz/ghc
  • yav/ghc
  • osa1/ghc
  • mbbx6spp/ghc
  • JulianLeviston/ghc
  • reactormonk/ghc
  • rae/ghc
  • takenobu-hs/ghc
  • michalt/ghc
  • andrewthad/ghc
  • hsyl20/ghc
  • scottgw/ghc
  • sjakobi/ghc
  • angerman/ghc
  • RyanGlScott/ghc
  • hvr/ghc
  • howtonotwin/ghc
  • chessai/ghc
  • m-renaud/ghc
  • brprice/ghc
  • stevehartdata/ghc
  • sighingnow/ghc
  • kgardas/ghc
  • ckoparkar/ghc
  • alp/ghc
  • smaeul/ghc
  • kakkun61/ghc
  • sykloid/ghc
  • newhoggy/ghc
  • toonn/ghc
  • nineonine/ghc
  • Phyx/ghc
  • ezyang/ghc
  • tweag/ghc
  • langston/ghc
  • ndmitchell/ghc
  • rockbmb/ghc
  • artempyanykh/ghc
  • mniip/ghc
  • mynguyenbmc/ghc
  • alexfmpe/ghc
  • crockeea/ghc
  • nh2/ghc
  • vaibhavsagar/ghc
  • phadej/ghc
  • Haskell-mouse/ghc
  • lolotp/ghc
  • spacekitteh/ghc
  • michaelpj/ghc
  • mgsloan/ghc
  • HPCohen/ghc
  • tmobile/ghc
  • radrow/ghc
  • simonmar/ghc
  • _deepfire/ghc
  • Ericson2314/ghc
  • leitao/ghc
  • fumieval/ghc
  • trac-isovector/ghc
  • cblp/ghc
  • xich/ghc
  • ciil/ghc
  • erthalion/ghc
  • xldenis/ghc
  • autotaker/ghc
  • haskell-wasm/ghc
  • kcsongor/ghc
  • agander/ghc
  • Baranowski/ghc
  • trac-dredozubov/ghc
  • 23Skidoo/ghc
  • iustin/ghc
  • ningning/ghc
  • josefs/ghc
  • kabuhr/ghc
  • gallais/ghc
  • dten/ghc
  • expipiplus1/ghc
  • Pluralia/ghc
  • rohanjr/ghc
  • intricate/ghc
  • kirelagin/ghc
  • Javran/ghc
  • DanielG/ghc
  • trac-mizunashi_mana/ghc
  • pparkkin/ghc
  • bollu/ghc
  • ntc2/ghc
  • jaspervdj/ghc
  • JoshMeredith/ghc
  • wz1000/ghc
  • zkourouma/ghc
  • code5hot/ghc
  • jdprice/ghc
  • tdammers/ghc
  • J-mie6/ghc
  • trac-lantti/ghc
  • ch1bo/ghc
  • cgohla/ghc
  • lucamolteni/ghc
  • acairncross/ghc
  • amerocu/ghc
  • chreekat/ghc
  • txsmith/ghc
  • trupill/ghc
  • typetetris/ghc
  • sergv/ghc
  • fryguybob/ghc
  • erikd/ghc
  • trac-roland/ghc
  • setupminimal/ghc
  • Friede80/ghc
  • SkyWriter/ghc
  • xplorld/ghc
  • abrar/ghc
  • obsidiansystems/ghc
  • Icelandjack/ghc
  • adinapoli/ghc
  • trac-matthewbauer/ghc
  • heatsink/ghc
  • dwijnand/ghc
  • Cmdv/ghc
  • alinab/ghc
  • pepeiborra/ghc
  • fommil/ghc
  • luochen1990/ghc
  • rlupton20/ghc
  • applePrincess/ghc
  • lehins/ghc
  • ronmrdechai/ghc
  • leeadam/ghc
  • harendra/ghc
  • mightymosquito1991/ghc
  • trac-gershomb/ghc
  • lucajulian/ghc
  • Rizary/ghc
  • VictorCMiraldo/ghc
  • jamesbrock/ghc
  • andrewdmeier/ghc
  • luke/ghc
  • pranaysashank/ghc
  • cocreature/ghc
  • hithroc/ghc
  • obreitwi/ghc
  • slrtbtfs/ghc
  • kaol/ghc
  • yairchu/ghc
  • Mathemagician98/ghc
  • trac-taylorfausak/ghc
  • leungbk/ghc
  • MichaWiedenmann/ghc
  • chris-martin/ghc
  • TDecki/ghc
  • adithyaov/ghc
  • trac-gelisam/ghc
  • Lysxia/ghc
  • complyue/ghc
  • bwignall/ghc
  • sternmull/ghc
  • sonika/ghc
  • leif/ghc
  • broadwaylamb/ghc
  • myszon/ghc
  • danbroooks/ghc
  • Mechachleopteryx/ghc
  • zardyh/ghc
  • trac-vdukhovni/ghc
  • OmarKhaledAbdo/ghc
  • arrowd/ghc
  • Bodigrim/ghc
  • matheus23/ghc
  • cardenaso11/ghc
  • trac-Athas/ghc
  • mb720/ghc
  • DylanZA/ghc
  • liff/ghc
  • typedrat/ghc
  • trac-claude/ghc
  • jbm/ghc
  • Gertjan423/ghc
  • PHO/ghc
  • JKTKops/ghc
  • kockahonza/ghc
  • msakai/ghc
  • Sir4ur0n/ghc
  • barambani/ghc
  • vishnu.c/ghc
  • dcoutts/ghc
  • trac-runeks/ghc
  • trac-MaxGabriel/ghc
  • lexi.lambda/ghc
  • strake/ghc
  • spavikevik/ghc
  • JakobBruenker/ghc
  • rmanne/ghc
  • gdziadkiewicz/ghc
  • ani/ghc
  • iliastsi/ghc
  • smunix/ghc
  • judah/ghc
  • blackgnezdo/ghc
  • emilypi/ghc
  • trac-bpfoley/ghc
  • muesli4/ghc
  • trac-gkaracha/ghc
  • Kleidukos/ghc
  • nek0/ghc
  • TristanCacqueray/ghc
  • dwulive/ghc
  • mbakke/ghc
  • arybczak/ghc
  • Yang123321/ghc
  • maksbotan/ghc
  • QuietMisdreavus/ghc
  • trac-olshanskydr/ghc
  • emekoi/ghc
  • samuela/ghc
  • josephcsible/ghc
  • dramforever/ghc
  • lpsmith/ghc
  • DenisFrezzato/ghc
  • michivi/ghc
  • jneira/ghc
  • jeffhappily/ghc
  • Ivan-Yudin/ghc
  • nakaji-dayo/ghc
  • gdevanla/ghc
  • galen/ghc
  • fendor/ghc
  • yaitskov/ghc
  • rcythr/ghc
  • awpr/ghc
  • jeremyschlatter/ghc
  • Aver1y/ghc
  • mitchellvitez/ghc
  • merijn/ghc
  • tomjaguarpaw1/ghc
  • trac-NoidedSuper/ghc
  • erewok/ghc
  • trac-junji.hashimoto/ghc
  • adamwespiser/ghc
  • bjaress/ghc
  • jhrcek/ghc
  • leonschoorl/ghc
  • lukasz-golebiewski/ghc
  • sheaf/ghc
  • last-g/ghc
  • carassius1014/ghc
  • eschwartz/ghc
  • dwincort/ghc
  • felixwiemuth/ghc
  • TimWSpence/ghc
  • marcusmonteirodesouza/ghc
  • WJWH/ghc
  • vtols/ghc
  • theobat/ghc
  • BinderDavid/ghc
  • ckoparkar0/ghc
  • alexander-kjeldaas/ghc
  • dme2/ghc
  • philderbeast/ghc
  • aaronallen8455/ghc
  • rayshih/ghc
  • benkard/ghc
  • mpardalos/ghc
  • saidelman/ghc
  • leiftw/ghc
  • ca333/ghc
  • bwroga/ghc
  • nmichael44/ghc
  • trac-crobbins/ghc
  • felixonmars/ghc
  • adityagupta1089/ghc
  • hgsipiere/ghc
  • treeowl/ghc
  • alexpeits/ghc
  • CraigFe/ghc
  • dnlkrgr/ghc
  • kerckhove_ts/ghc
  • cptwunderlich/ghc
  • eiais/ghc
  • hahohihu/ghc
  • sanchayan/ghc
  • lemmih/ghc
  • sehqlr/ghc
  • trac-dbeacham/ghc
  • luite/ghc
  • trac-f-a/ghc
  • vados/ghc
  • luntain/ghc
  • fatho/ghc
  • alexbiehl-gc/ghc
  • dcbdan/ghc
  • tvh/ghc
  • liam-ly/ghc
  • timbobbarnes/ghc
  • GovanifY/ghc
  • shanth2600/ghc
  • gliboc/ghc
  • duog/ghc
  • moxonsghost/ghc
  • zander/ghc
  • masaeedu/ghc
  • georgefst/ghc
  • guibou/ghc
  • nicuveo/ghc
  • mdebruijne/ghc
  • stjordanis/ghc
  • emiflake/ghc
  • wygulmage/ghc
  • frasertweedale/ghc
  • coot/ghc
  • aratamizuki/ghc
  • tsandstr/ghc
  • mrBliss/ghc
  • Anton-Latukha/ghc
  • tadfisher/ghc
  • vapourismo/ghc
  • Sorokin-Anton/ghc
  • basile-henry/ghc
  • trac-mightybyte/ghc
  • AbsoluteNikola/ghc
  • cobrien99/ghc
  • songzh/ghc
  • blamario/ghc
  • aj4ayushjain/ghc
  • trac-utdemir/ghc
  • tangcl/ghc
  • hdgarrood/ghc
  • maerwald/ghc
  • arjun/ghc
  • ratherforky/ghc
  • haskieLambda/ghc
  • EmilGedda/ghc
  • Bogicevic/ghc
  • eddiejessup/ghc
  • kozross/ghc
  • AlistairB/ghc
  • 3Rafal/ghc
  • christiaanb/ghc
  • trac-bit/ghc
  • matsumonkie/ghc
  • trac-parsonsmatt/ghc
  • chisui/ghc
  • jaro/ghc
  • trac-kmiyazato/ghc
  • davidsd/ghc
  • Tritlo/ghc
  • I-B-3/ghc
  • lykahb/ghc
  • AriFordsham/ghc
  • turion1/ghc
  • berberman/ghc
  • christiantakle/ghc
  • zyklotomic/ghc
  • trac-ocramz/ghc
  • CSEdd/ghc
  • doyougnu/ghc
  • mmhat/ghc
  • why-not-try-calmer/ghc
  • plutotulp/ghc
  • kjekac/ghc
  • Manvi07/ghc
  • teo/ghc
  • cactus/ghc
  • CarrieMY/ghc
  • abel/ghc
  • yihming/ghc
  • tsakki/ghc
  • jessicah/ghc
  • oliverbunting/ghc
  • meld/ghc
  • friedbrice/ghc
  • Joald/ghc
  • abarbu/ghc
  • DigitalBrains1/ghc
  • sterni/ghc
  • alexDarcy/ghc
  • hexchain/ghc
  • minimario/ghc
  • zliu41/ghc
  • tommd/ghc
  • jazcarate/ghc
  • peterbecich/ghc
  • alirezaghey/ghc
  • solomon/ghc
  • mikael.urankar/ghc
  • davjam/ghc
  • int-index/ghc
  • MorrowM/ghc
  • nrnrnr/ghc
  • Sonfamm/ghc-test-only
  • afzt1/ghc
  • nguyenhaibinh-tpc/ghc
  • trac-lierdakil/ghc
  • MichaWiedenmann1/ghc
  • jmorag/ghc
  • Ziharrk/ghc
  • trac-MitchellSalad/ghc
  • juampe/ghc
  • jwaldmann/ghc
  • snowleopard/ghc
  • juhp/ghc
  • normalcoder/ghc
  • ksqsf/ghc
  • trac-jberryman/ghc
  • roberth/ghc
  • 1ntEgr8/ghc
  • epworth/ghc
  • MrAdityaAlok/ghc
  • JunmingZhao42/ghc
  • jappeace/ghc
  • trac-Gabriel439/ghc
  • alt-romes/ghc
  • HugoPeters1024/ghc
  • 10ne1/ghc-fork
  • agentultra/ghc
  • Garfield1002/ghc
  • ChickenProp/ghc
  • clyring/ghc
  • MaxHearnden/ghc
  • jumper149/ghc
  • vem/ghc
  • ketzacoatl/ghc
  • Rosuavio/ghc
  • jackohughes/ghc
  • p4l1ly/ghc
  • konsumlamm/ghc
  • shlevy/ghc
  • torsten.schmits/ghc
  • andremarianiello/ghc
  • amesgen/ghc
  • googleson78/ghc
  • InfiniteVerma/ghc
  • uhbif19/ghc
  • yiyunliu/ghc
  • raehik/ghc
  • mrkun/ghc
  • telser/ghc
  • 1Jajen1/ghc
  • slotThe/ghc
  • WinstonHartnett/ghc
  • mpilgrem/ghc
  • dreamsmasher/ghc
  • schuelermine/ghc
  • trac-Viwor/ghc
  • undergroundquizscene/ghc
  • evertedsphere/ghc
  • coltenwebb/ghc
  • oberblastmeister/ghc
  • agrue/ghc
  • lf-/ghc
  • zacwood9/ghc
  • steshaw/ghc
  • high-cloud/ghc
  • SkamDart/ghc
  • PiDelport/ghc
  • maoif/ghc
  • RossPaterson/ghc
  • CharlesTaylor7/ghc
  • ribosomerocker/ghc
  • trac-ramirez7/ghc
  • daig/ghc
  • NicolasT/ghc
  • FinleyMcIlwaine/ghc
  • lawtonnichols/ghc
  • jmtd/ghc
  • ozkutuk/ghc
  • wildsebastian/ghc
  • lrzlin/ghc
  • tobias/ghc
  • fw/ghc
  • hawkinsw/ghc
  • type-dance/ghc
  • rui314/ghc
  • ocharles/ghc
  • wavewave/ghc
  • TheKK/ghc
  • nomeata/ghc
  • trac-csabahruska/ghc
  • jonathanjameswatson/ghc
  • L-as/ghc
  • Axman6/ghc
  • barracuda156/ghc
  • trac-jship/ghc
  • jake-87/ghc
  • meooow/ghc
  • rebeccat/ghc
  • hamana55/ghc
  • Enigmage/ghc
  • kokobd/ghc
  • agevelt/ghc
  • gshen42/ghc
  • chrismwendt/ghc
  • MangoIV/ghc
  • teto/ghc
  • Sookr1/ghc
  • trac-thomasjm/ghc
  • barci2/ghc-dev
  • trac-m4dc4p/ghc
  • dixonary/ghc
  • breakerzirconia/ghc
  • alexsio27444/ghc
  • glocq/ghc
  • sourabhxyz/ghc
  • ryantrinkle/ghc
  • Jade/ghc
  • scedfaliako/ghc
  • martijnbastiaan/ghc
  • trac-george.colpitts/ghc
  • ammarbinfaisal/ghc
  • mimi.vx/ghc
  • lortabac/ghc
  • trac-zyla/ghc
  • benbellick/ghc
  • aadaa-fgtaa/ghc
  • jvanbruegge/ghc
  • archbung/ghc
  • gilmi/ghc
  • mfonism/ghc
  • alex-mckenna/ghc
  • Ei30metry/ghc
  • DiegoDiverio/ghc
  • jorgecunhamendes/ghc
  • liesnikov/ghc
  • akrmn/ghc
  • trac-simplifierticks/ghc
  • jacco/ghc
  • rhendric/ghc
  • damhiya/ghc
  • ryndubei/ghc
  • DaveBarton/ghc
  • trac-Profpatsch/ghc
  • GZGavinZhao/ghc
  • ncfavier/ghc
  • jameshaydon/ghc
  • ajccosta/ghc
  • dschrempf/ghc
  • cydparser/ghc
  • LinuxUserGD/ghc
  • elodielander/ghc
  • facundominguez/ghc
  • psilospore/ghc
  • lachrimae/ghc
  • dylan-thinnes/ghc-type-errors-plugin
  • hamishmack/ghc
  • Leary/ghc
  • lzszt/ghc
  • lyokha/ghc
  • trac-glaubitz/ghc
  • Rewbert/ghc
  • andreabedini/ghc
  • Jasagredo/ghc
  • sol/ghc
  • OlegAlexander/ghc
  • trac-sthibaul/ghc
  • avdv/ghc
  • Wendaolee/ghc
  • ur4t/ghc
  • daylily/ghc
  • boltzmannrain/ghc
  • mmzk1526/ghc
  • trac-fizzixnerd/ghc
  • soulomoon/ghc
  • rwmjones/ghc
  • j14i/ghc
  • tracsis/ghc
  • gesh/ghc
  • flip101/ghc
  • eldritch-cookie/ghc
  • LemonjamesD/ghc
  • pgujjula/ghc
  • skeuchel/ghc
  • noteed/ghc
  • Torrekie/ghc
  • jlwoodwa/ghc
  • ayanamists/ghc
  • husong998/ghc
  • trac-edmundnoble/ghc
  • josephf/ghc
  • contrun/ghc
  • baulig/ghc
  • edsko/ghc
  • mzschr/ghc-issue-24732
  • ulidtko/ghc
  • Arsen/ghc
  • trac-sjoerd_visscher/ghc
  • crumbtoo/ghc
  • L0neGamer/ghc
  • DrewFenwick/ghc
  • benz0li/ghc
  • MaciejWas/ghc
  • jordanrule/ghc
  • trac-qqwy/ghc
  • LiamGoodacre/ghc
  • isomorpheme/ghc
  • trac-danidiaz/ghc
  • Kariim/ghc
  • taimoorzaeem/ghc
  • hololeap/ghc
  • ticat-fp/ghc
  • meritamen/ghc
  • criskell/ghc
  • trac-kraai/ghc
  • aergus/ghc
  • jdral/ghc
  • SamB/ghc
  • Tristian/ghc
  • ywgrit/ghc
  • KatsuPatrick/ghc
  • OsePedro/ghc
  • mpscholten/ghc
  • zaquest/ghc
  • fangyi-zhou/ghc
  • augyg/ghc
  • rkirkman/ghc
  • gulin.serge/ghc-windows-aarch64-bootstrap
  • iris/ghc
  • kwxm/ghc
  • maralorn/ghc
  • rafl/ghc
  • nikshalark/ghc
  • mrcjkb/ghc
  • blackheaven/ghc
  • laurenyim/ghc
  • bolt12/ghc
  • Xitian9/ghc
  • wenkokke/ghc
  • kephas/ghc
  • rmullanix/ghc
  • GunpowderGuy/ghc
  • I_I/ghc
  • leana8959/ghc
  • zlonast/ghc
  • jryans/ghc
  • Vekhir/ghc
658 results
Show changes
Showing
with 377 additions and 223 deletions
...@@ -190,11 +190,8 @@ outputForeignStubs dflags mod location stubs ...@@ -190,11 +190,8 @@ outputForeignStubs dflags mod location stubs
stub_c <- newTempName dflags "c" stub_c <- newTempName dflags "c"
case stubs of case stubs of
NoStubs -> do NoStubs ->
-- When compiling External Core files, may need to use stub return (False, Nothing)
-- files from a previous compilation
stub_h_exists <- doesFileExist stub_h
return (stub_h_exists, Nothing)
ForeignStubs h_code c_code -> do ForeignStubs h_code c_code -> do
let let
......
...@@ -82,7 +82,7 @@ data Phase ...@@ -82,7 +82,7 @@ data Phase
| HCc -- Haskellised C (as opposed to vanilla C) compilation | HCc -- Haskellised C (as opposed to vanilla C) compilation
| Splitter -- Assembly file splitter (part of '-split-objs') | Splitter -- Assembly file splitter (part of '-split-objs')
| SplitAs -- Assembler for split assembly files (part of '-split-objs') | SplitAs -- Assembler for split assembly files (part of '-split-objs')
| As -- Assembler for regular assembly files | As Bool -- Assembler for regular assembly files (Bool: with-cpp)
| LlvmOpt -- Run LLVM opt tool over llvm assembly | LlvmOpt -- Run LLVM opt tool over llvm assembly
| LlvmLlc -- LLVM bitcode to native assembly | LlvmLlc -- LLVM bitcode to native assembly
| LlvmMangle -- Fix up TNTC by processing assembly produced by LLVM | LlvmMangle -- Fix up TNTC by processing assembly produced by LLVM
...@@ -119,7 +119,7 @@ eqPhase Cobjcpp Cobjcpp = True ...@@ -119,7 +119,7 @@ eqPhase Cobjcpp Cobjcpp = True
eqPhase HCc HCc = True eqPhase HCc HCc = True
eqPhase Splitter Splitter = True eqPhase Splitter Splitter = True
eqPhase SplitAs SplitAs = True eqPhase SplitAs SplitAs = True
eqPhase As As = True eqPhase (As x) (As y) = x == y
eqPhase LlvmOpt LlvmOpt = True eqPhase LlvmOpt LlvmOpt = True
eqPhase LlvmLlc LlvmLlc = True eqPhase LlvmLlc LlvmLlc = True
eqPhase LlvmMangle LlvmMangle = True eqPhase LlvmMangle LlvmMangle = True
...@@ -150,21 +150,21 @@ nextPhase dflags p ...@@ -150,21 +150,21 @@ nextPhase dflags p
Splitter -> SplitAs Splitter -> SplitAs
LlvmOpt -> LlvmLlc LlvmOpt -> LlvmLlc
LlvmLlc -> LlvmMangle LlvmLlc -> LlvmMangle
LlvmMangle -> As LlvmMangle -> As False
SplitAs -> MergeStub SplitAs -> MergeStub
As -> MergeStub As _ -> MergeStub
Ccpp -> As Ccpp -> As False
Cc -> As Cc -> As False
Cobjc -> As Cobjc -> As False
Cobjcpp -> As Cobjcpp -> As False
CmmCpp -> Cmm CmmCpp -> Cmm
Cmm -> maybeHCc Cmm -> maybeHCc
HCc -> As HCc -> As False
MergeStub -> StopLn MergeStub -> StopLn
StopLn -> panic "nextPhase: nothing after StopLn" StopLn -> panic "nextPhase: nothing after StopLn"
where maybeHCc = if platformUnregisterised (targetPlatform dflags) where maybeHCc = if platformUnregisterised (targetPlatform dflags)
then HCc then HCc
else As else As False
-- the first compilation phase for a given file is determined -- the first compilation phase for a given file is determined
-- by its suffix. -- by its suffix.
...@@ -186,8 +186,8 @@ startPhase "mm" = Cobjcpp ...@@ -186,8 +186,8 @@ startPhase "mm" = Cobjcpp
startPhase "cc" = Ccpp startPhase "cc" = Ccpp
startPhase "cxx" = Ccpp startPhase "cxx" = Ccpp
startPhase "split_s" = Splitter startPhase "split_s" = Splitter
startPhase "s" = As startPhase "s" = As False
startPhase "S" = As startPhase "S" = As True
startPhase "ll" = LlvmOpt startPhase "ll" = LlvmOpt
startPhase "bc" = LlvmLlc startPhase "bc" = LlvmLlc
startPhase "lm_s" = LlvmMangle startPhase "lm_s" = LlvmMangle
...@@ -215,7 +215,8 @@ phaseInputExt Cobjc = "m" ...@@ -215,7 +215,8 @@ phaseInputExt Cobjc = "m"
phaseInputExt Cobjcpp = "mm" phaseInputExt Cobjcpp = "mm"
phaseInputExt Cc = "c" phaseInputExt Cc = "c"
phaseInputExt Splitter = "split_s" phaseInputExt Splitter = "split_s"
phaseInputExt As = "s" phaseInputExt (As True) = "S"
phaseInputExt (As False) = "s"
phaseInputExt LlvmOpt = "ll" phaseInputExt LlvmOpt = "ll"
phaseInputExt LlvmLlc = "bc" phaseInputExt LlvmLlc = "bc"
phaseInputExt LlvmMangle = "lm_s" phaseInputExt LlvmMangle = "lm_s"
...@@ -240,14 +241,14 @@ objish_suffixes :: Platform -> [String] ...@@ -240,14 +241,14 @@ objish_suffixes :: Platform -> [String]
-- Use the appropriate suffix for the system on which -- Use the appropriate suffix for the system on which
-- the GHC-compiled code will run -- the GHC-compiled code will run
objish_suffixes platform = case platformOS platform of objish_suffixes platform = case platformOS platform of
OSMinGW32 -> [ "o", "O", "obj", "OBJ" ] OSMinGW32 -> [ "o", "O", "obj", "OBJ" ]
_ -> [ "o" ] _ -> [ "o" ]
dynlib_suffixes :: Platform -> [String] dynlib_suffixes :: Platform -> [String]
dynlib_suffixes platform = case platformOS platform of dynlib_suffixes platform = case platformOS platform of
OSMinGW32 -> ["dll", "DLL"] OSMinGW32 -> ["dll", "DLL"]
OSDarwin -> ["dylib"] OSDarwin -> ["dylib", "so"]
_ -> ["so"] _ -> ["so"]
isHaskellishSuffix, isHaskellSrcSuffix, isCishSuffix, isExtCoreSuffix, isHaskellishSuffix, isHaskellSrcSuffix, isCishSuffix, isExtCoreSuffix,
isHaskellUserSrcSuffix isHaskellUserSrcSuffix
......
...@@ -139,11 +139,13 @@ compileOne' m_tc_result mHscMessage ...@@ -139,11 +139,13 @@ compileOne' m_tc_result mHscMessage
input_fnpp = ms_hspp_file summary input_fnpp = ms_hspp_file summary
mod_graph = hsc_mod_graph hsc_env0 mod_graph = hsc_mod_graph hsc_env0
needsTH = any (xopt Opt_TemplateHaskell . ms_hspp_opts) mod_graph needsTH = any (xopt Opt_TemplateHaskell . ms_hspp_opts) mod_graph
needsQQ = any (xopt Opt_QuasiQuotes . ms_hspp_opts) mod_graph
needsLinker = needsTH || needsQQ
isDynWay = any (== WayDyn) (ways dflags0) isDynWay = any (== WayDyn) (ways dflags0)
isProfWay = any (== WayProf) (ways dflags0) isProfWay = any (== WayProf) (ways dflags0)
-- #8180 - when using TemplateHaskell, switch on -dynamic-too so -- #8180 - when using TemplateHaskell, switch on -dynamic-too so
-- the linker can correctly load the object files. -- the linker can correctly load the object files.
let dflags1 = if needsTH && dynamicGhc && not isDynWay && not isProfWay let dflags1 = if needsLinker && dynamicGhc && not isDynWay && not isProfWay
then gopt_set dflags0 Opt_BuildDynamicToo then gopt_set dflags0 Opt_BuildDynamicToo
else dflags0 else dflags0
...@@ -496,8 +498,8 @@ compileFile hsc_env stop_phase (src, mb_phase) = do ...@@ -496,8 +498,8 @@ compileFile hsc_env stop_phase (src, mb_phase) = do
| otherwise = Persistent | otherwise = Persistent
stop_phase' = case stop_phase of stop_phase' = case stop_phase of
As | split -> SplitAs As _ | split -> SplitAs
_ -> stop_phase _ -> stop_phase
( _, out_file) <- runPipeline stop_phase' hsc_env ( _, out_file) <- runPipeline stop_phase' hsc_env
(src, fmap RealPhase mb_phase) Nothing output (src, fmap RealPhase mb_phase) Nothing output
...@@ -728,7 +730,7 @@ getOutputFilename stop_phase output basename dflags next_phase maybe_location ...@@ -728,7 +730,7 @@ getOutputFilename stop_phase output basename dflags next_phase maybe_location
-- sometimes, we keep output from intermediate stages -- sometimes, we keep output from intermediate stages
keep_this_output = keep_this_output =
case next_phase of case next_phase of
As | keep_s -> True As _ | keep_s -> True
LlvmOpt | keep_bc -> True LlvmOpt | keep_bc -> True
HCc | keep_hc -> True HCc | keep_hc -> True
_other -> False _other -> False
...@@ -1043,7 +1045,7 @@ runPhase (RealPhase cc_phase) input_fn dflags ...@@ -1043,7 +1045,7 @@ runPhase (RealPhase cc_phase) input_fn dflags
-- files; this is the Value Add(TM) that using ghc instead of -- files; this is the Value Add(TM) that using ghc instead of
-- gcc gives you :) -- gcc gives you :)
pkg_include_dirs <- liftIO $ getPackageIncludePath dflags pkgs pkg_include_dirs <- liftIO $ getPackageIncludePath dflags pkgs
let include_paths = foldr (\ x xs -> "-I" : x : xs) [] let include_paths = foldr (\ x xs -> ("-I" ++ x) : xs) []
(cmdline_include_paths ++ pkg_include_dirs) (cmdline_include_paths ++ pkg_include_dirs)
let gcc_extra_viac_flags = extraGccViaCFlags dflags let gcc_extra_viac_flags = extraGccViaCFlags dflags
...@@ -1076,7 +1078,7 @@ runPhase (RealPhase cc_phase) input_fn dflags ...@@ -1076,7 +1078,7 @@ runPhase (RealPhase cc_phase) input_fn dflags
| otherwise = [] | otherwise = []
-- Decide next phase -- Decide next phase
let next_phase = As let next_phase = As False
output_fn <- phaseOutputFilename next_phase output_fn <- phaseOutputFilename next_phase
let let
...@@ -1188,7 +1190,7 @@ runPhase (RealPhase Splitter) input_fn dflags ...@@ -1188,7 +1190,7 @@ runPhase (RealPhase Splitter) input_fn dflags
-- As, SpitAs phase : Assembler -- As, SpitAs phase : Assembler
-- This is for calling the assembler on a regular assembly file (not split). -- This is for calling the assembler on a regular assembly file (not split).
runPhase (RealPhase As) input_fn dflags runPhase (RealPhase (As with_cpp)) input_fn dflags
= do = do
-- LLVM from version 3.0 onwards doesn't support the OS X system -- LLVM from version 3.0 onwards doesn't support the OS X system
-- assembler, so we use clang as the assembler instead. (#5636) -- assembler, so we use clang as the assembler instead. (#5636)
...@@ -1214,6 +1216,7 @@ runPhase (RealPhase As) input_fn dflags ...@@ -1214,6 +1216,7 @@ runPhase (RealPhase As) input_fn dflags
-- might be a hierarchical module. -- might be a hierarchical module.
liftIO $ createDirectoryIfMissing True (takeDirectory output_fn) liftIO $ createDirectoryIfMissing True (takeDirectory output_fn)
ccInfo <- liftIO $ getCompilerInfo dflags
let runAssembler inputFilename outputFilename let runAssembler inputFilename outputFilename
= liftIO $ as_prog dflags = liftIO $ as_prog dflags
([ SysTools.Option ("-I" ++ p) | p <- cmdline_include_paths ] ([ SysTools.Option ("-I" ++ p) | p <- cmdline_include_paths ]
...@@ -1228,8 +1231,13 @@ runPhase (RealPhase As) input_fn dflags ...@@ -1228,8 +1231,13 @@ runPhase (RealPhase As) input_fn dflags
++ (if platformArch (targetPlatform dflags) == ArchSPARC ++ (if platformArch (targetPlatform dflags) == ArchSPARC
then [SysTools.Option "-mcpu=v9"] then [SysTools.Option "-mcpu=v9"]
else []) else [])
++ (if any (ccInfo ==) [Clang, AppleClang, AppleClang51]
++ [ SysTools.Option "-x", SysTools.Option "assembler-with-cpp" then [SysTools.Option "-Qunused-arguments"]
else [])
++ [ SysTools.Option "-x"
, if with_cpp
then SysTools.Option "assembler-with-cpp"
else SysTools.Option "assembler"
, SysTools.Option "-c" , SysTools.Option "-c"
, SysTools.FileOption "" inputFilename , SysTools.FileOption "" inputFilename
, SysTools.Option "-o" , SysTools.Option "-o"
...@@ -1254,6 +1262,7 @@ runPhase (RealPhase SplitAs) _input_fn dflags ...@@ -1254,6 +1262,7 @@ runPhase (RealPhase SplitAs) _input_fn dflags
osuf = objectSuf dflags osuf = objectSuf dflags
split_odir = base_o ++ "_" ++ osuf ++ "_split" split_odir = base_o ++ "_" ++ osuf ++ "_split"
-- this also creates the hierarchy
liftIO $ createDirectoryIfMissing True split_odir liftIO $ createDirectoryIfMissing True split_odir
-- remove M_split/ *.o, because we're going to archive M_split/ *.o -- remove M_split/ *.o, because we're going to archive M_split/ *.o
...@@ -1335,7 +1344,7 @@ runPhase (RealPhase LlvmOpt) input_fn dflags ...@@ -1335,7 +1344,7 @@ runPhase (RealPhase LlvmOpt) input_fn dflags
-- passes only, so if the user is passing us extra options we assume -- passes only, so if the user is passing us extra options we assume
-- they know what they are doing and don't get in the way. -- they know what they are doing and don't get in the way.
optFlag = if null (getOpts dflags opt_lo) optFlag = if null (getOpts dflags opt_lo)
then map SysTools.Option $ words (llvmOpts !! opt_lvl) then map SysTools.Option $ words (llvmOpts ver !! opt_lvl)
else [] else []
tbaa | ver < 29 = "" -- no tbaa in 2.8 and earlier tbaa | ver < 29 = "" -- no tbaa in 2.8 and earlier
| gopt Opt_LlvmTBAA dflags = "--enable-tbaa=true" | gopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
...@@ -1355,7 +1364,11 @@ runPhase (RealPhase LlvmOpt) input_fn dflags ...@@ -1355,7 +1364,11 @@ runPhase (RealPhase LlvmOpt) input_fn dflags
where where
-- we always (unless -optlo specified) run Opt since we rely on it to -- we always (unless -optlo specified) run Opt since we rely on it to
-- fix up some pretty big deficiencies in the code we generate -- fix up some pretty big deficiencies in the code we generate
llvmOpts = ["-mem2reg -globalopt", "-O1", "-O2"] llvmOpts ver = [ "-mem2reg -globalopt"
, if ver >= 34 then "-O1 -globalopt" else "-O1"
-- LLVM 3.4 -O1 doesn't eliminate aliases reliably (bug #8855)
, "-O2"
]
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- LlvmLlc phase -- LlvmLlc phase
...@@ -1379,7 +1392,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags ...@@ -1379,7 +1392,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
let next_phase = case gopt Opt_NoLlvmMangler dflags of let next_phase = case gopt Opt_NoLlvmMangler dflags of
False -> LlvmMangle False -> LlvmMangle
True | gopt Opt_SplitObjs dflags -> Splitter True | gopt Opt_SplitObjs dflags -> Splitter
True -> As True -> As False
output_fn <- phaseOutputFilename next_phase output_fn <- phaseOutputFilename next_phase
...@@ -1448,7 +1461,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags ...@@ -1448,7 +1461,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
runPhase (RealPhase LlvmMangle) input_fn dflags runPhase (RealPhase LlvmMangle) input_fn dflags
= do = do
let next_phase = if gopt Opt_SplitObjs dflags then Splitter else As let next_phase = if gopt Opt_SplitObjs dflags then Splitter else As False
output_fn <- phaseOutputFilename next_phase output_fn <- phaseOutputFilename next_phase
liftIO $ llvmFixupAsm dflags input_fn output_fn liftIO $ llvmFixupAsm dflags input_fn output_fn
return (RealPhase next_phase, output_fn) return (RealPhase next_phase, output_fn)
...@@ -1460,6 +1473,7 @@ runPhase (RealPhase MergeStub) input_fn dflags ...@@ -1460,6 +1473,7 @@ runPhase (RealPhase MergeStub) input_fn dflags
= do = do
PipeState{maybe_stub_o} <- getPipeState PipeState{maybe_stub_o} <- getPipeState
output_fn <- phaseOutputFilename StopLn output_fn <- phaseOutputFilename StopLn
liftIO $ createDirectoryIfMissing True (takeDirectory output_fn)
case maybe_stub_o of case maybe_stub_o of
Nothing -> Nothing ->
panic "runPhase(MergeStub): no stub" panic "runPhase(MergeStub): no stub"
...@@ -2128,26 +2142,27 @@ joinObjectFiles dflags o_files output_fn = do ...@@ -2128,26 +2142,27 @@ joinObjectFiles dflags o_files output_fn = do
let mySettings = settings dflags let mySettings = settings dflags
ldIsGnuLd = sLdIsGnuLd mySettings ldIsGnuLd = sLdIsGnuLd mySettings
osInfo = platformOS (targetPlatform dflags) osInfo = platformOS (targetPlatform dflags)
ld_r args ccInfo = SysTools.runLink dflags ([ ld_r args cc = SysTools.runLink dflags ([
SysTools.Option "-nostdlib", SysTools.Option "-nostdlib",
SysTools.Option "-Wl,-r" SysTools.Option "-Wl,-r"
] ]
++ (if ccInfo == Clang then [] ++ (if any (cc ==) [Clang, AppleClang, AppleClang51]
else [SysTools.Option "-nodefaultlibs"]) then []
++ (if osInfo == OSFreeBSD else [SysTools.Option "-nodefaultlibs"])
then [SysTools.Option "-L/usr/lib"] ++ (if osInfo == OSFreeBSD
else []) then [SysTools.Option "-L/usr/lib"]
-- gcc on sparc sets -Wl,--relax implicitly, but else [])
-- -r and --relax are incompatible for ld, so -- gcc on sparc sets -Wl,--relax implicitly, but
-- disable --relax explicitly. -- -r and --relax are incompatible for ld, so
++ (if platformArch (targetPlatform dflags) == ArchSPARC -- disable --relax explicitly.
&& ldIsGnuLd ++ (if platformArch (targetPlatform dflags) == ArchSPARC
then [SysTools.Option "-Wl,-no-relax"] && ldIsGnuLd
else []) then [SysTools.Option "-Wl,-no-relax"]
++ map SysTools.Option ld_build_id else [])
++ [ SysTools.Option "-o", ++ map SysTools.Option ld_build_id
SysTools.FileOption "" output_fn ] ++ [ SysTools.Option "-o",
++ args) SysTools.FileOption "" output_fn ]
++ args)
-- suppress the generation of the .note.gnu.build-id section, -- suppress the generation of the .note.gnu.build-id section,
-- which we don't need and sometimes causes ld to emit a -- which we don't need and sometimes causes ld to emit a
...@@ -2180,7 +2195,7 @@ hscPostBackendPhase dflags _ hsc_lang = ...@@ -2180,7 +2195,7 @@ hscPostBackendPhase dflags _ hsc_lang =
case hsc_lang of case hsc_lang of
HscC -> HCc HscC -> HCc
HscAsm | gopt Opt_SplitObjs dflags -> Splitter HscAsm | gopt Opt_SplitObjs dflags -> Splitter
| otherwise -> As | otherwise -> As False
HscLlvm -> LlvmOpt HscLlvm -> LlvmOpt
HscNothing -> StopLn HscNothing -> StopLn
HscInterpreted -> StopLn HscInterpreted -> StopLn
......
...@@ -1279,7 +1279,7 @@ initDynFlags dflags = do ...@@ -1279,7 +1279,7 @@ initDynFlags dflags = do
refRtccInfo <- newIORef Nothing refRtccInfo <- newIORef Nothing
wrapperNum <- newIORef emptyModuleEnv wrapperNum <- newIORef emptyModuleEnv
canUseUnicodeQuotes <- do let enc = localeEncoding canUseUnicodeQuotes <- do let enc = localeEncoding
str = "’" str = "’"
(withCString enc str $ \cstr -> (withCString enc str $ \cstr ->
do str' <- peekCString enc cstr do str' <- peekCString enc cstr
return (str == str')) return (str == str'))
...@@ -3523,10 +3523,10 @@ picCCOpts dflags ...@@ -3523,10 +3523,10 @@ picCCOpts dflags
-- Don't generate "common" symbols - these are unwanted -- Don't generate "common" symbols - these are unwanted
-- in dynamic libraries. -- in dynamic libraries.
| gopt Opt_PIC dflags -> ["-fno-common", "-U __PIC__", "-D__PIC__"] | gopt Opt_PIC dflags -> ["-fno-common", "-U__PIC__", "-D__PIC__"]
| otherwise -> ["-mdynamic-no-pic"] | otherwise -> ["-mdynamic-no-pic"]
OSMinGW32 -- no -fPIC for Windows OSMinGW32 -- no -fPIC for Windows
| gopt Opt_PIC dflags -> ["-U __PIC__", "-D__PIC__"] | gopt Opt_PIC dflags -> ["-U__PIC__", "-D__PIC__"]
| otherwise -> [] | otherwise -> []
_ _
-- we need -fPIC for C files when we are compiling with -dynamic, -- we need -fPIC for C files when we are compiling with -dynamic,
...@@ -3535,12 +3535,12 @@ picCCOpts dflags ...@@ -3535,12 +3535,12 @@ picCCOpts dflags
-- objects, but can't without -fPIC. See -- objects, but can't without -fPIC. See
-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PositionIndependentCode -- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PositionIndependentCode
| gopt Opt_PIC dflags || not (gopt Opt_Static dflags) -> | gopt Opt_PIC dflags || not (gopt Opt_Static dflags) ->
["-fPIC", "-U __PIC__", "-D__PIC__"] ["-fPIC", "-U__PIC__", "-D__PIC__"]
| otherwise -> [] | otherwise -> []
picPOpts :: DynFlags -> [String] picPOpts :: DynFlags -> [String]
picPOpts dflags picPOpts dflags
| gopt Opt_PIC dflags = ["-U __PIC__", "-D__PIC__"] | gopt Opt_PIC dflags = ["-U__PIC__", "-D__PIC__"]
| otherwise = [] | otherwise = []
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
...@@ -3749,6 +3749,8 @@ data LinkerInfo ...@@ -3749,6 +3749,8 @@ data LinkerInfo
data CompilerInfo data CompilerInfo
= GCC = GCC
| Clang | Clang
| AppleClang
| AppleClang51
| UnknownCC | UnknownCC
deriving Eq deriving Eq
......
...@@ -102,6 +102,7 @@ module GHC ( ...@@ -102,6 +102,7 @@ module GHC (
parseName, parseName,
RunResult(..), RunResult(..),
runStmt, runStmtWithLocation, runDecls, runDeclsWithLocation, runStmt, runStmtWithLocation, runDecls, runDeclsWithLocation,
runTcInteractive, -- Desired by some clients (Trac #8878)
parseImportDecl, SingleStep(..), parseImportDecl, SingleStep(..),
resume, resume,
Resume(resumeStmt, resumeThreadId, resumeBreakInfo, resumeSpan, Resume(resumeStmt, resumeThreadId, resumeBreakInfo, resumeSpan,
...@@ -257,6 +258,7 @@ module GHC ( ...@@ -257,6 +258,7 @@ module GHC (
import ByteCodeInstr import ByteCodeInstr
import BreakArray import BreakArray
import InteractiveEval import InteractiveEval
import TcRnDriver ( runTcInteractive )
#endif #endif
import HscMain import HscMain
......
...@@ -1357,11 +1357,7 @@ hscStmtWithLocation hsc_env0 stmt source linenumber = ...@@ -1357,11 +1357,7 @@ hscStmtWithLocation hsc_env0 stmt source linenumber =
Just parsed_stmt -> do Just parsed_stmt -> do
-- Rename and typecheck it -- Rename and typecheck it
hsc_env <- getHscEnv hsc_env <- getHscEnv
let interactive_hsc_env = setInteractivePackage hsc_env (ids, tc_expr, fix_env) <- ioMsgMaybe $ tcRnStmt hsc_env parsed_stmt
-- Bindings created here belong to the interactive package
-- See Note [The interactive package] in HscTypes
-- (NB: maybe not necessary, since Stmts bind only Ids)
(ids, tc_expr, fix_env) <- ioMsgMaybe $ tcRnStmt interactive_hsc_env parsed_stmt
-- Desugar it -- Desugar it
ds_expr <- ioMsgMaybe $ deSugarExpr hsc_env tc_expr ds_expr <- ioMsgMaybe $ deSugarExpr hsc_env tc_expr
...@@ -1397,10 +1393,7 @@ hscDeclsWithLocation hsc_env0 str source linenumber = ...@@ -1397,10 +1393,7 @@ hscDeclsWithLocation hsc_env0 str source linenumber =
{- Rename and typecheck it -} {- Rename and typecheck it -}
hsc_env <- getHscEnv hsc_env <- getHscEnv
let interactive_hsc_env = setInteractivePackage hsc_env tc_gblenv <- ioMsgMaybe $ tcRnDeclsi hsc_env decls
-- Bindings created here belong to the interactive package
-- See Note [The interactive package] in HscTypes
tc_gblenv <- ioMsgMaybe $ tcRnDeclsi interactive_hsc_env decls
{- Grab the new instances -} {- Grab the new instances -}
-- We grab the whole environment because of the overlapping that may have -- We grab the whole environment because of the overlapping that may have
......
...@@ -132,7 +132,7 @@ ppSourceStats short (L _ (HsModule _ exports imports ldecls _ _)) ...@@ -132,7 +132,7 @@ ppSourceStats short (L _ (HsModule _ exports imports ldecls _ _))
class_info decl@(ClassDecl {}) class_info decl@(ClassDecl {})
= (classops, addpr (sum3 (map count_bind methods))) = (classops, addpr (sum3 (map count_bind methods)))
where where
methods = map (unLoc . snd) $ bagToList (tcdMeths decl) methods = map unLoc $ bagToList (tcdMeths decl)
(_, classops, _, _, _) = count_sigs (map unLoc (tcdSigs decl)) (_, classops, _, _, _) = count_sigs (map unLoc (tcdSigs decl))
class_info _ = (0,0) class_info _ = (0,0)
...@@ -147,7 +147,7 @@ ppSourceStats short (L _ (HsModule _ exports imports ldecls _ _)) ...@@ -147,7 +147,7 @@ ppSourceStats short (L _ (HsModule _ exports imports ldecls _ _))
(addpr (sum3 (map count_bind methods)), (addpr (sum3 (map count_bind methods)),
ss, is, length ats, length adts) ss, is, length ats, length adts)
where where
methods = map (unLoc . snd) $ bagToList inst_meths methods = map unLoc $ bagToList inst_meths
-- TODO: use Sum monoid -- TODO: use Sum monoid
addpr :: (Int,Int,Int) -> Int addpr :: (Int,Int,Int) -> Int
......
...@@ -1119,10 +1119,10 @@ shadowed by the second declaration. But it has a respectable ...@@ -1119,10 +1119,10 @@ shadowed by the second declaration. But it has a respectable
qualified name (Ghci1.T), and its source location says where it was qualified name (Ghci1.T), and its source location says where it was
defined. defined.
So the main invariant continues to hold, that in any session an original So the main invariant continues to hold, that in any session an
name M.T only refers to oe unique thing. (In a previous iteration both original name M.T only refers to one unique thing. (In a previous
the T's above were called :Interactive.T, albeit with different uniques, iteration both the T's above were called :Interactive.T, albeit with
which gave rise to all sorts of trouble.) different uniques, which gave rise to all sorts of trouble.)
The details are a bit tricky though: The details are a bit tricky though:
...@@ -1132,7 +1132,7 @@ The details are a bit tricky though: ...@@ -1132,7 +1132,7 @@ The details are a bit tricky though:
* ic_tythings contains only things from the 'interactive' package. * ic_tythings contains only things from the 'interactive' package.
* Module from the 'interactive' package (Ghci1, Ghci2 etc) never go * Module from the 'interactive' package (Ghci1, Ghci2 etc) never go
in the Home Package Table (HPT). When you say :load, that's when in the Home Package Table (HPT). When you say :load, that's when we
extend the HPT. extend the HPT.
* The 'thisPackage' field of DynFlags is *not* set to 'interactive'. * The 'thisPackage' field of DynFlags is *not* set to 'interactive'.
...@@ -1140,10 +1140,13 @@ The details are a bit tricky though: ...@@ -1140,10 +1140,13 @@ The details are a bit tricky though:
package to which :load'ed modules are added to. package to which :load'ed modules are added to.
* So how do we arrange that declarations at the command prompt get * So how do we arrange that declarations at the command prompt get
to be in the 'interactive' package? By setting 'thisPackage' just to be in the 'interactive' package? Simply by setting the tcg_mod
before the typecheck/rename step for command-line processing; field of the TcGblEnv to "interactive:Ghci1". This is done by the
see the calls to HscTypes.setInteractivePackage in call to initTc in initTcInteractive, initTcForLookup, which in
HscMain.hscDeclsWithLocation and hscStmtWithLocation. turn get the module from it 'icInteractiveModule' field of the
interactive context.
The 'thisPackage' field stays as 'main' (or whatever -package-name says.
* The main trickiness is that the type environment (tcg_type_env and * The main trickiness is that the type environment (tcg_type_env and
fixity envt (tcg_fix_env) now contains entities from all the fixity envt (tcg_fix_env) now contains entities from all the
...@@ -1501,15 +1504,17 @@ implicitTyThings :: TyThing -> [TyThing] ...@@ -1501,15 +1504,17 @@ implicitTyThings :: TyThing -> [TyThing]
implicitTyThings (AnId _) = [] implicitTyThings (AnId _) = []
implicitTyThings (ACoAxiom _cc) = [] implicitTyThings (ACoAxiom _cc) = []
implicitTyThings (ATyCon tc) = implicitTyConThings tc implicitTyThings (ATyCon tc) = implicitTyConThings tc
implicitTyThings (AConLike cl) = case cl of implicitTyThings (AConLike cl) = implicitConLikeThings cl
RealDataCon dc ->
-- For data cons add the worker and (possibly) wrapper implicitConLikeThings :: ConLike -> [TyThing]
map AnId (dataConImplicitIds dc) implicitConLikeThings (RealDataCon dc)
PatSynCon ps -> = map AnId (dataConImplicitIds dc)
-- For bidirectional pattern synonyms, add the wrapper -- For data cons add the worker and (possibly) wrapper
case patSynWrapper ps of
Nothing -> [] implicitConLikeThings (PatSynCon {})
Just id -> [AnId id] = [] -- Pattern synonyms have no implicit Ids; the wrapper and matcher
-- are not "implicit"; they are simply new top-level bindings,
-- and they have their own declaration in an interface fiel
implicitClassThings :: Class -> [TyThing] implicitClassThings :: Class -> [TyThing]
implicitClassThings cl implicitClassThings cl
......
...@@ -1047,10 +1047,22 @@ isDllName :: DynFlags -> PackageId -> Module -> Name -> Bool ...@@ -1047,10 +1047,22 @@ isDllName :: DynFlags -> PackageId -> Module -> Name -> Bool
-- Despite the "dll", I think this function just means that -- Despite the "dll", I think this function just means that
-- the synbol comes from another dynamically-linked package, -- the synbol comes from another dynamically-linked package,
-- and applies on all platforms, not just Windows -- and applies on all platforms, not just Windows
isDllName dflags this_pkg this_mod name isDllName dflags _this_pkg this_mod name
| gopt Opt_Static dflags = False | gopt Opt_Static dflags = False
| Just mod <- nameModule_maybe name | Just mod <- nameModule_maybe name
= if modulePackageId mod /= this_pkg -- Issue #8696 - when GHC is dynamically linked, it will attempt
-- to load the dynamic dependencies of object files at compile
-- time for things like QuasiQuotes or
-- TemplateHaskell. Unfortunately, this interacts badly with
-- intra-package linking, because we don't generate indirect
-- (dynamic) symbols for intra-package calls. This means that if a
-- module with an intra-package call is loaded without its
-- dependencies, then GHC fails to link. This is the cause of #
--
-- In the mean time, always force dynamic indirections to be
-- generated: when the module name isn't the module being
-- compiled, references are dynamic.
= if mod /= this_mod
then True then True
else case dllSplit dflags of else case dllSplit dflags of
Nothing -> False Nothing -> False
......
...@@ -23,20 +23,18 @@ module PprTyThing ( ...@@ -23,20 +23,18 @@ module PprTyThing (
) where ) where
import TypeRep ( TyThing(..) ) import TypeRep ( TyThing(..) )
import ConLike
import DataCon import DataCon
import PatSyn
import Id import Id
import TyCon import TyCon
import Class import Class
import Coercion( pprCoAxiom, pprCoAxBranch ) import Coercion( pprCoAxBranch )
import CoAxiom( CoAxiom(..), brListMap ) import CoAxiom( CoAxiom(..), brListMap )
import HscTypes( tyThingParent_maybe ) import HscTypes( tyThingParent_maybe )
import HsBinds( pprPatSynSig )
import Type( tidyTopType, tidyOpenType, splitForAllTys, funResultTy ) import Type( tidyTopType, tidyOpenType, splitForAllTys, funResultTy )
import Kind( synTyConResKind ) import Kind( synTyConResKind )
import TypeRep( pprTvBndrs, pprForAll, suppressKinds ) import TypeRep( pprTvBndrs, pprForAll, suppressKinds )
import TysPrim( alphaTyVars ) import TysPrim( alphaTyVars )
import MkIface ( tyThingToIfaceDecl )
import TcType import TcType
import Name import Name
import VarEnv( emptyTidyEnv ) import VarEnv( emptyTidyEnv )
...@@ -44,7 +42,6 @@ import StaticFlags( opt_PprStyle_Debug ) ...@@ -44,7 +42,6 @@ import StaticFlags( opt_PprStyle_Debug )
import DynFlags import DynFlags
import Outputable import Outputable
import FastString import FastString
import Data.Maybe
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Pretty-printing entities that we get from the GHC API -- Pretty-printing entities that we get from the GHC API
...@@ -76,7 +73,7 @@ pprTyThingLoc tyThing ...@@ -76,7 +73,7 @@ pprTyThingLoc tyThing
-- | Pretty-prints a 'TyThing'. -- | Pretty-prints a 'TyThing'.
pprTyThing :: TyThing -> SDoc pprTyThing :: TyThing -> SDoc
pprTyThing thing = ppr_ty_thing showAll thing pprTyThing thing = ppr_ty_thing (Just showAll) thing
-- | Pretty-prints a 'TyThing' in context: that is, if the entity -- | Pretty-prints a 'TyThing' in context: that is, if the entity
-- is a data constructor, record selector, or class method, then -- is a data constructor, record selector, or class method, then
...@@ -88,7 +85,7 @@ pprTyThingInContext thing ...@@ -88,7 +85,7 @@ pprTyThingInContext thing
where where
go ss thing = case tyThingParent_maybe thing of go ss thing = case tyThingParent_maybe thing of
Just parent -> go (getName thing : ss) parent Just parent -> go (getName thing : ss) parent
Nothing -> ppr_ty_thing ss thing Nothing -> ppr_ty_thing (Just ss) thing
-- | Like 'pprTyThingInContext', but adds the defining location. -- | Like 'pprTyThingInContext', but adds the defining location.
pprTyThingInContextLoc :: TyThing -> SDoc pprTyThingInContextLoc :: TyThing -> SDoc
...@@ -100,21 +97,18 @@ pprTyThingInContextLoc tyThing ...@@ -100,21 +97,18 @@ pprTyThingInContextLoc tyThing
-- the function is equivalent to 'pprTyThing' but for type constructors -- the function is equivalent to 'pprTyThing' but for type constructors
-- and classes it prints only the header part of the declaration. -- and classes it prints only the header part of the declaration.
pprTyThingHdr :: TyThing -> SDoc pprTyThingHdr :: TyThing -> SDoc
pprTyThingHdr (AnId id) = pprId id pprTyThingHdr = ppr_ty_thing Nothing
pprTyThingHdr (AConLike conLike) = case conLike of
RealDataCon dataCon -> pprDataConSig dataCon
PatSynCon patSyn -> pprPatSyn patSyn
pprTyThingHdr (ATyCon tyCon) = pprTyConHdr tyCon
pprTyThingHdr (ACoAxiom ax) = pprCoAxiom ax
------------------------ ------------------------
ppr_ty_thing :: ShowSub -> TyThing -> SDoc -- NOTE: We pretty-print 'TyThing' via 'IfaceDecl' so that we can reuse the
ppr_ty_thing _ (AnId id) = pprId id -- 'TyCon' tidying happening in 'tyThingToIfaceDecl'. See #8776 for details.
ppr_ty_thing _ (AConLike conLike) = case conLike of ppr_ty_thing :: Maybe ShowSub -> TyThing -> SDoc
RealDataCon dataCon -> pprDataConSig dataCon ppr_ty_thing mss tyThing = case tyThing of
PatSynCon patSyn -> pprPatSyn patSyn AnId id -> pprId id
ppr_ty_thing ss (ATyCon tyCon) = pprTyCon ss tyCon ATyCon tyCon -> case mss of
ppr_ty_thing _ (ACoAxiom ax) = pprCoAxiom ax Nothing -> pprTyConHdr tyCon
Just ss -> pprTyCon ss tyCon
_ -> ppr $ tyThingToIfaceDecl tyThing
pprTyConHdr :: TyCon -> SDoc pprTyConHdr :: TyCon -> SDoc
pprTyConHdr tyCon pprTyConHdr tyCon
...@@ -133,7 +127,7 @@ pprTyConHdr tyCon ...@@ -133,7 +127,7 @@ pprTyConHdr tyCon
keyword | isSynTyCon tyCon = sLit "type" keyword | isSynTyCon tyCon = sLit "type"
| isNewTyCon tyCon = sLit "newtype" | isNewTyCon tyCon = sLit "newtype"
| otherwise = sLit "data" | otherwise = sLit "data"
opt_family opt_family
| isFamilyTyCon tyCon = ptext (sLit "family") | isFamilyTyCon tyCon = ptext (sLit "family")
...@@ -143,10 +137,6 @@ pprTyConHdr tyCon ...@@ -143,10 +137,6 @@ pprTyConHdr tyCon
| isAlgTyCon tyCon = pprThetaArrowTy (tyConStupidTheta tyCon) | isAlgTyCon tyCon = pprThetaArrowTy (tyConStupidTheta tyCon)
| otherwise = empty -- Returns 'empty' if null theta | otherwise = empty -- Returns 'empty' if null theta
pprDataConSig :: DataCon -> SDoc
pprDataConSig dataCon
= ppr_bndr dataCon <+> dcolon <+> pprTypeForUser (dataConUserType dataCon)
pprClassHdr :: Class -> SDoc pprClassHdr :: Class -> SDoc
pprClassHdr cls pprClassHdr cls
= sdocWithDynFlags $ \dflags -> = sdocWithDynFlags $ \dflags ->
...@@ -163,23 +153,6 @@ pprId ident ...@@ -163,23 +153,6 @@ pprId ident
= hang (ppr_bndr ident <+> dcolon) = hang (ppr_bndr ident <+> dcolon)
2 (pprTypeForUser (idType ident)) 2 (pprTypeForUser (idType ident))
pprPatSyn :: PatSyn -> SDoc
pprPatSyn patSyn
= pprPatSynSig ident is_bidir args (pprTypeForUser rhs_ty) prov req
where
ident = patSynId patSyn
is_bidir = isJust $ patSynWrapper patSyn
args = fmap pprParendType (patSynTyDetails patSyn)
prov = pprThetaOpt prov_theta
req = pprThetaOpt req_theta
pprThetaOpt [] = Nothing
pprThetaOpt theta = Just $ pprTheta theta
(_univ_tvs, _ex_tvs, (prov_theta, req_theta)) = patSynSig patSyn
rhs_ty = patSynType patSyn
pprTypeForUser :: Type -> SDoc pprTypeForUser :: Type -> SDoc
-- We do two things here. -- We do two things here.
-- a) We tidy the type, regardless -- a) We tidy the type, regardless
......
...@@ -233,6 +233,8 @@ initSysTools mbMinusB ...@@ -233,6 +233,8 @@ initSysTools mbMinusB
-- to make that possible, so for now you can't. -- to make that possible, so for now you can't.
gcc_prog <- getSetting "C compiler command" gcc_prog <- getSetting "C compiler command"
gcc_args_str <- getSetting "C compiler flags" gcc_args_str <- getSetting "C compiler flags"
cpp_prog <- getSetting "Haskell CPP command"
cpp_args_str <- getSetting "Haskell CPP flags"
let unreg_gcc_args = if targetUnregisterised let unreg_gcc_args = if targetUnregisterised
then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"] then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"]
else [] else []
...@@ -241,6 +243,7 @@ initSysTools mbMinusB ...@@ -241,6 +243,7 @@ initSysTools mbMinusB
| mkTablesNextToCode targetUnregisterised | mkTablesNextToCode targetUnregisterised
= ["-DTABLES_NEXT_TO_CODE"] = ["-DTABLES_NEXT_TO_CODE"]
| otherwise = [] | otherwise = []
cpp_args= map Option (words cpp_args_str)
gcc_args = map Option (words gcc_args_str gcc_args = map Option (words gcc_args_str
++ unreg_gcc_args ++ unreg_gcc_args
++ tntc_gcc_args) ++ tntc_gcc_args)
...@@ -283,10 +286,7 @@ initSysTools mbMinusB ...@@ -283,10 +286,7 @@ initSysTools mbMinusB
-- cpp is derived from gcc on all platforms -- cpp is derived from gcc on all platforms
-- HACK, see setPgmP below. We keep 'words' here to remember to fix -- HACK, see setPgmP below. We keep 'words' here to remember to fix
-- Config.hs one day. -- Config.hs one day.
let cpp_prog = gcc_prog
cpp_args = Option "-E"
: map Option (words cRAWCPP_FLAGS)
++ gcc_args
-- Other things being equal, as and ld are simply gcc -- Other things being equal, as and ld are simply gcc
gcc_link_args_str <- getSetting "C compiler link flags" gcc_link_args_str <- getSetting "C compiler link flags"
...@@ -602,6 +602,42 @@ figureLlvmVersion dflags = do ...@@ -602,6 +602,42 @@ figureLlvmVersion dflags = do
return Nothing) return Nothing)
return ver return ver
{- Note [Windows stack usage]
See: Trac #8870 (and #8834 for related info)
On Windows, occasionally we need to grow the stack. In order to do
this, we would normally just bump the stack pointer - but there's a
catch on Windows.
If the stack pointer is bumped by more than a single page, then the
pages between the initial pointer and the resulting location must be
properly committed by the Windows virtual memory subsystem. This is
only needed in the event we bump by more than one page (i.e 4097 bytes
or more).
Windows compilers solve this by emitting a call to a special function
called _chkstk, which does this committing of the pages for you.
The reason this was causing a segfault was because due to the fact the
new code generator tends to generate larger functions, we needed more
stack space in GHC itself. In the x86 codegen, we needed approximately
~12kb of stack space in one go, which caused the process to segfault,
as the intervening pages were not committed.
In the future, we should do the same thing, to make the problem
completely go away. In the mean time, we're using a workaround: we
instruct the linker to specify the generated PE as having an initial
reserved stack size of 8mb, as well as a initial *committed* stack
size of 8mb. The default committed size was previously only 4k.
Theoretically it's possible to still hit this problem if you request a
stack bump of more than 8mb in one go. But the amount of code
necessary is quite large, and 8mb "should be more than enough for
anyone" right now (he said, before millions of lines of code cried out
in terror).
-}
{- Note [Run-time linker info] {- Note [Run-time linker info]
...@@ -691,15 +727,20 @@ getLinkerInfo' dflags = do ...@@ -691,15 +727,20 @@ getLinkerInfo' dflags = do
-- that doesn't support --version. We can just assume that's -- that doesn't support --version. We can just assume that's
-- what we're using. -- what we're using.
return $ DarwinLD [] return $ DarwinLD []
OSiOS -> OSiOS ->
-- Ditto for iOS -- Ditto for iOS
return $ DarwinLD [] return $ DarwinLD []
OSMinGW32 -> OSMinGW32 ->
-- GHC doesn't support anything but GNU ld on Windows anyway. -- GHC doesn't support anything but GNU ld on Windows anyway.
-- Process creation is also fairly expensive on win32, so -- Process creation is also fairly expensive on win32, so
-- we short-circuit here. -- we short-circuit here.
return $ GnuLD $ map Option ["-Wl,--hash-size=31", return $ GnuLD $ map Option
"-Wl,--reduce-memory-overheads"] [ -- Reduce ld memory usage
"-Wl,--hash-size=31"
, "-Wl,--reduce-memory-overheads"
-- Increase default stack, see
-- Note [Windows stack usage]
, "-Xlinker", "--stack=0x800000,0x800000" ]
_ -> do _ -> do
-- In practice, we use the compiler as the linker here. Pass -- In practice, we use the compiler as the linker here. Pass
-- -Wl,--version to get linker version info. -- -Wl,--version to get linker version info.
...@@ -745,12 +786,15 @@ getCompilerInfo' dflags = do ...@@ -745,12 +786,15 @@ getCompilerInfo' dflags = do
-- Regular clang -- Regular clang
| any ("clang version" `isPrefixOf`) stde = | any ("clang version" `isPrefixOf`) stde =
return Clang return Clang
-- XCode 5.1 clang
| any ("Apple LLVM version 5.1" `isPrefixOf`) stde =
return AppleClang51
-- XCode 5 clang -- XCode 5 clang
| any ("Apple LLVM version" `isPrefixOf`) stde = | any ("Apple LLVM version" `isPrefixOf`) stde =
return Clang return AppleClang
-- XCode 4.1 clang -- XCode 4.1 clang
| any ("Apple clang version" `isPrefixOf`) stde = | any ("Apple clang version" `isPrefixOf`) stde =
return Clang return AppleClang
-- Unknown linker. -- Unknown linker.
| otherwise = fail "invalid -v output, or compiler is unsupported" | otherwise = fail "invalid -v output, or compiler is unsupported"
......
...@@ -559,7 +559,7 @@ Oh: two other reasons for injecting them late: ...@@ -559,7 +559,7 @@ Oh: two other reasons for injecting them late:
There is one sort of implicit binding that is injected still later, There is one sort of implicit binding that is injected still later,
namely those for data constructor workers. Reason (I think): it's namely those for data constructor workers. Reason (I think): it's
really just a code generation trick.... binding itself makes no sense. really just a code generation trick.... binding itself makes no sense.
See CorePrep Note [Data constructor workers]. See Note [Data constructor workers] in CorePrep.
\begin{code} \begin{code}
getTyConImplicitBinds :: TyCon -> [CoreBind] getTyConImplicitBinds :: TyCon -> [CoreBind]
......
...@@ -728,9 +728,10 @@ initializePicBase_ppc ArchPPC os picReg ...@@ -728,9 +728,10 @@ initializePicBase_ppc ArchPPC os picReg
fetchPC (BasicBlock bID insns) = fetchPC (BasicBlock bID insns) =
BasicBlock bID (PPC.FETCHPC picReg BasicBlock bID (PPC.FETCHPC picReg
: PPC.ADDIS tmp picReg (PPC.HI offsetToOffset)
: PPC.LD PPC.archWordSize tmp : PPC.LD PPC.archWordSize tmp
(PPC.AddrRegImm picReg offsetToOffset) (PPC.AddrRegImm tmp (PPC.LO offsetToOffset))
: PPC.ADD picReg picReg (PPC.RIReg tmp) : PPC.ADD picReg picReg (PPC.RIReg picReg)
: insns) : insns)
return (CmmProc info lab live (ListGraph blocks') : gotOffset : statics) return (CmmProc info lab live (ListGraph blocks') : gotOffset : statics)
......
...@@ -665,14 +665,20 @@ sccBlocks ...@@ -665,14 +665,20 @@ sccBlocks
sccBlocks blocks entries = map (fmap get_node) sccs sccBlocks blocks entries = map (fmap get_node) sccs
where where
sccs = stronglyConnCompFromG graph roots
graph = graphFromEdgedVertices nodes
-- nodes :: [(NatBasicBlock instr, Unique, [Unique])] -- nodes :: [(NatBasicBlock instr, Unique, [Unique])]
nodes = [ (block, id, getOutEdges instrs) nodes = [ (block, id, getOutEdges instrs)
| block@(BasicBlock id instrs) <- blocks ] | block@(BasicBlock id instrs) <- blocks ]
g1 = graphFromEdgedVertices nodes
reachable :: BlockSet
reachable = setFromList [ id | (_,id,_) <- reachablesG g1 roots ]
g2 = graphFromEdgedVertices [ node | node@(_,id,_) <- nodes
, id `setMember` reachable ]
sccs = stronglyConnCompG g2
get_node (n, _, _) = n get_node (n, _, _) = n
getOutEdges :: Instruction instr => [instr] -> [BlockId] getOutEdges :: Instruction instr => [instr] -> [BlockId]
......
...@@ -403,6 +403,9 @@ callClobberedRegs :: Platform -> [Reg] ...@@ -403,6 +403,9 @@ callClobberedRegs :: Platform -> [Reg]
-- caller-saves registers -- caller-saves registers
callClobberedRegs platform callClobberedRegs platform
| target32Bit platform = [eax,ecx,edx] ++ map regSingle (floatregnos platform) | target32Bit platform = [eax,ecx,edx] ++ map regSingle (floatregnos platform)
| platformOS platform == OSMinGW32
= [rax,rcx,rdx,r8,r9,r10,r11]
++ map regSingle (floatregnos platform)
| otherwise | otherwise
-- all xmm regs are caller-saves -- all xmm regs are caller-saves
-- caller-saves registers -- caller-saves registers
......
...@@ -1151,10 +1151,11 @@ atype :: { LHsType RdrName } ...@@ -1151,10 +1151,11 @@ atype :: { LHsType RdrName }
| TH_ID_SPLICE { LL $ mkHsSpliceTy $ L1 $ HsVar $ | TH_ID_SPLICE { LL $ mkHsSpliceTy $ L1 $ HsVar $
mkUnqual varName (getTH_ID_SPLICE $1) } mkUnqual varName (getTH_ID_SPLICE $1) }
-- see Note [Promotion] for the followings -- see Note [Promotion] for the followings
| SIMPLEQUOTE qconid { LL $ HsTyVar $ unLoc $2 } | SIMPLEQUOTE qcon { LL $ HsTyVar $ unLoc $2 }
| SIMPLEQUOTE '(' ')' { LL $ HsTyVar $ getRdrName unitDataCon }
| SIMPLEQUOTE '(' ctype ',' comma_types1 ')' { LL $ HsExplicitTupleTy [] ($3 : $5) } | SIMPLEQUOTE '(' ctype ',' comma_types1 ')' { LL $ HsExplicitTupleTy [] ($3 : $5) }
| SIMPLEQUOTE '[' comma_types0 ']' { LL $ HsExplicitListTy placeHolderKind $3 } | SIMPLEQUOTE '[' comma_types0 ']' { LL $ HsExplicitListTy placeHolderKind $3 }
| SIMPLEQUOTE var { LL $ HsTyVar $ unLoc $2 }
| '[' ctype ',' comma_types1 ']' { LL $ HsExplicitListTy placeHolderKind ($2 : $4) } | '[' ctype ',' comma_types1 ']' { LL $ HsExplicitListTy placeHolderKind ($2 : $4) }
| INTEGER {% mkTyLit $ LL $ HsNumTy $ getINTEGER $1 } | INTEGER {% mkTyLit $ LL $ HsNumTy $ getINTEGER $1 }
| STRING {% mkTyLit $ LL $ HsStrTy $ getSTRING $1 } | STRING {% mkTyLit $ LL $ HsStrTy $ getSTRING $1 }
...@@ -1475,18 +1476,18 @@ infixexp :: { LHsExpr RdrName } ...@@ -1475,18 +1476,18 @@ infixexp :: { LHsExpr RdrName }
exp10 :: { LHsExpr RdrName } exp10 :: { LHsExpr RdrName }
: '\\' apat apats opt_asig '->' exp : '\\' apat apats opt_asig '->' exp
{ LL $ HsLam (mkMatchGroup [LL $ Match ($2:$3) $4 { LL $ HsLam (mkMatchGroup FromSource [LL $ Match ($2:$3) $4
(unguardedGRHSs $6) (unguardedGRHSs $6)
]) } ]) }
| 'let' binds 'in' exp { LL $ HsLet (unLoc $2) $4 } | 'let' binds 'in' exp { LL $ HsLet (unLoc $2) $4 }
| '\\' 'lcase' altslist | '\\' 'lcase' altslist
{ LL $ HsLamCase placeHolderType (mkMatchGroup (unLoc $3)) } { LL $ HsLamCase placeHolderType (mkMatchGroup FromSource (unLoc $3)) }
| 'if' exp optSemi 'then' exp optSemi 'else' exp | 'if' exp optSemi 'then' exp optSemi 'else' exp
{% checkDoAndIfThenElse $2 $3 $5 $6 $8 >> {% checkDoAndIfThenElse $2 $3 $5 $6 $8 >>
return (LL $ mkHsIf $2 $5 $8) } return (LL $ mkHsIf $2 $5 $8) }
| 'if' ifgdpats {% hintMultiWayIf (getLoc $1) >> | 'if' ifgdpats {% hintMultiWayIf (getLoc $1) >>
return (LL $ HsMultiIf placeHolderType (reverse $ unLoc $2)) } return (LL $ HsMultiIf placeHolderType (reverse $ unLoc $2)) }
| 'case' exp 'of' altslist { LL $ HsCase $2 (mkMatchGroup (unLoc $4)) } | 'case' exp 'of' altslist { LL $ HsCase $2 (mkMatchGroup FromSource (unLoc $4)) }
| '-' fexp { LL $ NegApp $2 noSyntaxExpr } | '-' fexp { LL $ NegApp $2 noSyntaxExpr }
| 'do' stmtlist { L (comb2 $1 $2) (mkHsDo DoExpr (unLoc $2)) } | 'do' stmtlist { L (comb2 $1 $2) (mkHsDo DoExpr (unLoc $2)) }
......
...@@ -315,7 +315,7 @@ cvBindsAndSigs fb = go (fromOL fb) ...@@ -315,7 +315,7 @@ cvBindsAndSigs fb = go (fromOL fb)
go [] = (emptyBag, [], [], [], [], []) go [] = (emptyBag, [], [], [], [], [])
go (L l (SigD s) : ds) = (bs, L l s : ss, ts, tfis, dfis, docs) go (L l (SigD s) : ds) = (bs, L l s : ss, ts, tfis, dfis, docs)
where (bs, ss, ts, tfis, dfis, docs) = go ds where (bs, ss, ts, tfis, dfis, docs) = go ds
go (L l (ValD b) : ds) = ((FromSource, b') `consBag` bs, ss, ts, tfis, dfis, docs) go (L l (ValD b) : ds) = (b' `consBag` bs, ss, ts, tfis, dfis, docs)
where (b', ds') = getMonoBind (L l b) ds where (b', ds') = getMonoBind (L l b) ds
(bs, ss, ts, tfis, dfis, docs) = go ds' (bs, ss, ts, tfis, dfis, docs) = go ds'
go (L l (TyClD (FamDecl t)) : ds) = (bs, ss, L l t : ts, tfis, dfis, docs) go (L l (TyClD (FamDecl t)) : ds) = (bs, ss, L l t : ts, tfis, dfis, docs)
...@@ -735,7 +735,7 @@ checkFunBind msg lhs_loc fun is_infix pats opt_sig (L rhs_span grhss) ...@@ -735,7 +735,7 @@ checkFunBind msg lhs_loc fun is_infix pats opt_sig (L rhs_span grhss)
makeFunBind :: Located id -> Bool -> [LMatch id (LHsExpr id)] -> HsBind id makeFunBind :: Located id -> Bool -> [LMatch id (LHsExpr id)] -> HsBind id
-- Like HsUtils.mkFunBind, but we need to be able to set the fixity too -- Like HsUtils.mkFunBind, but we need to be able to set the fixity too
makeFunBind fn is_infix ms makeFunBind fn is_infix ms
= FunBind { fun_id = fn, fun_infix = is_infix, fun_matches = mkMatchGroup ms, = FunBind { fun_id = fn, fun_infix = is_infix, fun_matches = mkMatchGroup FromSource ms,
fun_co_fn = idHsWrapper, bind_fvs = placeHolderNames, fun_tick = Nothing } fun_co_fn = idHsWrapper, bind_fvs = placeHolderNames, fun_tick = Nothing }
checkPatBind :: SDoc checkPatBind :: SDoc
......
...@@ -37,55 +37,70 @@ Nota Bene: all Names defined in here should come from the base package ...@@ -37,55 +37,70 @@ Nota Bene: all Names defined in here should come from the base package
Note [Known-key names] Note [Known-key names]
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
It is *very* important that the compiler gives wired-in things and
things with "known-key" names the correct Uniques wherever they
occur. We have to be careful about this in exactly two places:
It is *very* important that the compiler gives wired-in things and things with "known-key" names 1. When we parse some source code, renaming the AST better yield an
the correct Uniques wherever they occur. We have to be careful about this in exactly two places: AST whose Names have the correct uniques
1. When we parse some source code, renaming the AST better yield an AST whose Names have the 2. When we read an interface file, the read-in gubbins better have
correct uniques the right uniques
2. When we read an interface file, the read-in gubbins better have the right uniques
This is accomplished through a combination of mechanisms: This is accomplished through a combination of mechanisms:
1. When parsing source code, the RdrName-decorated AST has some RdrNames which are Exact. These are 1. When parsing source code, the RdrName-decorated AST has some
wired-in RdrNames where the we could directly tell from the parsed syntax what Name to use. For RdrNames which are Exact. These are wired-in RdrNames where the
example, when we parse a [] in a type we can just insert an Exact RdrName Name with the listTyConKey. we could directly tell from the parsed syntax what Name to
use. For example, when we parse a [] in a type we can just insert
Currently, I believe this is just an optimisation: it would be equally valid to just output Orig an Exact RdrName Name with the listTyConKey.
RdrNames that correctly record the module etc we expect the final Name to come from. However,
were we to eliminate isTupleOcc_maybe it would become essential (see point 3). Currently, I believe this is just an optimisation: it would be
equally valid to just output Orig RdrNames that correctly record
2. The knownKeyNames (which consist of the basicKnownKeyNames from the module, and those names reachable the module etc we expect the final Name to come from. However,
via the wired-in stuff from TysWiredIn) are used to initialise the "original name cache" in IfaceEnv. were we to eliminate isBuiltInOcc_maybe it would become essential
This initialization ensures that when the type checker or renamer (both of which use IfaceEnv) look up (see point 3).
an original name (i.e. a pair of a Module and an OccName) for a known-key name they get the correct Unique.
2. The knownKeyNames (which consist of the basicKnownKeyNames from
the module, and those names reachable via the wired-in stuff from
TysWiredIn) are used to initialise the "OrigNameCache" in
IfaceEnv. This initialization ensures that when the type checker
or renamer (both of which use IfaceEnv) look up an original name
(i.e. a pair of a Module and an OccName) for a known-key name
they get the correct Unique.
This is the most important mechanism for ensuring that known-key
stuff gets the right Unique, and is why it is so important to
place your known-key names in the appropriate lists.
3. For "infinite families" of known-key names (i.e. tuples), we have
to be extra careful. Because there are an infinite number of
these things, we cannot add them to the list of known-key names
used to initialise the OrigNameCache. Instead, we have to
rely on never having to look them up in that cache.
This is the most important mechanism for ensuring that known-key stuff gets the right Unique, and is why This is accomplished through a variety of mechanisms:
it is so important to place your known-key names in the appropriate lists.
3. For "infinite families" of known-key names (i.e. tuples, Any tycons and implicit parameter TyCons), we a) The parser recognises them specially and generates an
have to be extra careful. Because there are an infinite number of these things, we cannot add them to Exact Name (hence not looked up in the orig-name cache)
the list of known-key names used to initialise the original name cache. Instead, we have to rely on
never having to look them up in that cache.
This is accomplished through a variety of mechanisms: b) The known infinite families of names are specially
serialised by BinIface.putName, with that special treatment
detected when we read back to ensure that we get back to the
correct uniques.
a) The known infinite families of names are specially serialised by BinIface.putName, with that special treatment Most of the infinite families cannot occur in source code,
detected when we read back to ensure that we get back to the correct uniques. so mechanisms (a,b) sufficies to ensure that they always have
the right Unique. In particular, implicit param TyCon names,
constraint tuples and Any TyCons cannot be mentioned by the
user.
b) Most of the infinite families cannot occur in source code, so mechanism a) sufficies to ensure that they c) IfaceEnv.lookupOrigNameCache uses isBuiltInOcc_maybe to map
always have the right Unique. In particular, implicit param TyCon names, constraint tuples and Any TyCons built-in syntax directly onto the corresponding name, rather
cannot be mentioned by the user. than trying to find it in the original-name cache.
c) Tuple TyCon/DataCon names have a special hack (isTupleOcc_maybe) that is used by the original name cache See also Note [Built-in syntax and the OrigNameCache]
lookup routine to detect tuple names and give them the right Unique. You might think that this is unnecessary
because tuple TyCon/DataCons are parsed as Exact RdrNames and *don't* appear as original names in interface files
(because serialization gives them special treatment), so we will never look them up in the original name cache.
However, there is a subtle reason why this is not the case: if you use setRdrNameSpace on an Exact RdrName
it may be turned into an Orig RdrName. So if the original name was an Exact tuple Name we might end up with
an Orig instead, which *will* lead to an original name cache query.
\begin{code} \begin{code}
module PrelNames ( module PrelNames (
Unique, Uniquable(..), hasKey, -- Re-exported for convenience Unique, Uniquable(..), hasKey, -- Re-exported for convenience
...@@ -250,8 +265,6 @@ basicKnownKeyNames ...@@ -250,8 +265,6 @@ basicKnownKeyNames
concatName, filterName, mapName, concatName, filterName, mapName,
zipName, foldrName, buildName, augmentName, appendName, zipName, foldrName, buildName, augmentName, appendName,
dollarName, -- The ($) apply function
-- FFI primitive types that are not wired-in. -- FFI primitive types that are not wired-in.
stablePtrTyConName, ptrTyConName, funPtrTyConName, stablePtrTyConName, ptrTyConName, funPtrTyConName,
int8TyConName, int16TyConName, int32TyConName, int64TyConName, int8TyConName, int16TyConName, int32TyConName, int64TyConName,
...@@ -476,10 +489,10 @@ mkMainModule_ m = mkModule mainPackageId m ...@@ -476,10 +489,10 @@ mkMainModule_ m = mkModule mainPackageId m
%************************************************************************ %************************************************************************
\begin{code} \begin{code}
mkTupleModule :: TupleSort -> Arity -> Module mkTupleModule :: TupleSort -> Module
mkTupleModule BoxedTuple _ = gHC_TUPLE mkTupleModule BoxedTuple = gHC_TUPLE
mkTupleModule ConstraintTuple _ = gHC_TUPLE mkTupleModule ConstraintTuple = gHC_TUPLE
mkTupleModule UnboxedTuple _ = gHC_PRIM mkTupleModule UnboxedTuple = gHC_PRIM
\end{code} \end{code}
...@@ -851,7 +864,7 @@ groupWithName = varQual gHC_EXTS (fsLit "groupWith") groupWithIdKey ...@@ -851,7 +864,7 @@ groupWithName = varQual gHC_EXTS (fsLit "groupWith") groupWithIdKey
fromStringName, otherwiseIdName, foldrName, buildName, augmentName, fromStringName, otherwiseIdName, foldrName, buildName, augmentName,
mapName, appendName, assertName, mapName, appendName, assertName,
breakpointName, breakpointCondName, breakpointAutoName, breakpointName, breakpointCondName, breakpointAutoName,
dollarName, opaqueTyConName :: Name opaqueTyConName :: Name
fromStringName = methName dATA_STRING (fsLit "fromString") fromStringClassOpKey fromStringName = methName dATA_STRING (fsLit "fromString") fromStringClassOpKey
otherwiseIdName = varQual gHC_BASE (fsLit "otherwise") otherwiseIdKey otherwiseIdName = varQual gHC_BASE (fsLit "otherwise") otherwiseIdKey
foldrName = varQual gHC_BASE (fsLit "foldr") foldrIdKey foldrName = varQual gHC_BASE (fsLit "foldr") foldrIdKey
...@@ -859,7 +872,6 @@ buildName = varQual gHC_BASE (fsLit "build") buildIdKey ...@@ -859,7 +872,6 @@ buildName = varQual gHC_BASE (fsLit "build") buildIdKey
augmentName = varQual gHC_BASE (fsLit "augment") augmentIdKey augmentName = varQual gHC_BASE (fsLit "augment") augmentIdKey
mapName = varQual gHC_BASE (fsLit "map") mapIdKey mapName = varQual gHC_BASE (fsLit "map") mapIdKey
appendName = varQual gHC_BASE (fsLit "++") appendIdKey appendName = varQual gHC_BASE (fsLit "++") appendIdKey
dollarName = varQual gHC_BASE (fsLit "$") dollarIdKey
assertName = varQual gHC_BASE (fsLit "assert") assertIdKey assertName = varQual gHC_BASE (fsLit "assert") assertIdKey
breakpointName = varQual gHC_BASE (fsLit "breakpoint") breakpointIdKey breakpointName = varQual gHC_BASE (fsLit "breakpoint") breakpointIdKey
breakpointCondName= varQual gHC_BASE (fsLit "breakpointCond") breakpointCondIdKey breakpointCondName= varQual gHC_BASE (fsLit "breakpointCond") breakpointCondIdKey
...@@ -1475,6 +1487,7 @@ rep1TyConKey = mkPreludeTyConUnique 156 ...@@ -1475,6 +1487,7 @@ rep1TyConKey = mkPreludeTyConUnique 156
typeNatKindConNameKey, typeSymbolKindConNameKey, typeNatKindConNameKey, typeSymbolKindConNameKey,
typeNatAddTyFamNameKey, typeNatMulTyFamNameKey, typeNatExpTyFamNameKey, typeNatAddTyFamNameKey, typeNatMulTyFamNameKey, typeNatExpTyFamNameKey,
typeNatLeqTyFamNameKey, typeNatSubTyFamNameKey typeNatLeqTyFamNameKey, typeNatSubTyFamNameKey
, typeSymbolCmpTyFamNameKey, typeNatCmpTyFamNameKey
:: Unique :: Unique
typeNatKindConNameKey = mkPreludeTyConUnique 160 typeNatKindConNameKey = mkPreludeTyConUnique 160
typeSymbolKindConNameKey = mkPreludeTyConUnique 161 typeSymbolKindConNameKey = mkPreludeTyConUnique 161
...@@ -1483,6 +1496,8 @@ typeNatMulTyFamNameKey = mkPreludeTyConUnique 163 ...@@ -1483,6 +1496,8 @@ typeNatMulTyFamNameKey = mkPreludeTyConUnique 163
typeNatExpTyFamNameKey = mkPreludeTyConUnique 164 typeNatExpTyFamNameKey = mkPreludeTyConUnique 164
typeNatLeqTyFamNameKey = mkPreludeTyConUnique 165 typeNatLeqTyFamNameKey = mkPreludeTyConUnique 165
typeNatSubTyFamNameKey = mkPreludeTyConUnique 166 typeNatSubTyFamNameKey = mkPreludeTyConUnique 166
typeSymbolCmpTyFamNameKey = mkPreludeTyConUnique 167
typeNatCmpTyFamNameKey = mkPreludeTyConUnique 168
ntTyConKey:: Unique ntTyConKey:: Unique
ntTyConKey = mkPreludeTyConUnique 174 ntTyConKey = mkPreludeTyConUnique 174
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
-- must be wired into the compiler nonetheless. C.f module TysPrim -- must be wired into the compiler nonetheless. C.f module TysPrim
module TysWiredIn ( module TysWiredIn (
-- * All wired in things -- * All wired in things
wiredInTyCons, wiredInTyCons, isBuiltInOcc_maybe,
-- * Bool -- * Bool
boolTy, boolTyCon, boolTyCon_RDR, boolTyConName, boolTy, boolTyCon, boolTyCon_RDR, boolTyConName,
...@@ -20,6 +20,8 @@ module TysWiredIn ( ...@@ -20,6 +20,8 @@ module TysWiredIn (
ltDataCon, ltDataConId, ltDataCon, ltDataConId,
eqDataCon, eqDataConId, eqDataCon, eqDataConId,
gtDataCon, gtDataConId, gtDataCon, gtDataConId,
promotedOrderingTyCon,
promotedLTDataCon, promotedEQDataCon, promotedGTDataCon,
-- * Char -- * Char
charTyCon, charDataCon, charTyCon_RDR, charTyCon, charDataCon, charTyCon_RDR,
...@@ -329,11 +331,11 @@ typeSymbolKind = TyConApp (promoteTyCon typeSymbolKindCon) [] ...@@ -329,11 +331,11 @@ typeSymbolKind = TyConApp (promoteTyCon typeSymbolKindCon) []
%************************************************************************ %************************************************************************
%* * %* *
\subsection[TysWiredIn-tuples]{The tuple types} Stuff for dealing with tuples
%* * %* *
%************************************************************************ %************************************************************************
Note [How tuples work] Note [How tuples work] See also Note [Known-key names] in PrelNames
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
* There are three families of tuple TyCons and corresponding * There are three families of tuple TyCons and corresponding
DataCons, (boxed, unboxed, and constraint tuples), expressed by the DataCons, (boxed, unboxed, and constraint tuples), expressed by the
...@@ -352,6 +354,68 @@ Note [How tuples work] ...@@ -352,6 +354,68 @@ Note [How tuples work]
are not serialised into interface files using OccNames at all. are not serialised into interface files using OccNames at all.
\begin{code} \begin{code}
isBuiltInOcc_maybe :: OccName -> Maybe Name
-- Built in syntax isn't "in scope" so these OccNames
-- map to wired-in Names with BuiltInSyntax
isBuiltInOcc_maybe occ
= case occNameString occ of
"[]" -> choose_ns listTyCon nilDataCon
":" -> Just consDataConName
"[::]" -> Just parrTyConName
"(##)" -> choose_ns unboxedUnitTyCon unboxedUnitDataCon
"()" -> choose_ns unitTyCon unitDataCon
'(':'#':',':rest -> parse_tuple UnboxedTuple 2 rest
'(':',':rest -> parse_tuple BoxedTuple 2 rest
_other -> Nothing
where
ns = occNameSpace occ
parse_tuple sort n rest
| (',' : rest2) <- rest = parse_tuple sort (n+1) rest2
| tail_matches sort rest = choose_ns (tupleTyCon sort n)
(tupleCon sort n)
| otherwise = Nothing
tail_matches BoxedTuple ")" = True
tail_matches UnboxedTuple "#)" = True
tail_matches _ _ = False
choose_ns tc dc
| isTcClsNameSpace ns = Just (getName tc)
| isDataConNameSpace ns = Just (getName dc)
| otherwise = Just (getName (dataConWorkId dc))
mkTupleOcc :: NameSpace -> TupleSort -> Arity -> OccName
mkTupleOcc ns sort ar = mkOccName ns str
where
-- No need to cache these, the caching is done in mk_tuple
str = case sort of
UnboxedTuple -> '(' : '#' : commas ++ "#)"
BoxedTuple -> '(' : commas ++ ")"
ConstraintTuple -> '(' : commas ++ ")"
commas = take (ar-1) (repeat ',')
-- Cute hack: we reuse the standard tuple OccNames (and hence code)
-- for fact tuples, but give them different Uniques so they are not equal.
--
-- You might think that this will go wrong because isBuiltInOcc_maybe won't
-- be able to tell the difference between boxed tuples and constraint tuples. BUT:
-- 1. Constraint tuples never occur directly in user code, so it doesn't matter
-- that we can't detect them in Orig OccNames originating from the user
-- programs (or those built by setRdrNameSpace used on an Exact tuple Name)
-- 2. Interface files have a special representation for tuple *occurrences*
-- in IfaceTyCons, their workers (in IfaceSyn) and their DataCons (in case
-- alternatives). Thus we don't rely on the OccName to figure out what kind
-- of tuple an occurrence was trying to use in these situations.
-- 3. We *don't* represent tuple data type declarations specially, so those
-- are still turned into wired-in names via isBuiltInOcc_maybe. But that's OK
-- because we don't actually need to declare constraint tuples thanks to this hack.
--
-- So basically any OccName like (,,) flowing to isBuiltInOcc_maybe will always
-- refer to the standard boxed tuple. Cool :-)
tupleTyCon :: TupleSort -> Arity -> TyCon tupleTyCon :: TupleSort -> Arity -> TyCon
tupleTyCon sort i | i > mAX_TUPLE_SIZE = fst (mk_tuple sort i) -- Build one specially tupleTyCon sort i | i > mAX_TUPLE_SIZE = fst (mk_tuple sort i) -- Build one specially
tupleTyCon BoxedTuple i = fst (boxedTupleArr ! i) tupleTyCon BoxedTuple i = fst (boxedTupleArr ! i)
...@@ -384,7 +448,7 @@ mk_tuple sort arity = (tycon, tuple_con) ...@@ -384,7 +448,7 @@ mk_tuple sort arity = (tycon, tuple_con)
UnboxedTuple -> Nothing UnboxedTuple -> Nothing
ConstraintTuple -> Nothing ConstraintTuple -> Nothing
modu = mkTupleModule sort arity modu = mkTupleModule sort
tc_name = mkWiredInName modu (mkTupleOcc tcName sort arity) tc_uniq tc_name = mkWiredInName modu (mkTupleOcc tcName sort arity) tc_uniq
(ATyCon tycon) BuiltInSyntax (ATyCon tycon) BuiltInSyntax
tc_kind = mkArrowKinds (map tyVarKind tyvars) res_kind tc_kind = mkArrowKinds (map tyVarKind tyvars) res_kind
...@@ -831,5 +895,19 @@ promotedTrueDataCon = promoteDataCon trueDataCon ...@@ -831,5 +895,19 @@ promotedTrueDataCon = promoteDataCon trueDataCon
promotedFalseDataCon = promoteDataCon falseDataCon promotedFalseDataCon = promoteDataCon falseDataCon
\end{code} \end{code}
Promoted Ordering
\begin{code}
promotedOrderingTyCon
, promotedLTDataCon
, promotedEQDataCon
, promotedGTDataCon
:: TyCon
promotedOrderingTyCon = promoteTyCon orderingTyCon
promotedLTDataCon = promoteDataCon ltDataCon
promotedEQDataCon = promoteDataCon eqDataCon
promotedGTDataCon = promoteDataCon gtDataCon
\end{code}
...@@ -47,7 +47,7 @@ import NameSet ...@@ -47,7 +47,7 @@ import NameSet
import RdrName ( RdrName, rdrNameOcc ) import RdrName ( RdrName, rdrNameOcc )
import SrcLoc import SrcLoc
import ListSetOps ( findDupsEq ) import ListSetOps ( findDupsEq )
import BasicTypes ( RecFlag(..), Origin ) import BasicTypes ( RecFlag(..) )
import Digraph ( SCC(..) ) import Digraph ( SCC(..) )
import Bag import Bag
import Outputable import Outputable
...@@ -275,7 +275,7 @@ rnValBindsLHS :: NameMaker ...@@ -275,7 +275,7 @@ rnValBindsLHS :: NameMaker
-> HsValBinds RdrName -> HsValBinds RdrName
-> RnM (HsValBindsLR Name RdrName) -> RnM (HsValBindsLR Name RdrName)
rnValBindsLHS topP (ValBindsIn mbinds sigs) rnValBindsLHS topP (ValBindsIn mbinds sigs)
= do { mbinds' <- mapBagM (wrapOriginLocM (rnBindLHS topP doc)) mbinds = do { mbinds' <- mapBagM (wrapLocM (rnBindLHS topP doc)) mbinds
; return $ ValBindsIn mbinds' sigs } ; return $ ValBindsIn mbinds' sigs }
where where
bndrs = collectHsBindsBinders mbinds bndrs = collectHsBindsBinders mbinds
...@@ -434,19 +434,26 @@ rnBindLHS name_maker _ bind@(FunBind { fun_id = name@(L nameLoc _) }) ...@@ -434,19 +434,26 @@ rnBindLHS name_maker _ bind@(FunBind { fun_id = name@(L nameLoc _) })
; return (bind { fun_id = L nameLoc newname }) } ; return (bind { fun_id = L nameLoc newname }) }
rnBindLHS name_maker _ bind@(PatSynBind{ patsyn_id = rdrname@(L nameLoc _) }) rnBindLHS name_maker _ bind@(PatSynBind{ patsyn_id = rdrname@(L nameLoc _) })
= do { addLocM checkConName rdrname = do { unless (isTopRecNameMaker name_maker) $
addErr localPatternSynonymErr
; addLocM checkConName rdrname
; name <- applyNameMaker name_maker rdrname ; name <- applyNameMaker name_maker rdrname
; return (bind{ patsyn_id = L nameLoc name }) } ; return (bind{ patsyn_id = L nameLoc name }) }
where
localPatternSynonymErr :: SDoc
localPatternSynonymErr
= hang (ptext (sLit "Illegal pattern synonym declaration"))
2 (ptext (sLit "Pattern synonym declarations are only valid in the top-level scope"))
rnBindLHS _ _ b = pprPanic "rnBindHS" (ppr b) rnBindLHS _ _ b = pprPanic "rnBindHS" (ppr b)
rnLBind :: (Name -> [Name]) -- Signature tyvar function rnLBind :: (Name -> [Name]) -- Signature tyvar function
-> (Origin, LHsBindLR Name RdrName) -> LHsBindLR Name RdrName
-> RnM ((Origin, LHsBind Name), [Name], Uses) -> RnM (LHsBind Name, [Name], Uses)
rnLBind sig_fn (origin, (L loc bind)) rnLBind sig_fn (L loc bind)
= setSrcSpan loc $ = setSrcSpan loc $
do { (bind', bndrs, dus) <- rnBind sig_fn bind do { (bind', bndrs, dus) <- rnBind sig_fn bind
; return ((origin, L loc bind'), bndrs, dus) } ; return (L loc bind', bndrs, dus) }
-- assumes the left-hands-side vars are in scope -- assumes the left-hands-side vars are in scope
rnBind :: (Name -> [Name]) -- Signature tyvar function rnBind :: (Name -> [Name]) -- Signature tyvar function
...@@ -574,7 +581,7 @@ trac ticket #1136. ...@@ -574,7 +581,7 @@ trac ticket #1136.
-} -}
--------------------- ---------------------
depAnalBinds :: Bag ((Origin, LHsBind Name), [Name], Uses) depAnalBinds :: Bag (LHsBind Name, [Name], Uses)
-> ([(RecFlag, LHsBinds Name)], DefUses) -> ([(RecFlag, LHsBinds Name)], DefUses)
-- Dependency analysis; this is important so that -- Dependency analysis; this is important so that
-- unused-binding reporting is accurate -- unused-binding reporting is accurate
...@@ -659,10 +666,9 @@ rnMethodBinds cls sig_fn binds ...@@ -659,10 +666,9 @@ rnMethodBinds cls sig_fn binds
; foldlM do_one (emptyBag, emptyFVs) (bagToList binds) } ; foldlM do_one (emptyBag, emptyFVs) (bagToList binds) }
where where
meth_names = collectMethodBinders binds meth_names = collectMethodBinders binds
do_one (binds,fvs) (origin,bind) do_one (binds,fvs) bind
= do { (bind', fvs_bind) <- rnMethodBind cls sig_fn bind = do { (bind', fvs_bind) <- rnMethodBind cls sig_fn bind
; let bind'' = mapBag (\bind -> (origin,bind)) bind' ; return (binds `unionBags` bind', fvs_bind `plusFV` fvs) }
; return (binds `unionBags` bind'', fvs_bind `plusFV` fvs) }
rnMethodBind :: Name rnMethodBind :: Name
-> (Name -> [Name]) -> (Name -> [Name])
...@@ -670,7 +676,7 @@ rnMethodBind :: Name ...@@ -670,7 +676,7 @@ rnMethodBind :: Name
-> RnM (Bag (LHsBindLR Name Name), FreeVars) -> RnM (Bag (LHsBindLR Name Name), FreeVars)
rnMethodBind cls sig_fn rnMethodBind cls sig_fn
(L loc bind@(FunBind { fun_id = name, fun_infix = is_infix (L loc bind@(FunBind { fun_id = name, fun_infix = is_infix
, fun_matches = MG { mg_alts = matches } })) , fun_matches = MG { mg_alts = matches, mg_origin = origin } }))
= setSrcSpan loc $ do = setSrcSpan loc $ do
sel_name <- wrapLocM (lookupInstDeclBndr cls (ptext (sLit "method"))) name sel_name <- wrapLocM (lookupInstDeclBndr cls (ptext (sLit "method"))) name
let plain_name = unLoc sel_name let plain_name = unLoc sel_name
...@@ -678,7 +684,7 @@ rnMethodBind cls sig_fn ...@@ -678,7 +684,7 @@ rnMethodBind cls sig_fn
(new_matches, fvs) <- bindSigTyVarsFV (sig_fn plain_name) $ (new_matches, fvs) <- bindSigTyVarsFV (sig_fn plain_name) $
mapFvRn (rnMatch (FunRhs plain_name is_infix) rnLExpr) matches mapFvRn (rnMatch (FunRhs plain_name is_infix) rnLExpr) matches
let new_group = mkMatchGroup new_matches let new_group = mkMatchGroup origin new_matches
when is_infix $ checkPrecMatch plain_name new_group when is_infix $ checkPrecMatch plain_name new_group
return (unitBag (L loc (bind { fun_id = sel_name return (unitBag (L loc (bind { fun_id = sel_name
...@@ -882,11 +888,11 @@ rnMatchGroup :: Outputable (body RdrName) => HsMatchContext Name ...@@ -882,11 +888,11 @@ rnMatchGroup :: Outputable (body RdrName) => HsMatchContext Name
-> (Located (body RdrName) -> RnM (Located (body Name), FreeVars)) -> (Located (body RdrName) -> RnM (Located (body Name), FreeVars))
-> MatchGroup RdrName (Located (body RdrName)) -> MatchGroup RdrName (Located (body RdrName))
-> RnM (MatchGroup Name (Located (body Name)), FreeVars) -> RnM (MatchGroup Name (Located (body Name)), FreeVars)
rnMatchGroup ctxt rnBody (MG { mg_alts = ms }) rnMatchGroup ctxt rnBody (MG { mg_alts = ms, mg_origin = origin })
= do { empty_case_ok <- xoptM Opt_EmptyCase = do { empty_case_ok <- xoptM Opt_EmptyCase
; when (null ms && not empty_case_ok) (addErr (emptyCaseErr ctxt)) ; when (null ms && not empty_case_ok) (addErr (emptyCaseErr ctxt))
; (new_ms, ms_fvs) <- mapFvRn (rnMatch ctxt rnBody) ms ; (new_ms, ms_fvs) <- mapFvRn (rnMatch ctxt rnBody) ms
; return (mkMatchGroup new_ms, ms_fvs) } ; return (mkMatchGroup origin new_ms, ms_fvs) }
rnMatch :: Outputable (body RdrName) => HsMatchContext Name rnMatch :: Outputable (body RdrName) => HsMatchContext Name
-> (Located (body RdrName) -> RnM (Located (body Name), FreeVars)) -> (Located (body RdrName) -> RnM (Located (body Name), FreeVars))
......