Fixed some lexing problems with DOS line-endings
[delight/core.git] / dmd / module.h
blob45e7060deb70385d06fd12d67100973dfb1033eb
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 by Digital Mars
4 // All Rights Reserved
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.
11 #ifndef DMD_MODULE_H
12 #define DMD_MODULE_H
14 #ifdef __DMC__
15 #pragma once
16 #endif /* __DMC__ */
18 #include "root.h"
19 #include "dsymbol.h"
21 struct ModuleInfoDeclaration;
22 struct ClassDeclaration;
23 struct ModuleDeclaration;
24 struct Macro;
25 struct Escape;
26 struct VarDeclaration;
27 struct Library;
29 // Back end
30 #if IN_GCC
31 union tree_node; typedef union tree_node elem;
32 #else
33 struct elem;
34 #endif
36 struct Package : ScopeDsymbol
38 Package(Identifier *ident);
39 char *kind();
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
55 static void init();
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
72 int needmoduleinfo;
73 #ifdef IN_GCC
74 int strictlyneedmoduleinfo;
75 #endif
77 int insearch;
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);
109 ~Module();
111 static Module *load(Loc loc, Array *packages, Identifier *ident);
113 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
114 char *kind();
115 void setDocfile(); // set docfile member
116 void read(Loc loc); // read file
117 #if IN_GCC
118 void parse(bool dump_source = false); // syntactic parse
119 #else
120 void parse(); // syntactic parse
121 #endif
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
127 #ifdef _DH
128 void genhdrfile(); // generate D import file
129 #endif
130 void genobjfile(int multiobj);
131 void gensymfile();
132 void gendocfile();
133 int needModuleInfo();
134 Dsymbol *search(Loc loc, Identifier *ident, int flags);
135 void deleteObjFile();
136 void addDeferredSemantic(Dsymbol *s);
137 void runDeferredSemantic();
139 // Back end
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();
160 elem *toEfilename();
161 elem *toEmodulename();
163 Symbol *toSymbol();
164 void genmoduleinfo();
166 Module *isModule() { return this; }
170 struct ModuleDeclaration
172 Identifier *id;
173 Array *packages; // array of Identifier's representing packages
175 ModuleDeclaration(Array *packages, Identifier *id);
177 char *toChars();
180 #endif /* DMD_MODULE_H */