2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 by Digital Mars
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
21 struct ModuleInfoDeclaration
;
22 struct ClassDeclaration
;
23 struct ModuleDeclaration
;
26 struct VarDeclaration
;
31 union tree_node
; typedef union tree_node elem
;
36 struct Package
: ScopeDsymbol
38 Package(Identifier
*ident
);
41 static DsymbolTable
*resolve(Array
*packages
, Dsymbol
**pparent
, Package
**ppkg
);
43 Package
*isPackage() { return this; }
45 virtual void semantic(Scope
*sc
) { }
48 struct Module
: Package
50 static Module
*rootModule
;
51 static DsymbolTable
*modules
; // symbol table of all modules
52 static Array amodules
; // array of all modules
53 static Array deferred
; // deferred Dsymbol's needing semantic() run on them
54 static unsigned dprogress
; // progress resolving the deferred list
57 static ClassDeclaration
*moduleinfo
;
60 const char *arg
; // original argument name
61 ModuleDeclaration
*md
; // if !NULL, the contents of the ModuleDeclaration declaration
62 File
*srcfile
; // input source file
63 File
*objfile
; // output .obj file
64 File
*hdrfile
; // 'header' file
65 File
*symfile
; // output symbol file
66 File
*docfile
; // output documentation file
67 unsigned errors
; // if any errors in file
68 unsigned numlines
; // number of lines in source file
69 int isHtml
; // if it is an HTML file
70 int isDocFile
; // if it is a documentation input file, not D source
71 int isDltFile
; // if it is a Delight source file
74 int strictlyneedmoduleinfo
;
78 Identifier
*searchCacheIdent
;
79 Dsymbol
*searchCacheSymbol
; // cached value of search
80 int searchCacheFlags
; // cached flags
82 int semanticstarted
; // has semantic() been started?
83 int semanticdone
; // has semantic() been done?
84 int root
; // != 0 if this is a 'root' module,
85 // i.e. a module that will be taken all the
86 // way to an object file
87 Module
*importedFrom
; // module from command line we're imported from,
88 // i.e. a module that will be taken all the
89 // way to an object file
91 Array
*decldefs
; // top level declarations for this Module
93 Array aimports
; // all imported modules
95 ModuleInfoDeclaration
*vmoduleinfo
;
97 unsigned debuglevel
; // debug level
98 Array
*debugids
; // debug identifiers
99 Array
*debugidsNot
; // forward referenced debug identifiers
101 unsigned versionlevel
; // version level
102 Array
*versionids
; // version identifiers
103 Array
*versionidsNot
; // forward referenced version identifiers
105 Macro
*macrotable
; // document comment macros
106 Escape
*escapetable
; // document comment escapes
108 Module(char *arg
, Identifier
*ident
, int doDocComment
, int doHdrGen
, int isDltFile
);
111 static Module
*load(Loc loc
, Array
*packages
, Identifier
*ident
);
113 void toCBuffer(OutBuffer
*buf
, HdrGenState
*hgs
);
115 void setDocfile(); // set docfile member
116 void read(Loc loc
); // read file
118 void parse(bool dump_source
= false); // syntactic parse
120 void parse(); // syntactic parse
122 void semantic(); // semantic analysis
123 void semantic2(); // pass 2 semantic analysis
124 void semantic3(); // pass 3 semantic analysis
125 void inlineScan(); // scan for functions to inline
126 void setHdrfile(); // set hdrfile member
128 void genhdrfile(); // generate D import file
130 void genobjfile(int multiobj
);
133 int needModuleInfo();
134 Dsymbol
*search(Loc loc
, Identifier
*ident
, int flags
);
135 void deleteObjFile();
136 void addDeferredSemantic(Dsymbol
*s
);
137 void runDeferredSemantic();
141 int doppelganger
; // sub-module
142 Symbol
*cov
; // private uint[] __coverage;
143 unsigned *covb
; // bit array of valid code line numbers
145 Symbol
*sictor
; // module order independent constructor
146 Symbol
*sctor
; // module constructor
147 Symbol
*sdtor
; // module destructor
148 Symbol
*stest
; // module unit test
150 Symbol
*sfilename
; // symbol for filename
152 Symbol
*massert
; // module assert function
153 Symbol
*toModuleAssert(); // get module assert function
155 Symbol
*marray
; // module array bounds function
156 Symbol
*toModuleArray(); // get module array bounds function
159 static Symbol
*gencritsec();
161 elem
*toEmodulename();
164 void genmoduleinfo();
166 Module
*isModule() { return this; }
170 struct ModuleDeclaration
173 Array
*packages
; // array of Identifier's representing packages
175 ModuleDeclaration(Array
*packages
, Identifier
*id
);
180 #endif /* DMD_MODULE_H */