Mercurial > projects > ldc
annotate dmd/mars.h @ 860:7edce7e58ab1
Add more toConstElem stubs to get better error messages.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Thu, 18 Dec 2008 07:59:03 +0100 |
parents | 82ad6c0c601c |
children | aa953cc960b6 |
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; |
853
82ad6c0c601c
Add Elrood's patch to output LDC and LLVM source revs.
Christian Kamm <kamm incasoftware de>
parents:
797
diff
changeset
|
189 char *llvm_version; |
159 | 190 |
191 Param params; | |
192 unsigned errors; // number of errors reported so far | |
193 unsigned gag; // !=0 means gag reporting of errors | |
194 | |
195 Global(); | |
196 }; | |
197 | |
198 extern Global global; | |
199 | |
200 #if __GNUC__ | |
201 //#define memicmp strncasecmp | |
202 //#define stricmp strcasecmp | |
203 #endif | |
204 | |
205 #ifdef __DMC__ | |
206 typedef _Complex long double complex_t; | |
207 #else | |
208 #ifndef IN_GCC | |
209 #include "complex_t.h" | |
210 #endif | |
211 #ifdef __APPLE__ | |
212 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
213 #define integer_t dmd_integer_t | |
214 #endif | |
215 #endif | |
216 | |
217 // Be careful not to care about sign when using integer_t | |
218 typedef uint64_t integer_t; | |
219 | |
220 // Signed and unsigned variants | |
221 typedef int64_t sinteger_t; | |
222 typedef uint64_t uinteger_t; | |
223 | |
224 typedef int8_t d_int8; | |
225 typedef uint8_t d_uns8; | |
226 typedef int16_t d_int16; | |
227 typedef uint16_t d_uns16; | |
228 typedef int32_t d_int32; | |
229 typedef uint32_t d_uns32; | |
230 typedef int64_t d_int64; | |
231 typedef uint64_t d_uns64; | |
232 | |
233 typedef float d_float32; | |
234 typedef double d_float64; | |
235 typedef long double d_float80; | |
236 | |
237 typedef d_uns8 d_char; | |
238 typedef d_uns16 d_wchar; | |
239 typedef d_uns32 d_dchar; | |
240 | |
241 #ifdef IN_GCC | |
242 #include "d-gcc-real.h" | |
243 #else | |
244 typedef long double real_t; | |
245 #endif | |
246 | |
247 // Modify OutBuffer::writewchar to write the correct size of wchar | |
248 #if _WIN32 | |
249 #define writewchar writeword | |
250 #else | |
251 // This needs a configuration test... | |
252 #define writewchar write4 | |
253 #endif | |
254 | |
255 #ifdef IN_GCC | |
256 #include "d-gcc-complex_t.h" | |
257 #endif | |
258 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
259 // taken from GDC |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
260 // 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
|
261 #if __MSVCRT__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
262 #define PRIuSIZE "Iu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
263 #define PRIxSIZE "Ix" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
264 #elif __MINGW32__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
265 #define PRIuSIZE "u" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
266 #define PRIxSIZE "x" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
267 #else |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
268 #define PRIuSIZE "zu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
269 #define PRIxSIZE "zx" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
270 #endif |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
271 |
159 | 272 struct Module; |
273 | |
274 //typedef unsigned Loc; // file location | |
275 struct Loc | |
276 { | |
277 char *filename; | |
278 unsigned linnum; | |
279 | |
280 Loc() | |
281 { | |
282 linnum = 0; | |
283 filename = NULL; | |
284 } | |
285 | |
286 Loc(int x) | |
287 { | |
288 linnum = x; | |
289 filename = NULL; | |
290 } | |
291 | |
292 Loc(Module *mod, unsigned linnum); | |
293 | |
294 char *toChars() const; | |
295 }; | |
296 | |
297 #ifndef GCC_SAFE_DMD | |
298 #define TRUE 1 | |
299 #define FALSE 0 | |
300 #endif | |
301 | |
302 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
303 // in interface vtbl[]'s | |
304 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
305 // in the inheritance graph multiple | |
306 // times, only one is used | |
307 | |
308 enum LINK | |
309 { | |
310 LINKdefault, | |
311 LINKd, | |
312 LINKc, | |
313 LINKcpp, | |
314 LINKwindows, | |
315 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
|
316 |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
708
diff
changeset
|
317 // LDC |
55f6c2e454d7
Implemented correct parameter order according to x86-32 ABI documentation.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
708
diff
changeset
|
318 LINKintrinsic, |
159 | 319 }; |
320 | |
321 enum DYNCAST | |
322 { | |
323 DYNCAST_OBJECT, | |
324 DYNCAST_EXPRESSION, | |
325 DYNCAST_DSYMBOL, | |
326 DYNCAST_TYPE, | |
327 DYNCAST_IDENTIFIER, | |
328 DYNCAST_TUPLE, | |
329 }; | |
330 | |
331 enum MATCH | |
332 { | |
333 MATCHnomatch, // no match | |
334 MATCHconvert, // match with conversions | |
336 | 335 #if DMDV2 |
159 | 336 MATCHconst, // match with conversion to const |
337 #endif | |
338 MATCHexact // exact match | |
339 }; | |
340 | |
341 void error(Loc loc, const char *format, ...); | |
342 void verror(Loc loc, const char *format, va_list); | |
343 void fatal(); | |
344 void err_nomem(); | |
345 void inifile(char *argv0, char *inifile); | |
346 void halt(); | |
347 | |
348 /*** 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
|
349 #if IN_GCC || IN_LLVM |
159 | 350 #define stdmsg stderr |
351 #else | |
352 #define stdmsg stdout | |
353 #endif | |
354 | |
355 #endif /* DMD_MARS_H */ |