summaryrefslogtreecommitdiff
path: root/compiler/main/GHC.hs
Commit message (Collapse)AuthorAgeFilesLines
...
* Columns now start at 1, as lines already didIan Lynagh2009-11-271-3/+3
| | | | Also corrected a couple of line 0's to line 1
* improve the cyclic module error message as per #1856Simon Marlow2009-09-161-5/+12
| | | | | | | - remove the main: stuff - show the filenames - don't clutter the output with imports that aren't involved in the cycle
* remove Haddock-lexing/parsing/renaming from GHCIsaac Dupree2009-08-261-15/+1
|
* Make updates to the Finder caches atomic. Well, almost.Thomas Schilling2009-08-161-2/+5
| | | | | | | | Flushing and uncaching a single module is not completely atomic since both caches a cleared separately. However, flushing is only done when changing the working directory which shouldn't be done concurrently to other threads. Uncaching is only done in 'summariseModule' which requires some more work to become thread-safe anyway.
* refactor: use packageConfigId in place of mkPackageId . packageSimon Marlow2009-07-161-1/+1
|
* Remove unused importsIan Lynagh2009-07-071-1/+0
|
* Trim unused imports detected by new unused-import codesimonpj@microsoft.com2009-07-061-3/+3
|
* Support for -fwarn-unused-do-bind and -fwarn-wrong-do-bind, as per #3263Max Bolingbroke2009-07-011-3/+3
|
* Fix the flag used to force linking when we are making a shared libraryDuncan Coutts2009-06-041-1/+1
| | | | | | | This is a correction to the patch: * When linking a shared library with --make, always do the link step which used the wrong flag in making the decision. It used -dynamic whereas the correct flag is -shared.
* When linking a shared library with --make, always do the link stepDuncan Coutts2009-05-191-1/+1
| | | | | | | | Without -shared, the default target is a binary and in that case it makes sense for --make to not try and link a binary when there is no Main module. But for a shared library the user already has to specify -shared and there's no reason a shared lib should contain any Main module or main function.
* FIX #2682: banish silly cases of the "module Foo is not loaded" errorSimon Marlow2009-04-211-17/+53
| | | | | | | | | | | | | | | | | | | | | | In GHCi if you say 'import Foo' meaning to load a package module Foo, and Foo.hs is found on the search path, then GHCi replies "module Foo is not loaded", because it knows Foo refers to the source file rather than the package module, and you haven't loaded that module with :load. This is consistent with the usual module-finding semantics. However, it isn't particularly useful. And it leads to silly problems like not being able to start GHCi when you happen to be sitting in libraries/base, because GHCi thinks the Prelude hasn't been loaded. So now I've made a slight change to the way that 'import M' works: if M is loaded, then it refers to the loaded module, otherwise it looks for a package module M. This does what the reporter of #2682 wanted, and since it turns an error condition into meaningful behaviour it can't break anything. The only undesirable consequence is that 'import M' might refer to a different M than ':load M'. Hopefully that won't lead to confusion.
* FIX #2976: fix buggy implementation of shadowing in GHC.getBindingsSimon Marlow2009-03-111-9/+3
|
* The default cleanup handler should /always/ delete the temp filesIan Lynagh2008-12-111-1/+1
| | | | | | Not only if there has been an exception. It worked for GHC anyway, as it was getting an ExitSuccess exception, but GHC API clients shouldn't be required to do that.
* Document 'loadModule'.Thomas Schilling2008-12-021-1/+7
|
* Add 'needsTemplateHaskell' utility function and document why one mightThomas Schilling2008-12-021-0/+10
| | | | want to use it.
* Documentation only.Thomas Schilling2008-12-021-7/+36
|
* Export 'succeeded' and 'failed' helper functions.Thomas Schilling2008-12-021-1/+2
|
* Put full ImportDecls in ModSummary instead of just ModuleNamesSimon Marlow2008-12-021-10/+19
| | | | | | | | ... and use it to make ghc -M generate correct cross-package dependencies when using package-qualified imports (needed for the new build system). Since we're already parsing the ImportDecl from the source file, there seems no good reason not to keep it in the ModSummary, it might be useful for other things too.
* Let 'loadModule' generate proper code depending on the 'hscTarget'.Thomas Schilling2008-11-281-8/+12
| | | | | | | With this change it should be possible to perform something similar to 'load' by traversing the module graph in dependency order and calling '{parse,typecheck,load}Module' on each. Of course, if you want smart recompilation checking you should still use 'load'.
* Use a per-session data structure for callbacks. Make 'WarnErrLogger'Thomas Schilling2008-11-281-15/+23
| | | | | | | | | | | | | | | | | | | | | part of it. Part of the GHC API essentially represents a compilation framework. The difference of a *framework* as opposed to a *library* is that the overall structure of the functionality is pre-defined but certain details can be customised via callbacks. (Also known as the Hollywood Principle: "Don't call us, we'll call you.") This patch introduces a per-session data structure that contains all the callbacks instead of adding lots of small function arguments whenever we want to give the user more control over certain parts of the API. This should also help with future changes: Adding a new callback doesn't break old code since code that doesn't know about the new callback will use the (hopefully sane) default implementation. Overall, however, we should try and keep the number of callbacks small and well-defined (and provide useful defaults) and use simple library routines for the rest.
* Improve error message for #2739 (but no fix).Thomas Schilling2008-11-271-1/+3
| | | | | | | This patch changes 'loadModule' to define a fake linkable. The previous implementation of providing no linkable at all violated a pre-condition in the ByteCode linker. This doesn't fix #2739, but it improves the error message a bit.
* Collect instead of print warnings in 'warnUnnecessarySourceImports'.Thomas Schilling2008-11-271-4/+4
|
* Force recompilation of BCOs when they were compiled in HscNothing mode.Thomas Schilling2008-11-261-1/+16
| | | | | | | | | Previously, loading a set of modules in HscNothing mode and then switching to HscInterpreted could lead to crashes since modules compiled with HscNothing were thought to be valid bytecode objects. This patch forces recompilation in these cases, hence switching between HscNothing and HscInterpreted should be safe now.
* Major clean-up of HscMain.Thomas Schilling2008-11-251-37/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch entails a major restructuring of HscMain and a small bugfix to MkIface (which required the restructuring in HscMain). In MkIface: - mkIface* no longer outputs orphan warnings directly and also no longer quits GHC when -Werror is set. Instead, errors are reported using the common IO (Messages, Maybe result) scheme. In HscMain: - Get rid of the 'Comp' monad. This monad was mostly GhcMonad + two reader arguments, a ModSummary for the currently compiled module and a possible old interface. The latter actually lead to a small space-leak since only its hash was needed (to check whether the newly-generated interface file was the same as the original one). Functions originally of type 'Comp' now only take the arguments that they actually need. This leads to slighly longer argument lists in some places, however, it is now much easier to see what is actually going on. - Get rid of 'myParseModule'. Rename 'parseFile' to 'hscParse'. - Join 'deSugarModule' and 'hscDesugar' (keeping the latter). - Rename 'typecheck{Rename}Module{'}' to 'hscTypecheck{Rename}'. One variant keeps the renamed syntax, the other doesn't. - Parameterise 'HscStatus', so that 'InteractiveStatus' is just a different parameterisation of 'HscStatus'. - 'hscCompile{OneShot,Batch,Nothing,Interactive}' are now implemented using a (local) typeclass called 'HsCompiler'. The idea is to make the common structure more obvious. Using this typeclass we now have two functions 'genericHscCompile' (original 'hscCompiler') and 'genericHscRecompile' (original 'genComp') describing the default pipeline. The methods of the typeclass describe a sort of "hook" interface (in OO-terms this would be called the "template method" pattern). One problem with this approach is that we parameterise over the /result/ type which, in fact, is not actually different for "nothing" and "batch" mode. To avoid functional dependencies or associated types, we use type tags to make them artificially different and parameterise the type class over the result type. A perhaps better approach might be to use records instead. - Drop some redundant 'HscEnv' arguments. These were likely different from what 'getSession' would return because during compilation we temporarily set the module's DynFlags as well as a few other fields. We now use the 'withTempSession' combinator to temporarily change the 'HscEnv' and automatically restore the original session after the enclosed action has returned (even in case of exceptions). - Rename 'hscCompile' to 'hscGenHardCode' (since that is what it does). Calls in 'GHC' and 'DriverPipeline' accordingly needed small adaptions.
* Change 'handleFlagWarnings' to throw exceptions instead of dying.Thomas Schilling2008-11-221-2/+2
| | | | It now uses the standard warning log and error reporting mechanism.
* Throw SourceErrors instead of ProgramErrors in main/HeaderInfo.Thomas Schilling2008-11-211-2/+2
| | | | | Parse errors during dependency analysis or options parsing really shouldn't kill GHC; this is particularly annoying for GHC API clients.
* Fix a bug in the recompilation checking logic.Thomas Schilling2008-11-131-54/+64
| | | | | | | | | | | | | | | Previously, using target HscNothing resulted in unnessesary recompilation because 'upsweep_mod' treated HscInterface specially. This patch changes relaxes this. When running GHC with debug level 5, 'upsweep_mod' will now also be more verbose about what it is doing. There is (at least) one possible remaining problem, though: When using target 'HscNothing' we generate a fake linkable to signal that we have processed a module. When switching to 'HscInterpreted' this may cause objects to not be recompiled. Switching from HscNothing to HscInterpreted is therefore only safe if we unload everything first.
* Documentation only. Clarify that 'load*' may indeed throw SourceErrors.Thomas Schilling2008-11-101-1/+9
| | | | | I don't think errors during dependency analysis should be passed to the logger.
* Add 'packageDbModules' function to GHC API.Thomas Schilling2008-11-101-0/+21
| | | | | | | This function returns a list of all modules available through the package DB. MERGE TO 6.10
* Export typeclasses for accessing compiler results.Thomas Schilling2008-10-281-0/+1
| | | | MERGE TO 6.10.
* Minor refactoring.Thomas Schilling2008-10-281-3/+1
|
* Add (a) CoreM monad, (b) new Annotations featuresimonpj@microsoft.com2008-10-301-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch, written by Max Bolingbroke, does two things 1. It adds a new CoreM monad (defined in simplCore/CoreMonad), which is used as the top-level monad for all the Core-to-Core transformations (starting at SimplCore). It supports * I/O (for debug printing) * Unique supply * Statistics gathering * Access to the HscEnv, RuleBase, Annotations, Module The patch therefore refactors the top "skin" of every Core-to-Core pass, but does not change their functionality. 2. It adds a completely new facility to GHC: Core "annotations". The idea is that you can say {#- ANN foo (Just "Hello") #-} which adds the annotation (Just "Hello") to the top level function foo. These annotations can be looked up in any Core-to-Core pass, and are persisted into interface files. (Hence a Core-to-Core pass can also query the annotations of imported things.) Furthermore, a Core-to-Core pass can add new annotations (eg strictness info) of its own, which can be queried by importing modules. The design of the annotation system is somewhat in flux. It's designed to work with the (upcoming) dynamic plug-ins mechanism, but is meanwhile independently useful. Do not merge to 6.10!
* Improve haddock documentation for 'GHC.topSortModuleGraph'.Thomas Schilling2008-10-141-4/+5
|
* Re-export Located(..) and related functionsSimon Marlow2008-10-201-0/+14
| | | | So that clients don't need to import SrcLoc
* fix #2636: throw missing module errors as SourceErrors, not ErrMsgSimon Marlow2008-10-101-15/+8
|
* Make 'getModSummary' deterministic.Thomas Schilling2008-10-081-5/+6
|
* Use an extensible-exceptions package when bootstrappingIan Lynagh2008-10-031-22/+3
| | | | | | | Ifdefs for whether we had extensible exceptions or not were spreading through GHC's source, and things would only have got worse for the next 2-3 years, so instead we now use an implementation of extensible exceptions built on top of the old exception type.
* Let parseModule take a ModSummary like checkAndLoadModule did.Thomas Schilling2008-10-021-5/+12
| | | | | | | | | To get the ModSummary for a ModuleName getModSummary can be used. It's not called find* or lookup* because it assumes that the module is in the module graph and throws an exception if it cannot be found. Overall, I'm not quite sure about the usefulness of this function since the user has no control about which filetype to grab (hs or hs-boot).
* Generalise type of 'defaultErrorHandler' so it can be used inside a Ghc session.Thomas Schilling2008-09-211-6/+7
|
* Disallow package flags in OPTIONS_GHC pragmas (#2499)Simon Marlow2008-09-231-1/+1
|
* Fix a couple of issues with :printpepe2008-09-181-11/+7
| | | | | | | | | | | | - Ticket #1995: Unsoundness with newtypes - Ticket #2475: "Can't unify" error when stopped at an exception In addition this patch adds the following: - Unfailingness: RTTI cannot panic anymore. In case of failure, it recovers gracefully by returning the "I know nothing" type - A -ddump-rtti flag
* RichTokenStream supportChaddai Fouche2008-09-181-6/+85
| | | | | | | | | | | | | | | | | | | | | | This patch adds support for raw token streams, that contain more information than normal token streams (they contains comments at least). The "lexTokenStream" function brings this support to the Lexer module. In addition to that, functions have been added to the GHC module to make easier to recover of the token stream of a module ("getTokenStream"). Building on that, I added what could be called "rich token stream": token stream to which have been added the source string corresponding to each token, the function addSourceToToken takes a StringBuffer and a starting SrcLoc and a token stream and build this rich token stream. getRichTokenStream is a convenience function to get a module rich token stream. "showRichTokenStream" use the SrcLoc information in such a token stream to get a string similar to the original source (except unsignificant whitespaces). Thus "putStrLn . showRichTokenStream =<< getRichTokenStream s mod" should print a valid module source, the interesting part being to modify the token stream between the get and the show of course.
* Change 'loadWithCompiler' callback argument to just print warnings.Thomas Schilling2008-09-171-49/+34
| | | | | | | | | | Rename function accordingly. The callback wasn't very flexible to begin with. There's pretty much no way around to calling 'compile' inside that callback since 'upsweep' depends on certain side effects of compile. It therefore makes more sense to restrict the callback to its intended use only, namely to log warnings and errors.
* Use 'GhcMonad' in GHC and split up checkModule into phases.Thomas Schilling2008-09-141-431/+612
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm not sure I covered all the ways of throwing errors in the code. Some functions throw ProgramErrors, some error messages. It's still quite a mess, but we're getting closer. The missing cases are mostly errors that cannot be fixed by the API client either or are a result of wrong usage, so are in any case fatal. One function, 'getModuleInfo', still returns a 'Maybe', but the documentation suggests it should always succeed. So I may change that soon. The spit-up of of 'checkModule' has pros and cons. The various forms of 'checkModule*' now become: checkAndLoadModule ms False ~~> loadModule =<< typecheckModule =<< parseModule (ms_mod_name ms) checkAndLoadModule ms True ~~> loadModule =<< desugarModule =<< typecheckModule =<< parseModule (ms_mod_name ms) checkModule mn False ~~> typecheckModule =<< parseModule mn checkModule mn True ~~> desugarModule =<< typecheckModule =<< parseModule mn The old APIs cannot easily be provided, since the result type would be different depending on the second argument. However, a more convenient API can be modelled on top of these four functions ({parse,typecheck,desugar,load}Module).
* re-fix of #1205, fix #2542Simon Marlow2008-08-271-25/+49
| | | | | | | | | | | | | | | New form of :load in GHCi: > :load *A forces A to be loaded as byte-code. See the manual for details. The previous behaviour for specifying filenames vs. module names on the command line and in :load has been restored. The Target datatype has a new Bool field, which is True if the target is allowed to be loaded from compiled code, or False otherwise, so this functionality is available via the GHC API. guessTarget understands the *-prefix form for specifying targets.
* Give locations of flag warnings/errorsIan Lynagh2008-08-261-2/+2
|
* Separate the static flag parser from the static global variablesIan Lynagh2008-08-261-0/+1
| | | | | This allows us to avoid a module import loop: CmdLineParser -> SrcLoc -> Outputable -> StaticFlags -> CmdLineParser
* Add -XPackageImports, new syntax for package-qualified importsSimon Marlow2008-08-051-1/+1
| | | | | | | | | | | | | | | | | Now you can say import "network" Network.Socket and get Network.Socket from package "network", even if there are multiple Network.Socket modules in scope from different packages and/or the current package. This is not really intended for general use, it's mainly so that we can build backwards-compatible versions of packages, where we need to be able to do module GHC.Base (module New.GHC.Base) where import "base" GHC.Base as New.GHC.Base
* Follow Digraph changes in GHC; patch from Max BolingbrokeIan Lynagh2008-08-071-71/+74
|
* Split the Id related functions out from Var into Id, document Var and some of IdMax Bolingbroke2008-07-311-1/+1
|