Mercurial > projects > ldc
annotate dmd/module.h @ 1146:1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
* Added #if IN_DMD versioning around DMD backend specific code in the D1 frontend, D2 is currently broken.
* All part of a greater cleanup scheme.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Thu, 26 Mar 2009 20:45:53 +0100 |
parents | b30fe7e1dbb9 |
children | dbe4af57b240 |
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; | |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
957
diff
changeset
|
33 namespace llvm { class Module; } |
336 | 34 #else |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
35 |
336 | 36 #ifdef IN_GCC |
37 union tree_node; typedef union tree_node elem; | |
38 #else | |
39 struct elem; | |
40 #endif | |
41 #endif | |
42 | |
43 struct Package : ScopeDsymbol | |
44 { | |
45 Package(Identifier *ident); | |
46 const char *kind(); | |
47 | |
48 static DsymbolTable *resolve(Array *packages, Dsymbol **pparent, Package **ppkg); | |
49 | |
50 Package *isPackage() { return this; } | |
51 | |
52 virtual void semantic(Scope *sc) { } | |
53 }; | |
54 | |
55 struct Module : Package | |
56 { | |
57 static Module *rootModule; | |
58 static DsymbolTable *modules; // symbol table of all modules | |
59 static Array amodules; // array of all modules | |
60 static Array deferred; // deferred Dsymbol's needing semantic() run on them | |
61 static unsigned dprogress; // progress resolving the deferred list | |
62 static void init(); | |
63 | |
64 static ClassDeclaration *moduleinfo; | |
65 | |
66 | |
67 const char *arg; // original argument name | |
68 ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration | |
69 File *srcfile; // input source file | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
70 |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
71 File *objfile; // output object file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
72 File *docfile; // output doc file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
73 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
|
74 |
336 | 75 unsigned errors; // if any errors in file |
76 unsigned numlines; // number of lines in source file | |
77 int isHtml; // if it is an HTML file | |
78 int isDocFile; // if it is a documentation input file, not D source | |
79 int needmoduleinfo; | |
80 #ifdef IN_GCC | |
81 int strictlyneedmoduleinfo; | |
82 #endif | |
83 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1052
diff
changeset
|
84 int selfimports; // 0: don't know, 1: does not, 2: does |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1052
diff
changeset
|
85 int selfImports(); // returns !=0 if module imports itself |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1052
diff
changeset
|
86 |
336 | 87 int insearch; |
88 Identifier *searchCacheIdent; | |
89 Dsymbol *searchCacheSymbol; // cached value of search | |
90 int searchCacheFlags; // cached flags | |
91 | |
92 int semanticstarted; // has semantic() been started? | |
93 int semanticdone; // has semantic() been done? | |
94 int root; // != 0 if this is a 'root' module, | |
95 // i.e. a module that will be taken all the | |
96 // way to an object file | |
97 Module *importedFrom; // module from command line we're imported from, | |
98 // i.e. a module that will be taken all the | |
99 // way to an object file | |
100 | |
101 Array *decldefs; // top level declarations for this Module | |
102 | |
103 Array aimports; // all imported modules | |
104 | |
105 ModuleInfoDeclaration *vmoduleinfo; | |
106 | |
107 unsigned debuglevel; // debug level | |
108 Array *debugids; // debug identifiers | |
109 Array *debugidsNot; // forward referenced debug identifiers | |
110 | |
111 unsigned versionlevel; // version level | |
112 Array *versionids; // version identifiers | |
113 Array *versionidsNot; // forward referenced version identifiers | |
114 | |
115 Macro *macrotable; // document comment macros | |
432 | 116 struct Escape *escapetable; // document comment escapes |
336 | 117 |
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
|
118 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
|
119 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
|
120 |
336 | 121 Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen); |
122 ~Module(); | |
123 | |
124 static Module *load(Loc loc, Array *packages, Identifier *ident); | |
125 | |
126 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
127 const char *kind(); | |
128 void read(Loc loc); // read file | |
129 #if IN_GCC | |
130 void parse(bool dump_source = false); // syntactic parse | |
131 #else | |
132 void parse(); // syntactic parse | |
133 #endif | |
751
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
703
diff
changeset
|
134 void semantic(Scope* unused_sc = NULL); // semantic analysis |
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
703
diff
changeset
|
135 void semantic2(Scope* unused_sc = NULL); // pass 2 semantic analysis |
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
703
diff
changeset
|
136 void semantic3(Scope* unused_sc = NULL); // pass 3 semantic analysis |
336 | 137 void inlineScan(); // scan for functions to inline |
138 #ifdef _DH | |
139 void genhdrfile(); // generate D import file | |
140 #endif | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
141 // void gensymfile(); |
336 | 142 void gendocfile(); |
143 int needModuleInfo(); | |
144 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
145 void deleteObjFile(); | |
146 void addDeferredSemantic(Dsymbol *s); | |
147 void runDeferredSemantic(); | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
849
diff
changeset
|
148 int imports(Module *m); |
336 | 149 |
150 // Back end | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
151 #if IN_DMD |
336 | 152 int doppelganger; // sub-module |
153 Symbol *cov; // private uint[] __coverage; | |
154 unsigned *covb; // bit array of valid code line numbers | |
155 | |
156 Symbol *sictor; // module order independent constructor | |
157 Symbol *sctor; // module constructor | |
158 Symbol *sdtor; // module destructor | |
159 Symbol *stest; // module unit test | |
160 | |
161 Symbol *sfilename; // symbol for filename | |
162 | |
163 Symbol *massert; // module assert function | |
164 Symbol *toModuleAssert(); // get module assert function | |
165 | |
166 Symbol *marray; // module array bounds function | |
167 Symbol *toModuleArray(); // get module array bounds function | |
168 | |
169 | |
170 static Symbol *gencritsec(); | |
171 elem *toEfilename(); | |
172 elem *toEmodulename(); | |
173 | |
174 Symbol *toSymbol(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
175 #endif |
336 | 176 void genmoduleinfo(); |
177 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
604
diff
changeset
|
178 // LDC |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
957
diff
changeset
|
179 llvm::Module* genLLVMModule(int multiobj); |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
180 void buildTargetFiles(); |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1052
diff
changeset
|
181 File* buildFilePath(const char* forcename, const char* path, const char* ext); |
336 | 182 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
|
183 |
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
|
184 bool llvmForceLogging; |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
185 |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
186 // 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
|
187 StringTable arrayfuncs; |
336 | 188 }; |
189 | |
190 | |
191 struct ModuleDeclaration | |
192 { | |
193 Identifier *id; | |
194 Array *packages; // array of Identifier's representing packages | |
195 | |
196 ModuleDeclaration(Array *packages, Identifier *id); | |
197 | |
198 char *toChars(); | |
199 }; | |
200 | |
201 #endif /* DMD_MODULE_H */ |