[project @ 2003-06-23 10:35:15 by simonpj]
authorsimonpj <unknown>
Mon, 23 Jun 2003 10:35:23 +0000 (10:35 +0000)
committersimonpj <unknown>
Mon, 23 Jun 2003 10:35:23 +0000 (10:35 +0000)
commitd28ba8c800901bea01f70c4719278c2a364cf9fc
tree5cae868eabe5c1734803cb6ae37b4a1c2dcbcef9
parentdd6fe03634149bfb79aa1878114514806161947b
[project @ 2003-06-23 10:35:15 by simonpj]
-------------------
Dealing with 'main'
-------------------

1.  In GHC 6.0, a module with no "module Main ... where" header
    elicited an error "main is not in scope" if 'main' is not defined.  We
    don't want this behaviour in GHCi.  This happened because the parser
    expanded the (absent) header to "module Main( main ) where", and the
    'main' in the export list isn't.

Solution: elaborate HsModule to record whether the 'module ..." header was
given explicitly by the user or not.

2.  Add a -main-is flag, and document it, so that you can have a 'main' function
that is not Main.main.  Summary of changes

* The -main-is flag nominates what the main function is to be (see the documentation).
No -main-is flag  says that the main function is Main.main
-main-is Foo.baz says that the main function is Foo.baz
-main-is Foo says that the main function is Foo.main
-main-is baz says that the main function is Main.baz

  Let's say  you say -main-is Foo.baz

* TcRnDriver injects the extra definition
$Mian.main :: IO t
$Main.main = baz
  in the module Foo.   Note the naming, which is a bit different than before;
  previously the extra defn was for Main.$main.  The RTS invokes zdMain_main_closure.

* CodeGen injects an extra initialisation block into module Foo, thus
stginit_zdMain {
stginit_Foo
}
  That ensures that the RTS can initialise stginit_zdMain.
16 files changed:
ghc/compiler/absCSyn/CLabel.lhs
ghc/compiler/codeGen/CodeGen.lhs
ghc/compiler/hsSyn/HsSyn.lhs
ghc/compiler/main/DriverFlags.hs
ghc/compiler/main/DriverState.hs
ghc/compiler/main/HscStats.lhs
ghc/compiler/main/Main.hs
ghc/compiler/parser/Parser.y
ghc/compiler/parser/ParserCore.y
ghc/compiler/prelude/PrelNames.lhs
ghc/compiler/rename/RnNames.lhs
ghc/compiler/typecheck/TcRnDriver.lhs
ghc/docs/users_guide/ffi-chap.sgml
ghc/docs/users_guide/phases.sgml
ghc/rts/Main.c
ghc/rts/Prelude.h