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