[cvs-nhc98] Fix many faults in the import/export mechanism.
Malcolm Wallace
malcolm@sparud.net
Wed, 17 Oct 2001 14:57:21 +0200 (CEST)
malcolm: Wed Oct 17 14:57:21 CEST 2001
Update of /usr/src/master/nhc/src/compiler98
In directory hinken:/tmp/cvs-serv28723
Modified Files:
CaseLib.hs DbgDataTrans.hs DbgDumpSRIDTable.hs
DbgDumpSRIDTableC.hs DbgReplaceConstr.hs DbgTrans.hs Export.hs
FFITrans.hs FSLib.hs GcodeFix.hs GcodeSpec.hs IExtract.hs
Import.hs Info.hs IntState.hs Need.hs ParseI.hs PreImp.hs
PreImport.hs Remove1_3.hs Rename.hs RenameLib.hs
ReportImports.hs TokenId.hs TokenInt.hs TypeUtil.hs
Log Message:
Fix many faults in the import/export mechanism.
New features
------------
* The compiler now treats explicitly named constructors and methods
correctly, e.g. in
module M (T(A,B), C(f,g)) where
or
import M (T(A,B), C(f,g))
only the constructors A and B of datatype T, and only the methods f and g
of class C, are exported/imported.
* The declaration
import qualified M (f)
is now accepted without complaint, whereas previously it needed to be
import qualified M (M.f)
in some circumstances.
* It is now possible to name selectors explicitly in an export/import
list, provided the type they select over is *not* exported/imported.
Implementation
--------------
The symbol table entries
InfoConstr, InfoMethod, InfoField
now each have an extra field 'ie' which determines whether an
individual constructor/method/field is to be re-exported, rather than
relying on the corresponding tag of the relevant InfoData/InfoClass
symbol.
The IE type is extended to distinguish the various cases of:
IEall - re-export with all constructors/methods e.g. C(..)
IEsome - re-export with some constructors/methods e.g. C(f,g)
IEabs - re-export with no constructors/methods e.g. C() or C
IEnone - do not re-export
and
IEsel - re-export this selected constructor/method individually
The interface file (.hi) now indicates which individual
constructors/methods are actually exported in the {-# NEED {C f g} #-}
annotation. Most importantly, *all* the actual constructors/methods
are listed in the datatype/class definition that follows, because the
numerical ordering is required to generate correct code. However, when
importing such a datatype/class, the non-visible constructors/methods
are renamed internally to something like "Unknown.Constructor_n" in
the symbol table, to ensure that they cannot be used. These new names
will appear any new interface file that is generated due to a further
re-export.