Mercurial > projects > ldc
annotate dmd/mars.h @ 837:331a176c1f4f
Removed error on naked, not fully complete, but I'll be doing more work on it during this Christmas, and some things do work.
Fixed taking delegate of final class method. see mini/delegate3.d.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 09 Dec 2008 14:07:30 +0100 |
parents | 340acf1535d0 |
children | 82ad6c0c601c |
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 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
651
diff
changeset
|
40 // LDC |
534
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, |
734
6dcab994ddc3
Fold in mandel's patch for ARM from #106
Christian Kamm <kamm incasoftware de>
parents:
723
diff
changeset
|
47 ARCHppc_64, |
735
eee9efe5b51f
Attempt at getting LLVM to provide a proper target data layout. Should assert now if things are borked.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
734
diff
changeset
|
48 ARCHarm, |
eee9efe5b51f
Attempt at getting LLVM to provide a proper target data layout. Should assert now if things are borked.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
734
diff
changeset
|
49 ARCHthumb |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
50 }; |
708
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
51 enum OUTPUTFLAG |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
52 { |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
53 OUTPUTFLAGno, |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
54 OUTPUTFLAGdefault, // for the .o default |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
55 OUTPUTFLAGset // for -output |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
56 }; |
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 enum OS |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
59 { |
566
68d7df3f9b05
Added some sanity checks for target detection.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
550
diff
changeset
|
60 OSinvalid, |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
61 OSLinux, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
62 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
|
63 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
|
64 OSFreeBSD |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
65 }; |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
66 |
159 | 67 // Put command line switches in here |
68 struct Param | |
69 { | |
70 char obj; // write object file | |
71 char link; // perform link | |
72 char quiet; // suppress non-error messages | |
73 char verbose; // verbose compile | |
74 char symdebug; // insert debug symbolic information | |
75 char optimize; // run optimizer | |
76 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
|
77 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
|
78 OS os; // target OS |
159 | 79 char is64bit; // generate 64 bit code |
80 char isLE; // generate little endian code | |
81 char scheduler; // which scheduler to use | |
82 char useDeprecated; // allow use of deprecated features | |
83 char useAssert; // generate runtime code for assert()'s | |
84 char useInvariants; // generate class invariant checks | |
85 char useIn; // generate precondition checks | |
86 char useOut; // generate postcondition checks | |
87 char useArrayBounds; // generate array bounds checks | |
88 char useSwitchError; // check for switches without a default | |
89 char useUnitTests; // generate unittest code | |
90 char useInline; // inline expand functions | |
91 char preservePaths; // !=0 means don't strip path from source file | |
92 char warnings; // enable warnings | |
93 char pic; // generate position-independent-code for shared libs | |
94 char noruntime; // code is not allowed to make implicit calls to the runtime | |
95 char novalidate;// no bitcode validation | |
96 char Dversion; // D version number | |
97 char ignoreUnsupportedPragmas; // rather than error on them | |
98 | |
99 char *argv0; // program name | |
100 Array *imppath; // array of char*'s of where to look for import modules | |
101 Array *fileImppath; // array of char*'s of where to look for file import modules | |
102 char *runtimeImppath; // char* of where to look for the core runtime | |
103 char *objdir; // .obj file output directory | |
104 char *objname; // .obj file output name | |
105 | |
106 char doDocComments; // process embedded documentation comments | |
107 char *docdir; // write documentation file to docdir directory | |
108 char *docname; // write documentation file to docname | |
109 Array *ddocfiles; // macro include files for Ddoc | |
110 | |
111 char doHdrGeneration; // process embedded documentation comments | |
112 char *hdrdir; // write 'header' file to docdir directory | |
113 char *hdrname; // write 'header' file to docname | |
114 | |
115 unsigned debuglevel; // debug level | |
116 Array *debugids; // debug identifiers | |
117 | |
118 unsigned versionlevel; // version level | |
119 Array *versionids; // version identifiers | |
120 | |
121 bool dump_source; | |
122 | |
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
|
123 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
|
124 Array *debuglibnames; // default libraries for debug builds |
159 | 125 |
126 char *xmlname; // filename for XML output | |
127 | |
128 // Hidden debug switches | |
129 char debuga; | |
130 char debugb; | |
131 char debugc; | |
132 char debugf; | |
133 char debugr; | |
134 char debugw; | |
135 char debugx; | |
136 char debugy; | |
137 | |
138 char run; // run resulting executable | |
139 size_t runargs_length; | |
140 char** runargs; // arguments for executable | |
141 | |
142 // Linker stuff | |
143 Array *objfiles; | |
144 Array *linkswitches; | |
145 Array *libfiles; | |
146 char *deffile; | |
147 char *resfile; | |
148 char *exefile; | |
149 | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
651
diff
changeset
|
150 // LDC stuff |
159 | 151 char *llvmArch; |
152 char forceBE; | |
675
bfe5229f9d8e
Disable bc output by default. Remove -dis. Add -output-bc, -output-ll, -output-s.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
153 char output_ll; |
bfe5229f9d8e
Disable bc output by default. Remove -dis. Add -output-bc, -output-ll, -output-s.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
154 char output_bc; |
bfe5229f9d8e
Disable bc output by default. Remove -dis. Add -output-bc, -output-ll, -output-s.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
155 char output_s; |
694
931333ea35c6
Allow output of only bc, ll, or s by making -of set the output type depending
Christian Kamm <kamm incasoftware de>
parents:
675
diff
changeset
|
156 char output_o; |
159 | 157 char llvmInline; |
158 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
|
159 char useInlineAsm; |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
568
diff
changeset
|
160 char fqnNames; // use fully qualified object names |
651
5709381df7e8
Added -nodefaultlib switch do disable implicitly linked standard lib modules
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
637
diff
changeset
|
161 char noDefaultLib; |
699
ed9a9e6dd1cc
Started changing target triple stuff, part of fixing #97
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
694
diff
changeset
|
162 |
ed9a9e6dd1cc
Started changing target triple stuff, part of fixing #97
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
694
diff
changeset
|
163 // target stuff |
ed9a9e6dd1cc
Started changing target triple stuff, part of fixing #97
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
694
diff
changeset
|
164 char *targetTriple; |
735
eee9efe5b51f
Attempt at getting LLVM to provide a proper target data layout. Should assert now if things are borked.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
734
diff
changeset
|
165 char *dataLayout; |
159 | 166 }; |
167 | |
168 struct Global | |
169 { | |
170 char *mars_ext; | |
171 char *sym_ext; | |
172 char *obj_ext; | |
708
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
173 #if _WIN32 |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
174 char *obj_ext_alt; |
fd5665da3a27
Hopefully sensible command switch handling. Changed default ext to .o on Windows.
Christian Kamm <kamm incasoftware de>
parents:
699
diff
changeset
|
175 #endif |
159 | 176 char *ll_ext; |
177 char *bc_ext; | |
675
bfe5229f9d8e
Disable bc output by default. Remove -dis. Add -output-bc, -output-ll, -output-s.
Christian Kamm <kamm incasoftware de>
parents:
663
diff
changeset
|
178 char *s_ext; |
159 | 179 char *doc_ext; // for Ddoc generated files |
180 char *ddoc_ext; // for Ddoc macro include files | |
181 char *hdr_ext; // for D 'header' import files | |
182 char *copyright; | |
183 char *written; | |
184 Array *path; // Array of char*'s which form the import lookup path | |
185 Array *filePath; // Array of char*'s which form the file import lookup path | |
186 int structalign; | |
187 char *version; | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
651
diff
changeset
|
188 char *ldc_version; |
159 | 189 |
190 Param params; | |
191 unsigned errors; // number of errors reported so far | |
192 unsigned gag; // !=0 means gag reporting of errors | |
193 | |
194 Global(); | |
195 }; | |
196 | |
197 extern Global global; | |
198 | |
199 #if __GNUC__ | |
200 //#define memicmp strncasecmp | |
201 //#define stricmp strcasecmp | |
202 #endif | |
203 | |
204 #ifdef __DMC__ | |
205 typedef _Complex long double complex_t; | |
206 #else | |
207 #ifndef IN_GCC | |
208 #include "complex_t.h" | |
209 #endif | |
210 #ifdef __APPLE__ | |
211 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
212 #define integer_t dmd_integer_t | |
213 #endif | |
214 #endif | |
215 | |
216 // Be careful not to care about sign when using integer_t | |
217 typedef uint64_t integer_t; | |
218 | |
219 // Signed and unsigned variants | |
220 typedef int64_t sinteger_t; | |
221 typedef uint64_t uinteger_t; | |
222 | |
223 typedef int8_t d_int8; | |
224 typedef uint8_t d_uns8; | |
225 typedef int16_t d_int16; | |
226 typedef uint16_t d_uns16; | |
227 typedef int32_t d_int32; | |
228 typedef uint32_t d_uns32; | |
229 typedef int64_t d_int64; | |
230 typedef uint64_t d_uns64; | |
231 | |
232 typedef float d_float32; | |
233 typedef double d_float64; | |
234 typedef long double d_float80; | |
235 | |
236 typedef d_uns8 d_char; | |
237 typedef d_uns16 d_wchar; | |
238 typedef d_uns32 d_dchar; | |
239 | |
240 #ifdef IN_GCC | |
241 #include "d-gcc-real.h" | |
242 #else | |
243 typedef long double real_t; | |
244 #endif | |
245 | |
246 // Modify OutBuffer::writewchar to write the correct size of wchar | |
247 #if _WIN32 | |
248 #define writewchar writeword | |
249 #else | |
250 // This needs a configuration test... | |
251 #define writewchar write4 | |
252 #endif | |
253 | |
254 #ifdef IN_GCC | |
255 #include "d-gcc-complex_t.h" | |
256 #endif | |
257 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
258 // taken from GDC |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
259 // 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
|
260 #if __MSVCRT__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
261 #define PRIuSIZE "Iu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
262 #define PRIxSIZE "Ix" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
263 #elif __MINGW32__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
264 #define PRIuSIZE "u" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
265 #define PRIxSIZE "x" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
266 #else |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
267 #define PRIuSIZE "zu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
268 #define PRIxSIZE "zx" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
269 #endif |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
270 |
159 | 271 struct Module; |
272 | |
273 //typedef unsigned Loc; // file location | |
274 struct Loc | |
275 { | |
276 char *filename; | |
277 unsigned linnum; | |
278 | |
279 Loc() | |
280 { | |
281 linnum = 0; | |
282 filename = NULL; | |
283 } | |
284 | |
285 Loc(int x) | |
286 { | |
287 linnum = x; | |
288 filename = NULL; | |
289 } | |
290 | |
291 Loc(Module *mod, unsigned linnum); | |
292 | |
293 char *toChars() const; | |
294 }; | |
295 | |
296 #ifndef GCC_SAFE_DMD | |
297 #define TRUE 1 | |
298 #define FALSE 0 | |
299 #endif | |
300 | |
301 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
302 // in interface vtbl[]'s | |
303 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
304 // in the inheritance graph multiple | |
305 // times, only one is used | |
306 | |
307 enum LINK | |
308 { | |
309 LINKdefault, | |
310 LINKd, | |
311 LINKc, | |
312 LINKcpp, | |
313 LINKwindows, | |
314 LINKpascal, | |
723
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
708
diff
changeset
|
315 |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
708
diff
changeset
|
316 // LDC |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
708
diff
changeset
|
317 LINKintrinsic, |
159 | 318 }; |
319 | |
320 enum DYNCAST | |
321 { | |
322 DYNCAST_OBJECT, | |
323 DYNCAST_EXPRESSION, | |
324 DYNCAST_DSYMBOL, | |
325 DYNCAST_TYPE, | |
326 DYNCAST_IDENTIFIER, | |
327 DYNCAST_TUPLE, | |
328 }; | |
329 | |
330 enum MATCH | |
331 { | |
332 MATCHnomatch, // no match | |
333 MATCHconvert, // match with conversions | |
336 | 334 #if DMDV2 |
159 | 335 MATCHconst, // match with conversion to const |
336 #endif | |
337 MATCHexact // exact match | |
338 }; | |
339 | |
340 void error(Loc loc, const char *format, ...); | |
341 void verror(Loc loc, const char *format, va_list); | |
342 void fatal(); | |
343 void err_nomem(); | |
344 void inifile(char *argv0, char *inifile); | |
345 void halt(); | |
346 | |
347 /*** Where to send error messages ***/ | |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
735
diff
changeset
|
348 #if IN_GCC || IN_LLVM |
159 | 349 #define stdmsg stderr |
350 #else | |
351 #define stdmsg stdout | |
352 #endif | |
353 | |
354 #endif /* DMD_MARS_H */ |