Mercurial > projects > ldc
annotate dmd/mars.h @ 650:aa6a0b7968f7
Added test case for bug #100
Removed dubious check for not emitting static private global in other modules without access. This should be handled properly somewhere else, it's causing unresolved global errors for stuff that should work (in MiniD)
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 05 Oct 2008 17:28:15 +0200 |
parents | 29dc68c949b0 |
children | 5709381df7e8 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2007 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_MARS_H | |
12 #define DMD_MARS_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include <stdint.h> | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
19 #include <stdarg.h> |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
20 #define __STDC_FORMAT_MACROS 1 |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
21 #include <inttypes.h> |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
22 #include <stdarg.h> |
159 | 23 |
24 #ifdef __DMC__ | |
25 #ifdef DEBUG | |
26 #undef assert | |
27 #define assert(e) (static_cast<void>((e) || (printf("assert %s(%d) %s\n", __FILE__, __LINE__, #e), halt()))) | |
28 #endif | |
29 #endif | |
30 | |
31 #ifdef IN_GCC | |
32 /* Changes for the GDC compiler by David Friedman */ | |
33 #endif | |
34 | |
336 | 35 #define DMDV2 0 // Version 2.0 features |
159 | 36 #define BREAKABI 1 // 0 if not ready to break the ABI just yet |
37 | |
38 struct Array; | |
39 | |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
40 // LLVMDC |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
41 enum ARCH |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
42 { |
566
68d7df3f9b05
Added some sanity checks for target detection.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
550
diff
changeset
|
43 ARCHinvalid, |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
44 ARCHx86, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
45 ARCHx86_64, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
46 ARCHppc, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
47 ARCHppc_64 |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
48 }; |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
49 |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
50 enum OS |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
51 { |
566
68d7df3f9b05
Added some sanity checks for target detection.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
550
diff
changeset
|
52 OSinvalid, |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
53 OSLinux, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
54 OSWindows, |
637
29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
580
diff
changeset
|
55 OSMacOSX, |
29dc68c949b0
Applied the FreeBSD patch from Ralith, closes ticket #95 , slightly changed but basically the same. Thanx Ralith :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
580
diff
changeset
|
56 OSFreeBSD |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
57 }; |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
58 |
159 | 59 // Put command line switches in here |
60 struct Param | |
61 { | |
62 char obj; // write object file | |
63 char link; // perform link | |
64 char quiet; // suppress non-error messages | |
65 char verbose; // verbose compile | |
66 char symdebug; // insert debug symbolic information | |
67 char optimize; // run optimizer | |
68 char optimizeLevel; // optimization level | |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
69 ARCH cpu; // target CPU |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
70 OS os; // target OS |
159 | 71 char is64bit; // generate 64 bit code |
72 char isLE; // generate little endian code | |
73 char scheduler; // which scheduler to use | |
74 char useDeprecated; // allow use of deprecated features | |
75 char useAssert; // generate runtime code for assert()'s | |
76 char useInvariants; // generate class invariant checks | |
77 char useIn; // generate precondition checks | |
78 char useOut; // generate postcondition checks | |
79 char useArrayBounds; // generate array bounds checks | |
80 char useSwitchError; // check for switches without a default | |
81 char useUnitTests; // generate unittest code | |
82 char useInline; // inline expand functions | |
83 char preservePaths; // !=0 means don't strip path from source file | |
84 char warnings; // enable warnings | |
85 char pic; // generate position-independent-code for shared libs | |
86 char noruntime; // code is not allowed to make implicit calls to the runtime | |
87 char novalidate;// no bitcode validation | |
88 char Dversion; // D version number | |
89 char ignoreUnsupportedPragmas; // rather than error on them | |
90 | |
91 char *argv0; // program name | |
92 Array *imppath; // array of char*'s of where to look for import modules | |
93 Array *fileImppath; // array of char*'s of where to look for file import modules | |
94 char *runtimeImppath; // char* of where to look for the core runtime | |
95 char *objdir; // .obj file output directory | |
96 char *objname; // .obj file output name | |
97 | |
98 char doDocComments; // process embedded documentation comments | |
99 char *docdir; // write documentation file to docdir directory | |
100 char *docname; // write documentation file to docname | |
101 Array *ddocfiles; // macro include files for Ddoc | |
102 | |
103 char doHdrGeneration; // process embedded documentation comments | |
104 char *hdrdir; // write 'header' file to docdir directory | |
105 char *hdrname; // write 'header' file to docname | |
106 | |
107 unsigned debuglevel; // debug level | |
108 Array *debugids; // debug identifiers | |
109 | |
110 unsigned versionlevel; // version level | |
111 Array *versionids; // version identifiers | |
112 | |
113 bool dump_source; | |
114 | |
567
aaba4f7c6d8a
Get rid of runtime path. Allow defaultlib and debuglib switches to be given multiple times.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
115 Array *defaultlibnames; // default libraries for non-debug builds |
aaba4f7c6d8a
Get rid of runtime path. Allow defaultlib and debuglib switches to be given multiple times.
Christian Kamm <kamm incasoftware de>
parents:
550
diff
changeset
|
116 Array *debuglibnames; // default libraries for debug builds |
159 | 117 |
118 char *xmlname; // filename for XML output | |
119 | |
120 // Hidden debug switches | |
121 char debuga; | |
122 char debugb; | |
123 char debugc; | |
124 char debugf; | |
125 char debugr; | |
126 char debugw; | |
127 char debugx; | |
128 char debugy; | |
129 | |
130 char run; // run resulting executable | |
131 size_t runargs_length; | |
132 char** runargs; // arguments for executable | |
133 | |
134 // Linker stuff | |
135 Array *objfiles; | |
136 Array *linkswitches; | |
137 Array *libfiles; | |
138 char *deffile; | |
139 char *resfile; | |
140 char *exefile; | |
141 | |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
237
diff
changeset
|
142 // LLVMDC stuff |
159 | 143 char *llvmArch; |
144 char forceBE; | |
145 char *tt_arch; | |
146 char *tt_os; | |
147 char *data_layout; | |
148 char disassemble; | |
149 char llvmInline; | |
150 char llvmAnnotate; | |
220
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
217
diff
changeset
|
151 char useInlineAsm; |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
568
diff
changeset
|
152 char fqnNames; // use fully qualified object names |
159 | 153 }; |
154 | |
155 struct Global | |
156 { | |
157 char *mars_ext; | |
158 char *sym_ext; | |
159 char *obj_ext; | |
160 char *ll_ext; | |
161 char *bc_ext; | |
162 char *nativeobj_ext; | |
163 char *doc_ext; // for Ddoc generated files | |
164 char *ddoc_ext; // for Ddoc macro include files | |
165 char *hdr_ext; // for D 'header' import files | |
166 char *copyright; | |
167 char *written; | |
168 Array *path; // Array of char*'s which form the import lookup path | |
169 Array *filePath; // Array of char*'s which form the file import lookup path | |
170 int structalign; | |
171 char *version; | |
172 char *llvmdc_version; | |
173 | |
174 Param params; | |
175 unsigned errors; // number of errors reported so far | |
176 unsigned gag; // !=0 means gag reporting of errors | |
177 | |
178 Global(); | |
179 }; | |
180 | |
181 extern Global global; | |
182 | |
183 #if __GNUC__ | |
184 //#define memicmp strncasecmp | |
185 //#define stricmp strcasecmp | |
186 #endif | |
187 | |
188 #ifdef __DMC__ | |
189 typedef _Complex long double complex_t; | |
190 #else | |
191 #ifndef IN_GCC | |
192 #include "complex_t.h" | |
193 #endif | |
194 #ifdef __APPLE__ | |
195 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
196 #define integer_t dmd_integer_t | |
197 #endif | |
198 #endif | |
199 | |
200 // Be careful not to care about sign when using integer_t | |
201 typedef uint64_t integer_t; | |
202 | |
203 // Signed and unsigned variants | |
204 typedef int64_t sinteger_t; | |
205 typedef uint64_t uinteger_t; | |
206 | |
207 typedef int8_t d_int8; | |
208 typedef uint8_t d_uns8; | |
209 typedef int16_t d_int16; | |
210 typedef uint16_t d_uns16; | |
211 typedef int32_t d_int32; | |
212 typedef uint32_t d_uns32; | |
213 typedef int64_t d_int64; | |
214 typedef uint64_t d_uns64; | |
215 | |
216 typedef float d_float32; | |
217 typedef double d_float64; | |
218 typedef long double d_float80; | |
219 | |
220 typedef d_uns8 d_char; | |
221 typedef d_uns16 d_wchar; | |
222 typedef d_uns32 d_dchar; | |
223 | |
224 #ifdef IN_GCC | |
225 #include "d-gcc-real.h" | |
226 #else | |
227 typedef long double real_t; | |
228 #endif | |
229 | |
230 // Modify OutBuffer::writewchar to write the correct size of wchar | |
231 #if _WIN32 | |
232 #define writewchar writeword | |
233 #else | |
234 // This needs a configuration test... | |
235 #define writewchar write4 | |
236 #endif | |
237 | |
238 #ifdef IN_GCC | |
239 #include "d-gcc-complex_t.h" | |
240 #endif | |
241 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
242 // taken from GDC |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
243 // for handling printf incompatibilities |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
244 #if __MSVCRT__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
245 #define PRIuSIZE "Iu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
246 #define PRIxSIZE "Ix" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
247 #elif __MINGW32__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
248 #define PRIuSIZE "u" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
249 #define PRIxSIZE "x" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
250 #else |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
251 #define PRIuSIZE "zu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
252 #define PRIxSIZE "zx" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
253 #endif |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
254 |
159 | 255 struct Module; |
256 | |
257 //typedef unsigned Loc; // file location | |
258 struct Loc | |
259 { | |
260 char *filename; | |
261 unsigned linnum; | |
262 | |
263 Loc() | |
264 { | |
265 linnum = 0; | |
266 filename = NULL; | |
267 } | |
268 | |
269 Loc(int x) | |
270 { | |
271 linnum = x; | |
272 filename = NULL; | |
273 } | |
274 | |
275 Loc(Module *mod, unsigned linnum); | |
276 | |
277 char *toChars() const; | |
278 }; | |
279 | |
280 #ifndef GCC_SAFE_DMD | |
281 #define TRUE 1 | |
282 #define FALSE 0 | |
283 #endif | |
284 | |
285 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
286 // in interface vtbl[]'s | |
287 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
288 // in the inheritance graph multiple | |
289 // times, only one is used | |
290 | |
291 enum LINK | |
292 { | |
293 LINKdefault, | |
294 LINKd, | |
295 LINKc, | |
296 LINKcpp, | |
297 LINKwindows, | |
298 LINKpascal, | |
299 }; | |
300 | |
301 enum DYNCAST | |
302 { | |
303 DYNCAST_OBJECT, | |
304 DYNCAST_EXPRESSION, | |
305 DYNCAST_DSYMBOL, | |
306 DYNCAST_TYPE, | |
307 DYNCAST_IDENTIFIER, | |
308 DYNCAST_TUPLE, | |
309 }; | |
310 | |
311 enum MATCH | |
312 { | |
313 MATCHnomatch, // no match | |
314 MATCHconvert, // match with conversions | |
336 | 315 #if DMDV2 |
159 | 316 MATCHconst, // match with conversion to const |
317 #endif | |
318 MATCHexact // exact match | |
319 }; | |
320 | |
321 void error(Loc loc, const char *format, ...); | |
322 void verror(Loc loc, const char *format, va_list); | |
323 void fatal(); | |
324 void err_nomem(); | |
325 void inifile(char *argv0, char *inifile); | |
326 void halt(); | |
327 | |
328 /*** Where to send error messages ***/ | |
329 #if IN_GCC | |
330 #define stdmsg stderr | |
331 #else | |
332 #define stdmsg stdout | |
333 #endif | |
334 | |
335 #endif /* DMD_MARS_H */ |