Mercurial > projects > ldc
comparison dmd/module.h @ 1:c53b6e3fe49a trunk
[svn r5] Initial commit. Most things are very rough.
author | lindquist |
---|---|
date | Sat, 01 Sep 2007 21:43:27 +0200 |
parents | |
children | 0c77619e803b |
comparison
equal
deleted
inserted
replaced
0:a9e71648e74d | 1:c53b6e3fe49a |
---|---|
1 | |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2005 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 | |
28 // Back end | |
29 #if IN_GCC | |
30 union tree_node; typedef union tree_node elem; | |
31 #else | |
32 struct elem; | |
33 #endif | |
34 | |
35 struct Package : ScopeDsymbol | |
36 { | |
37 Package(Identifier *ident); | |
38 char *kind(); | |
39 | |
40 static DsymbolTable *resolve(Array *packages, Dsymbol **pparent, Package **ppkg); | |
41 | |
42 Package *isPackage() { return this; } | |
43 | |
44 virtual void semantic(Scope *sc) { } | |
45 }; | |
46 | |
47 struct Module : Package | |
48 { | |
49 static Module *rootModule; | |
50 static DsymbolTable *modules; // symbol table of all modules | |
51 static Array amodules; // array of all modules | |
52 static Array deferred; // deferred Dsymbol's needing semantic() run on them | |
53 static unsigned dprogress; // progress resolving the deferred list | |
54 static void init(); | |
55 | |
56 static ClassDeclaration *moduleinfo; | |
57 | |
58 | |
59 const char *arg; // original argument name | |
60 ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration | |
61 File *srcfile; // input source file | |
62 File *objfile; // output .obj file | |
63 File *bcfile; // output .bc 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 needmoduleinfo; | |
72 #ifdef IN_GCC | |
73 int strictlyneedmoduleinfo; | |
74 #endif | |
75 | |
76 int insearch; | |
77 Identifier *searchCacheIdent; | |
78 Dsymbol *searchCacheSymbol; // cached value of search | |
79 int searchCacheFlags; // cached flags | |
80 | |
81 int semanticstarted; // has semantic() been started? | |
82 int semanticdone; // has semantic() been done? | |
83 int root; // != 0 if this is a 'root' module, | |
84 // i.e. a module that will be taken all the | |
85 // way to an object file | |
86 Module *importedFrom; // module from command line we're imported from, | |
87 // i.e. a module that will be taken all the | |
88 // way to an object file | |
89 | |
90 Array *decldefs; // top level declarations for this Module | |
91 | |
92 Array aimports; // all imported modules | |
93 | |
94 ModuleInfoDeclaration *vmoduleinfo; | |
95 | |
96 unsigned debuglevel; // debug level | |
97 Array *debugids; // debug identifiers | |
98 Array *debugidsNot; // forward referenced debug identifiers | |
99 | |
100 unsigned versionlevel; // version level | |
101 Array *versionids; // version identifiers | |
102 Array *versionidsNot; // forward referenced version identifiers | |
103 | |
104 Macro *macrotable; // document comment macros | |
105 Escape *escapetable; // document comment escapes | |
106 | |
107 Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen); | |
108 ~Module(); | |
109 | |
110 static Module *load(Loc loc, Array *packages, Identifier *ident); | |
111 | |
112 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
113 char *kind(); | |
114 void setDocfile(); // set docfile member | |
115 void read(Loc loc); // read file | |
116 #if IN_GCC | |
117 void parse(bool dump_source = false); // syntactic parse | |
118 #else | |
119 void parse(); // syntactic parse | |
120 #endif | |
121 void semantic(); // semantic analysis | |
122 void semantic2(); // pass 2 semantic analysis | |
123 void semantic3(); // pass 3 semantic analysis | |
124 void inlineScan(); // scan for functions to inline | |
125 void setHdrfile(); // set hdrfile member | |
126 #ifdef _DH | |
127 void genhdrfile(); // generate D import file | |
128 #endif | |
129 void genobjfile(); | |
130 void gensymfile(); | |
131 void gendocfile(); | |
132 int needModuleInfo(); | |
133 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
134 void deleteObjFile(); | |
135 void addDeferredSemantic(Dsymbol *s); | |
136 void runDeferredSemantic(); | |
137 | |
138 // Back end | |
139 | |
140 Symbol *cov; // private uint[] __coverage; | |
141 unsigned *covb; // bit array of valid code line numbers | |
142 | |
143 Symbol *sctor; // module constructor | |
144 Symbol *sdtor; // module destructor | |
145 Symbol *stest; // module unit test | |
146 | |
147 Symbol *sfilename; // symbol for filename | |
148 | |
149 Symbol *massert; // module assert function | |
150 Symbol *toModuleAssert(); // get module assert function | |
151 | |
152 Symbol *marray; // module array bounds function | |
153 Symbol *toModuleArray(); // get module array bounds function | |
154 | |
155 | |
156 static Symbol *gencritsec(); | |
157 elem *toEfilename(); | |
158 elem *toEmodulename(); | |
159 | |
160 Symbol *toSymbol(); | |
161 void genmoduleinfo(); | |
162 | |
163 Module *isModule() { return this; } | |
164 }; | |
165 | |
166 | |
167 struct ModuleDeclaration | |
168 { | |
169 Identifier *id; | |
170 Array *packages; // array of Identifier's representing packages | |
171 | |
172 ModuleDeclaration(Array *packages, Identifier *id); | |
173 | |
174 char *toChars(); | |
175 }; | |
176 | |
177 #endif /* DMD_MODULE_H */ |