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