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