Mercurial > projects > ldc
annotate dmd/module.h @ 717:a26b0c5d5942
Merged DMD 1.036.
Improved comments a little in the runtime source code.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 17:06:17 +0200 |
parents | 06576ece1a1b |
children | dc8b8b7ea0c1 |
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 | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
68 |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
69 File *objfile; // output object file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
70 File *docfile; // output doc file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
71 File *hdrfile; // output hdr 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
|
72 |
336 | 73 unsigned errors; // if any errors in file |
74 unsigned numlines; // number of lines in source file | |
75 int isHtml; // if it is an HTML file | |
76 int isDocFile; // if it is a documentation input file, not D source | |
77 int needmoduleinfo; | |
78 #ifdef IN_GCC | |
79 int strictlyneedmoduleinfo; | |
80 #endif | |
81 | |
82 int insearch; | |
83 Identifier *searchCacheIdent; | |
84 Dsymbol *searchCacheSymbol; // cached value of search | |
85 int searchCacheFlags; // cached flags | |
86 | |
87 int semanticstarted; // has semantic() been started? | |
88 int semanticdone; // has semantic() been done? | |
89 int root; // != 0 if this is a 'root' module, | |
90 // i.e. a module that will be taken all the | |
91 // way to an object file | |
92 Module *importedFrom; // module from command line we're imported from, | |
93 // i.e. a module that will be taken all the | |
94 // way to an object file | |
95 | |
96 Array *decldefs; // top level declarations for this Module | |
97 | |
98 Array aimports; // all imported modules | |
99 | |
100 ModuleInfoDeclaration *vmoduleinfo; | |
101 | |
102 unsigned debuglevel; // debug level | |
103 Array *debugids; // debug identifiers | |
104 Array *debugidsNot; // forward referenced debug identifiers | |
105 | |
106 unsigned versionlevel; // version level | |
107 Array *versionids; // version identifiers | |
108 Array *versionidsNot; // forward referenced version identifiers | |
109 | |
110 Macro *macrotable; // document comment macros | |
432 | 111 struct Escape *escapetable; // document comment escapes |
336 | 112 |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
580
diff
changeset
|
113 int doDocComment; // enable generating doc comments for this module |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
580
diff
changeset
|
114 int doHdrGen; // enable generating header file for this module |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
580
diff
changeset
|
115 |
336 | 116 Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen); |
117 ~Module(); | |
118 | |
119 static Module *load(Loc loc, Array *packages, Identifier *ident); | |
120 | |
121 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
122 const char *kind(); | |
123 void read(Loc loc); // read file | |
124 #if IN_GCC | |
125 void parse(bool dump_source = false); // syntactic parse | |
126 #else | |
127 void parse(); // syntactic parse | |
128 #endif | |
129 void semantic(); // semantic analysis | |
130 void semantic2(); // pass 2 semantic analysis | |
131 void semantic3(); // pass 3 semantic analysis | |
132 void inlineScan(); // scan for functions to inline | |
133 #ifdef _DH | |
134 void genhdrfile(); // generate D import file | |
135 #endif | |
676
1f0a78174598
Make ldc call gcc to assemble.
Christian Kamm <kamm incasoftware de>
parents:
664
diff
changeset
|
136 void genobjfile(int multiobj, char** envp); |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
137 // void gensymfile(); |
336 | 138 void gendocfile(); |
139 int needModuleInfo(); | |
140 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
141 void deleteObjFile(); | |
142 void addDeferredSemantic(Dsymbol *s); | |
143 void runDeferredSemantic(); | |
144 | |
145 // Back end | |
146 | |
147 int doppelganger; // sub-module | |
148 Symbol *cov; // private uint[] __coverage; | |
149 unsigned *covb; // bit array of valid code line numbers | |
150 | |
151 Symbol *sictor; // module order independent constructor | |
152 Symbol *sctor; // module constructor | |
153 Symbol *sdtor; // module destructor | |
154 Symbol *stest; // module unit test | |
155 | |
156 Symbol *sfilename; // symbol for filename | |
157 | |
158 Symbol *massert; // module assert function | |
159 Symbol *toModuleAssert(); // get module assert function | |
160 | |
161 Symbol *marray; // module array bounds function | |
162 Symbol *toModuleArray(); // get module array bounds function | |
163 | |
164 | |
165 static Symbol *gencritsec(); | |
166 elem *toEfilename(); | |
167 elem *toEmodulename(); | |
168 | |
169 Symbol *toSymbol(); | |
170 void genmoduleinfo(); | |
171 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
604
diff
changeset
|
172 // LDC |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
173 void buildTargetFiles(); |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
174 File* buildFilePath(char* forcename, char* path, char* ext); |
336 | 175 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
|
176 |
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 bool llvmForceLogging; |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
178 |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
179 // array ops emitted in this module already |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
180 StringTable arrayfuncs; |
336 | 181 }; |
182 | |
183 | |
184 struct ModuleDeclaration | |
185 { | |
186 Identifier *id; | |
187 Array *packages; // array of Identifier's representing packages | |
188 | |
189 ModuleDeclaration(Array *packages, Identifier *id); | |
190 | |
191 char *toChars(); | |
192 }; | |
193 | |
194 #endif /* DMD_MODULE_H */ |