Mercurial > projects > ldc
annotate dmd/module.h @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | 1d2d1aa16841 |
children |
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 | |
1364
46f6365a50d7
Added IrTypeFunction and IrTypeDelegate and eliminated IrDType. This means the Type::ir field can be removed. It's the final part needed for the move to a slightly more sane type system. Now the whole thing just needs to be cleaned up :P
Tomas Lindquist Olsen <tomas.l.olsen gmail com>
parents:
1147
diff
changeset
|
31 class Ir; |
336 | 32 struct DValue; |
33 typedef DValue elem; | |
1535
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1364
diff
changeset
|
34 namespace llvm { |
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1364
diff
changeset
|
35 class LLVMContext; |
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1364
diff
changeset
|
36 class Module; |
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1364
diff
changeset
|
37 } |
336 | 38 #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
|
39 |
336 | 40 #ifdef IN_GCC |
41 union tree_node; typedef union tree_node elem; | |
42 #else | |
43 struct elem; | |
44 #endif | |
45 #endif | |
46 | |
47 struct Package : ScopeDsymbol | |
48 { | |
49 Package(Identifier *ident); | |
50 const char *kind(); | |
51 | |
52 static DsymbolTable *resolve(Array *packages, Dsymbol **pparent, Package **ppkg); | |
53 | |
54 Package *isPackage() { return this; } | |
55 | |
56 virtual void semantic(Scope *sc) { } | |
57 }; | |
58 | |
59 struct Module : Package | |
60 { | |
61 static Module *rootModule; | |
62 static DsymbolTable *modules; // symbol table of all modules | |
63 static Array amodules; // array of all modules | |
64 static Array deferred; // deferred Dsymbol's needing semantic() run on them | |
65 static unsigned dprogress; // progress resolving the deferred list | |
66 static void init(); | |
67 | |
68 static ClassDeclaration *moduleinfo; | |
69 | |
70 | |
71 const char *arg; // original argument name | |
72 ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration | |
73 File *srcfile; // input source file | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
74 |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
75 File *objfile; // output object file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
76 File *docfile; // output doc file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
77 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
|
78 |
336 | 79 unsigned errors; // if any errors in file |
80 unsigned numlines; // number of lines in source file | |
81 int isHtml; // if it is an HTML file | |
82 int isDocFile; // if it is a documentation input file, not D source | |
83 int needmoduleinfo; | |
84 #ifdef IN_GCC | |
85 int strictlyneedmoduleinfo; | |
86 #endif | |
87 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1052
diff
changeset
|
88 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
|
89 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
|
90 |
336 | 91 int insearch; |
92 Identifier *searchCacheIdent; | |
93 Dsymbol *searchCacheSymbol; // cached value of search | |
94 int searchCacheFlags; // cached flags | |
95 | |
96 int semanticstarted; // has semantic() been started? | |
1587 | 97 int semanticRun; // has semantic() been done? |
336 | 98 int root; // != 0 if this is a 'root' module, |
99 // i.e. a module that will be taken all the | |
100 // way to an object file | |
101 Module *importedFrom; // module from command line we're imported from, | |
102 // i.e. a module that will be taken all the | |
103 // way to an object file | |
104 | |
105 Array *decldefs; // top level declarations for this Module | |
106 | |
107 Array aimports; // all imported modules | |
108 | |
109 ModuleInfoDeclaration *vmoduleinfo; | |
110 | |
111 unsigned debuglevel; // debug level | |
112 Array *debugids; // debug identifiers | |
113 Array *debugidsNot; // forward referenced debug identifiers | |
114 | |
115 unsigned versionlevel; // version level | |
116 Array *versionids; // version identifiers | |
117 Array *versionidsNot; // forward referenced version identifiers | |
118 | |
119 Macro *macrotable; // document comment macros | |
432 | 120 struct Escape *escapetable; // document comment escapes |
336 | 121 |
1587 | 122 int doDocComment; // enable generating doc comments for this module |
123 int doHdrGen; // enable generating header file for this module | |
124 | |
125 bool safe; // TRUE if module is marked as 'safe' | |
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
|
126 |
336 | 127 Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen); |
128 ~Module(); | |
129 | |
130 static Module *load(Loc loc, Array *packages, Identifier *ident); | |
131 | |
132 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
1587 | 133 void toJsonBuffer(OutBuffer *buf); |
336 | 134 const char *kind(); |
135 void read(Loc loc); // read file | |
136 #if IN_GCC | |
137 void parse(bool dump_source = false); // syntactic parse | |
138 #else | |
139 void parse(); // syntactic parse | |
140 #endif | |
1587 | 141 void importAll(Scope *sc); |
751
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
703
diff
changeset
|
142 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
|
143 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
|
144 void semantic3(Scope* unused_sc = NULL); // pass 3 semantic analysis |
336 | 145 void inlineScan(); // scan for functions to inline |
146 #ifdef _DH | |
147 void genhdrfile(); // generate D import file | |
148 #endif | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
149 // void gensymfile(); |
336 | 150 void gendocfile(); |
151 int needModuleInfo(); | |
152 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
1587 | 153 Dsymbol *symtabInsert(Dsymbol *s); |
336 | 154 void deleteObjFile(); |
155 void addDeferredSemantic(Dsymbol *s); | |
1630
44b145be2ef5
Merge dmd 1.056.
Robert Clipsham <robert@octarineparrot.com>
parents:
1587
diff
changeset
|
156 static void runDeferredSemantic(); |
1640 | 157 static void clearCache(); |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
849
diff
changeset
|
158 int imports(Module *m); |
336 | 159 |
160 // 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
|
161 #if IN_DMD |
336 | 162 int doppelganger; // sub-module |
163 Symbol *cov; // private uint[] __coverage; | |
164 unsigned *covb; // bit array of valid code line numbers | |
165 | |
166 Symbol *sictor; // module order independent constructor | |
167 Symbol *sctor; // module constructor | |
168 Symbol *sdtor; // module destructor | |
169 Symbol *stest; // module unit test | |
170 | |
171 Symbol *sfilename; // symbol for filename | |
172 | |
173 Symbol *massert; // module assert function | |
174 Symbol *toModuleAssert(); // get module assert function | |
175 | |
176 Symbol *marray; // module array bounds function | |
177 Symbol *toModuleArray(); // get module array bounds function | |
178 | |
179 | |
180 static Symbol *gencritsec(); | |
181 elem *toEfilename(); | |
182 elem *toEmodulename(); | |
183 | |
184 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
|
185 #endif |
336 | 186 void genmoduleinfo(); |
187 | |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
188 #if IN_LLVM |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
604
diff
changeset
|
189 // LDC |
1535
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1364
diff
changeset
|
190 llvm::Module* genLLVMModule(llvm::LLVMContext& context, Ir* sir); |
1645
1d2d1aa16841
Don't error out with -singleobj, -of, and -c/-output-{bc,ll,o,s}.
Matti Niemenmaa <matti.niemenmaa+hg@iki.fi>
parents:
1640
diff
changeset
|
191 void buildTargetFiles(bool singleObj); |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1052
diff
changeset
|
192 File* buildFilePath(const char* forcename, const char* path, const char* ext); |
336 | 193 Module *isModule() { return this; } |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
194 |
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
|
195 bool llvmForceLogging; |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
196 |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
197 // 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
|
198 StringTable arrayfuncs; |
1147
dbe4af57b240
Changed use of toObjFile to a new codegen method.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1146
diff
changeset
|
199 #endif |
336 | 200 }; |
201 | |
202 | |
203 struct ModuleDeclaration | |
204 { | |
205 Identifier *id; | |
206 Array *packages; // array of Identifier's representing packages | |
1587 | 207 bool safe; |
336 | 208 |
209 ModuleDeclaration(Array *packages, Identifier *id); | |
210 | |
211 char *toChars(); | |
212 }; | |
213 | |
214 #endif /* DMD_MODULE_H */ |