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