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