Mercurial > projects > ldc
annotate dmd/mars.h @ 31:2841234d2aea trunk
[svn r35] * Attributes on struct fields/methods now work
* Updated object.d to 1.021
* Added -novalidate command line option. this is sometimes useful when debugging as it may let you read the .ll even if it's invalid.
author | lindquist |
---|---|
date | Thu, 04 Oct 2007 16:44:07 +0200 |
parents | 788401029ecf |
children | 0c77619e803b |
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; | |
131 }; | |
132 | |
133 struct Global | |
134 { | |
135 char *mars_ext; | |
136 char *sym_ext; | |
137 char *obj_ext; | |
138 char *ll_ext; | |
139 char *bc_ext; | |
140 char *nativeobj_ext; | |
141 char *doc_ext; // for Ddoc generated files | |
142 char *ddoc_ext; // for Ddoc macro include files | |
143 char *hdr_ext; // for D 'header' import files | |
144 char *copyright; | |
145 char *written; | |
146 Array *path; // Array of char*'s which form the import lookup path | |
147 Array *filePath; // Array of char*'s which form the file import lookup path | |
148 int structalign; | |
149 char *version; | |
150 char *llvmdc_version; | |
151 | |
152 Param params; | |
153 unsigned errors; // number of errors reported so far | |
154 unsigned gag; // !=0 means gag reporting of errors | |
155 | |
156 Global(); | |
157 }; | |
158 | |
159 extern Global global; | |
160 | |
161 #if __GNUC__ | |
162 //#define memicmp strncasecmp | |
163 //#define stricmp strcasecmp | |
164 #endif | |
165 | |
166 #ifdef __DMC__ | |
167 typedef _Complex long double complex_t; | |
168 #else | |
169 #ifndef IN_GCC | |
170 #include "complex_t.h" | |
171 #endif | |
172 #ifdef __APPLE__ | |
173 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
174 #define integer_t dmd_integer_t | |
175 #endif | |
176 #endif | |
177 | |
178 // Be careful not to care about sign when using integer_t | |
179 typedef uint64_t integer_t; | |
180 | |
181 // Signed and unsigned variants | |
182 typedef int64_t sinteger_t; | |
183 typedef uint64_t uinteger_t; | |
184 | |
185 typedef int8_t d_int8; | |
186 typedef uint8_t d_uns8; | |
187 typedef int16_t d_int16; | |
188 typedef uint16_t d_uns16; | |
189 typedef int32_t d_int32; | |
190 typedef uint32_t d_uns32; | |
191 typedef int64_t d_int64; | |
192 typedef uint64_t d_uns64; | |
193 | |
194 typedef float d_float32; | |
195 typedef double d_float64; | |
196 typedef long double d_float80; | |
197 | |
198 typedef d_uns8 d_char; | |
199 typedef d_uns16 d_wchar; | |
200 typedef d_uns32 d_dchar; | |
201 | |
202 #ifdef IN_GCC | |
203 #include "d-gcc-real.h" | |
204 #else | |
205 typedef long double real_t; | |
206 #endif | |
207 | |
208 // Modify OutBuffer::writewchar to write the correct size of wchar | |
209 #if _WIN32 | |
210 #define writewchar writeword | |
211 #else | |
212 // This needs a configuration test... | |
213 #define writewchar write4 | |
214 #endif | |
215 | |
216 #ifdef IN_GCC | |
217 #include "d-gcc-complex_t.h" | |
218 #endif | |
219 | |
220 struct Module; | |
221 | |
222 //typedef unsigned Loc; // file location | |
223 struct Loc | |
224 { | |
225 char *filename; | |
226 unsigned linnum; | |
227 | |
228 Loc() | |
229 { | |
230 linnum = 0; | |
231 filename = NULL; | |
232 } | |
233 | |
234 Loc(int x) | |
235 { | |
236 linnum = x; | |
237 filename = NULL; | |
238 } | |
239 | |
240 Loc(Module *mod, unsigned linnum); | |
241 | |
242 char *toChars(); | |
243 }; | |
244 | |
245 #ifndef GCC_SAFE_DMD | |
246 #define TRUE 1 | |
247 #define FALSE 0 | |
248 #endif | |
249 | |
250 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
251 // in interface vtbl[]'s | |
252 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
253 // in the inheritance graph multiple | |
254 // times, only one is used | |
255 | |
256 enum LINK | |
257 { | |
258 LINKdefault, | |
259 LINKd, | |
260 LINKc, | |
261 LINKcpp, | |
262 LINKwindows, | |
263 LINKpascal, | |
264 }; | |
265 | |
266 enum DYNCAST | |
267 { | |
268 DYNCAST_OBJECT, | |
269 DYNCAST_EXPRESSION, | |
270 DYNCAST_DSYMBOL, | |
271 DYNCAST_TYPE, | |
272 DYNCAST_IDENTIFIER, | |
273 DYNCAST_TUPLE, | |
274 }; | |
275 | |
276 enum MATCH | |
277 { | |
278 MATCHnomatch, // no match | |
279 MATCHconvert, // match with conversions | |
280 #if V2 | |
281 MATCHconst, // match with conversion to const | |
282 #endif | |
283 MATCHexact // exact match | |
284 }; | |
285 | |
286 void error(Loc loc, const char *format, ...); | |
287 void verror(Loc loc, const char *format, va_list); | |
288 void fatal(); | |
289 void err_nomem(); | |
290 int runLINK(); | |
291 void deleteExeFile(); | |
292 int runProgram(); | |
293 void inifile(char *argv0, char *inifile); | |
294 void halt(); | |
295 | |
296 /*** Where to send error messages ***/ | |
297 #if IN_GCC | |
298 #define stdmsg stderr | |
299 #else | |
300 #define stdmsg stdout | |
301 #endif | |
302 | |
303 #endif /* DMD_MARS_H */ |