Mercurial > projects > ldc
annotate dmd/mars.h @ 52:0c77619e803b trunk
[svn r56] Initial support for TypeInfo.
Enums not work.
Several other bugfixes.
author | lindquist |
---|---|
date | Tue, 23 Oct 2007 05:55:12 +0200 |
parents | 2841234d2aea |
children | 8096ba7082db |
rev | line source |
---|---|
1 | 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> | |
19 #include <string> | |
20 #include <cstdarg> | |
21 | |
22 #ifdef __DMC__ | |
23 #ifdef DEBUG | |
24 #undef assert | |
25 #define assert(e) (static_cast<void>((e) || (printf("assert %s(%d) %s\n", __FILE__, __LINE__, #e), halt()))) | |
26 #endif | |
27 #endif | |
28 | |
29 #ifdef IN_GCC | |
30 /* Changes for the GDC compiler by David Friedman */ | |
31 #endif | |
32 | |
33 #define V2 0 // Version 2.0 features | |
34 #define BREAKABI 1 // 0 if not ready to break the ABI just yet | |
35 | |
36 struct Array; | |
37 | |
38 // Put command line switches in here | |
39 struct Param | |
40 { | |
41 char obj; // write object file | |
42 char link; // perform link | |
43 char trace; // insert profiling hooks | |
44 char quiet; // suppress non-error messages | |
45 char verbose; // verbose compile | |
46 char symdebug; // insert debug symbolic information | |
47 char optimize; // run optimizer | |
48 char optimizeLevel; // optimization level | |
49 char cpu; // target CPU | |
50 char is64bit; // generate 64 bit code | |
51 char isLE; // generate little endian code | |
52 char isLinux; // generate code for linux | |
53 char isWindows; // generate code for Windows | |
54 char scheduler; // which scheduler to use | |
55 char useDeprecated; // allow use of deprecated features | |
56 char useAssert; // generate runtime code for assert()'s | |
57 char useInvariants; // generate class invariant checks | |
58 char useIn; // generate precondition checks | |
59 char useOut; // generate postcondition checks | |
60 char useArrayBounds; // generate array bounds checks | |
61 char useSwitchError; // check for switches without a default | |
62 char useUnitTests; // generate unittest code | |
63 char useInline; // inline expand functions | |
64 char release; // build release version | |
65 char preservePaths; // !=0 means don't strip path from source file | |
66 char warnings; // enable warnings | |
67 char pic; // generate position-independent-code for shared libs | |
68 char cov; // generate code coverage data | |
69 char nofloat; // code should not pull in floating point support | |
70 char noruntime; // code is not allowed to make implicit calls to the runtime | |
31
2841234d2aea
[svn r35] * Attributes on struct fields/methods now work
lindquist
parents:
19
diff
changeset
|
71 char novalidate;// no bitcode validation |
1 | 72 char Dversion; // D version number |
73 | |
74 char *argv0; // program name | |
75 Array *imppath; // array of char*'s of where to look for import modules | |
76 Array *fileImppath; // array of char*'s of where to look for file import modules | |
77 char *runtimeImppath; // char* of where to look for the core runtime | |
78 char *objdir; // .obj file output directory | |
79 char *objname; // .obj file output name | |
80 | |
81 char doDocComments; // process embedded documentation comments | |
82 char *docdir; // write documentation file to docdir directory | |
83 char *docname; // write documentation file to docname | |
84 Array *ddocfiles; // macro include files for Ddoc | |
85 | |
86 char doHdrGeneration; // process embedded documentation comments | |
87 char *hdrdir; // write 'header' file to docdir directory | |
88 char *hdrname; // write 'header' file to docname | |
89 | |
90 unsigned debuglevel; // debug level | |
91 Array *debugids; // debug identifiers | |
92 | |
93 unsigned versionlevel; // version level | |
94 Array *versionids; // version identifiers | |
95 | |
96 bool dump_source; | |
97 | |
19 | 98 char *defaultlibname; // default library for non-debug builds |
99 char *debuglibname; // default library for debug builds | |
100 | |
101 char *xmlname; // filename for XML output | |
102 | |
1 | 103 // Hidden debug switches |
104 char debuga; | |
105 char debugb; | |
106 char debugc; | |
107 char debugf; | |
108 char debugr; | |
109 char debugw; | |
110 char debugx; | |
111 char debugy; | |
112 | |
113 char run; // run resulting executable | |
114 size_t runargs_length; | |
115 char** runargs; // arguments for executable | |
116 | |
117 // Linker stuff | |
118 Array *objfiles; | |
119 Array *linkswitches; | |
120 Array *libfiles; | |
121 char *deffile; | |
122 char *resfile; | |
123 char *exefile; | |
124 | |
125 // LLVM stuff | |
126 char *llvmArch; | |
127 char forceBE; | |
128 char *tt_arch; | |
129 char *tt_os; | |
130 char *data_layout; | |
52 | 131 char disassemble; |
1 | 132 }; |
133 | |
134 struct Global | |
135 { | |
136 char *mars_ext; | |
137 char *sym_ext; | |
138 char *obj_ext; | |
139 char *ll_ext; | |
140 char *bc_ext; | |
141 char *nativeobj_ext; | |
142 char *doc_ext; // for Ddoc generated files | |
143 char *ddoc_ext; // for Ddoc macro include files | |
144 char *hdr_ext; // for D 'header' import files | |
145 char *copyright; | |
146 char *written; | |
147 Array *path; // Array of char*'s which form the import lookup path | |
148 Array *filePath; // Array of char*'s which form the file import lookup path | |
149 int structalign; | |
150 char *version; | |
151 char *llvmdc_version; | |
152 | |
153 Param params; | |
154 unsigned errors; // number of errors reported so far | |
155 unsigned gag; // !=0 means gag reporting of errors | |
156 | |
157 Global(); | |
158 }; | |
159 | |
160 extern Global global; | |
161 | |
162 #if __GNUC__ | |
163 //#define memicmp strncasecmp | |
164 //#define stricmp strcasecmp | |
165 #endif | |
166 | |
167 #ifdef __DMC__ | |
168 typedef _Complex long double complex_t; | |
169 #else | |
170 #ifndef IN_GCC | |
171 #include "complex_t.h" | |
172 #endif | |
173 #ifdef __APPLE__ | |
174 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
175 #define integer_t dmd_integer_t | |
176 #endif | |
177 #endif | |
178 | |
179 // Be careful not to care about sign when using integer_t | |
180 typedef uint64_t integer_t; | |
181 | |
182 // Signed and unsigned variants | |
183 typedef int64_t sinteger_t; | |
184 typedef uint64_t uinteger_t; | |
185 | |
186 typedef int8_t d_int8; | |
187 typedef uint8_t d_uns8; | |
188 typedef int16_t d_int16; | |
189 typedef uint16_t d_uns16; | |
190 typedef int32_t d_int32; | |
191 typedef uint32_t d_uns32; | |
192 typedef int64_t d_int64; | |
193 typedef uint64_t d_uns64; | |
194 | |
195 typedef float d_float32; | |
196 typedef double d_float64; | |
197 typedef long double d_float80; | |
198 | |
199 typedef d_uns8 d_char; | |
200 typedef d_uns16 d_wchar; | |
201 typedef d_uns32 d_dchar; | |
202 | |
203 #ifdef IN_GCC | |
204 #include "d-gcc-real.h" | |
205 #else | |
206 typedef long double real_t; | |
207 #endif | |
208 | |
209 // Modify OutBuffer::writewchar to write the correct size of wchar | |
210 #if _WIN32 | |
211 #define writewchar writeword | |
212 #else | |
213 // This needs a configuration test... | |
214 #define writewchar write4 | |
215 #endif | |
216 | |
217 #ifdef IN_GCC | |
218 #include "d-gcc-complex_t.h" | |
219 #endif | |
220 | |
221 struct Module; | |
222 | |
223 //typedef unsigned Loc; // file location | |
224 struct Loc | |
225 { | |
226 char *filename; | |
227 unsigned linnum; | |
228 | |
229 Loc() | |
230 { | |
231 linnum = 0; | |
232 filename = NULL; | |
233 } | |
234 | |
235 Loc(int x) | |
236 { | |
237 linnum = x; | |
238 filename = NULL; | |
239 } | |
240 | |
241 Loc(Module *mod, unsigned linnum); | |
242 | |
243 char *toChars(); | |
244 }; | |
245 | |
246 #ifndef GCC_SAFE_DMD | |
247 #define TRUE 1 | |
248 #define FALSE 0 | |
249 #endif | |
250 | |
251 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
252 // in interface vtbl[]'s | |
253 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
254 // in the inheritance graph multiple | |
255 // times, only one is used | |
256 | |
257 enum LINK | |
258 { | |
259 LINKdefault, | |
260 LINKd, | |
261 LINKc, | |
262 LINKcpp, | |
263 LINKwindows, | |
264 LINKpascal, | |
265 }; | |
266 | |
267 enum DYNCAST | |
268 { | |
269 DYNCAST_OBJECT, | |
270 DYNCAST_EXPRESSION, | |
271 DYNCAST_DSYMBOL, | |
272 DYNCAST_TYPE, | |
273 DYNCAST_IDENTIFIER, | |
274 DYNCAST_TUPLE, | |
275 }; | |
276 | |
277 enum MATCH | |
278 { | |
279 MATCHnomatch, // no match | |
280 MATCHconvert, // match with conversions | |
281 #if V2 | |
282 MATCHconst, // match with conversion to const | |
283 #endif | |
284 MATCHexact // exact match | |
285 }; | |
286 | |
287 void error(Loc loc, const char *format, ...); | |
288 void verror(Loc loc, const char *format, va_list); | |
289 void fatal(); | |
290 void err_nomem(); | |
291 int runLINK(); | |
292 void deleteExeFile(); | |
293 int runProgram(); | |
294 void inifile(char *argv0, char *inifile); | |
295 void halt(); | |
296 | |
297 /*** Where to send error messages ***/ | |
298 #if IN_GCC | |
299 #define stdmsg stderr | |
300 #else | |
301 #define stdmsg stdout | |
302 #endif | |
303 | |
304 #endif /* DMD_MARS_H */ |