Mercurial > projects > ldc
annotate dmd/module.h @ 503:7148a3f2b44b
merge
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 13 Aug 2008 15:43:34 +0200 |
parents | a34078905d01 |
children | 7824c21a58e3 |
rev | line source |
---|---|
336 | 1 |
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. | |
10 | |
11 #ifndef DMD_MODULE_H | |
12 #define DMD_MODULE_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 #include "dsymbol.h" | |
20 | |
21 struct ModuleInfoDeclaration; | |
22 struct ClassDeclaration; | |
23 struct ModuleDeclaration; | |
24 struct Macro; | |
25 struct Escape; | |
26 struct VarDeclaration; | |
27 struct Library; | |
28 | |
29 // Back end | |
30 #if IN_LLVM | |
31 struct DValue; | |
32 typedef DValue elem; | |
33 #else | |
34 #ifdef IN_GCC | |
35 union tree_node; typedef union tree_node elem; | |
36 #else | |
37 struct elem; | |
38 #endif | |
39 #endif | |
40 | |
41 struct Package : ScopeDsymbol | |
42 { | |
43 Package(Identifier *ident); | |
44 const char *kind(); | |
45 | |
46 static DsymbolTable *resolve(Array *packages, Dsymbol **pparent, Package **ppkg); | |
47 | |
48 Package *isPackage() { return this; } | |
49 | |
50 virtual void semantic(Scope *sc) { } | |
51 }; | |
52 | |
53 struct Module : Package | |
54 { | |
55 static Module *rootModule; | |
56 static DsymbolTable *modules; // symbol table of all modules | |
57 static Array amodules; // array of all modules | |
58 static Array deferred; // deferred Dsymbol's needing semantic() run on them | |
59 static unsigned dprogress; // progress resolving the deferred list | |
60 static void init(); | |
61 | |
62 static ClassDeclaration *moduleinfo; | |
63 | |
64 | |
65 const char *arg; // original argument name | |
66 ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration | |
67 File *srcfile; // input source file | |
68 File *objfile; // output .obj file | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
69 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
70 // LLVMDC |
336 | 71 File *bcfile; // output .bc file |
72 File *llfile; // output .ll file | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
73 |
336 | 74 File *hdrfile; // 'header' file |
75 File *symfile; // output symbol file | |
76 File *docfile; // output documentation file | |
77 unsigned errors; // if any errors in file | |
78 unsigned numlines; // number of lines in source file | |
79 int isHtml; // if it is an HTML file | |
80 int isDocFile; // if it is a documentation input file, not D source | |
81 int needmoduleinfo; | |
82 #ifdef IN_GCC | |
83 int strictlyneedmoduleinfo; | |
84 #endif | |
85 | |
86 int insearch; | |
87 Identifier *searchCacheIdent; | |
88 Dsymbol *searchCacheSymbol; // cached value of search | |
89 int searchCacheFlags; // cached flags | |
90 | |
91 int semanticstarted; // has semantic() been started? | |
92 int semanticdone; // has semantic() been done? | |
93 int root; // != 0 if this is a 'root' module, | |
94 // i.e. a module that will be taken all the | |
95 // way to an object file | |
96 Module *importedFrom; // module from command line we're imported from, | |
97 // i.e. a module that will be taken all the | |
98 // way to an object file | |
99 | |
100 Array *decldefs; // top level declarations for this Module | |
101 | |
102 Array aimports; // all imported modules | |
103 | |
104 ModuleInfoDeclaration *vmoduleinfo; | |
105 | |
106 unsigned debuglevel; // debug level | |
107 Array *debugids; // debug identifiers | |
108 Array *debugidsNot; // forward referenced debug identifiers | |
109 | |
110 unsigned versionlevel; // version level | |
111 Array *versionids; // version identifiers | |
112 Array *versionidsNot; // forward referenced version identifiers | |
113 | |
114 Macro *macrotable; // document comment macros | |
432 | 115 struct Escape *escapetable; // document comment escapes |
336 | 116 |
117 Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen); | |
118 ~Module(); | |
119 | |
120 static Module *load(Loc loc, Array *packages, Identifier *ident); | |
121 | |
122 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
123 const char *kind(); | |
124 void setDocfile(); // set docfile member | |
125 void read(Loc loc); // read file | |
126 #if IN_GCC | |
127 void parse(bool dump_source = false); // syntactic parse | |
128 #else | |
129 void parse(); // syntactic parse | |
130 #endif | |
131 void semantic(); // semantic analysis | |
132 void semantic2(); // pass 2 semantic analysis | |
133 void semantic3(); // pass 3 semantic analysis | |
134 void inlineScan(); // scan for functions to inline | |
135 void setHdrfile(); // set hdrfile member | |
136 #ifdef _DH | |
137 void genhdrfile(); // generate D import file | |
138 #endif | |
139 void genobjfile(int multiobj); | |
140 void gensymfile(); | |
141 void gendocfile(); | |
142 int needModuleInfo(); | |
143 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
144 void deleteObjFile(); | |
145 void addDeferredSemantic(Dsymbol *s); | |
146 void runDeferredSemantic(); | |
147 | |
148 // Back end | |
149 | |
150 int doppelganger; // sub-module | |
151 Symbol *cov; // private uint[] __coverage; | |
152 unsigned *covb; // bit array of valid code line numbers | |
153 | |
154 Symbol *sictor; // module order independent constructor | |
155 Symbol *sctor; // module constructor | |
156 Symbol *sdtor; // module destructor | |
157 Symbol *stest; // module unit test | |
158 | |
159 Symbol *sfilename; // symbol for filename | |
160 | |
161 Symbol *massert; // module assert function | |
162 Symbol *toModuleAssert(); // get module assert function | |
163 | |
164 Symbol *marray; // module array bounds function | |
165 Symbol *toModuleArray(); // get module array bounds function | |
166 | |
167 | |
168 static Symbol *gencritsec(); | |
169 elem *toEfilename(); | |
170 elem *toEmodulename(); | |
171 | |
172 Symbol *toSymbol(); | |
173 void genmoduleinfo(); | |
174 | |
175 // LLVMDC | |
176 Module *isModule() { return this; } | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
177 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
178 bool llvmForceLogging; |
336 | 179 }; |
180 | |
181 | |
182 struct ModuleDeclaration | |
183 { | |
184 Identifier *id; | |
185 Array *packages; // array of Identifier's representing packages | |
186 | |
187 ModuleDeclaration(Array *packages, Identifier *id); | |
188 | |
189 char *toChars(); | |
190 }; | |
191 | |
192 #endif /* DMD_MODULE_H */ |