Merged Delight changes to D1 into D2
[delight/core.git] / dmd2 / mars.h
blob1da820ec72a02b3dd0d49bbdf5c7a20a1265920b
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 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.
11 /* NOTE: This file has been patched from the original DMD distribution to
12 work with the GDC compiler.
14 Modified by David Friedman, December 2006
17 #ifndef DMD_MARS_H
18 #define DMD_MARS_H
20 #ifdef __DMC__
21 #pragma once
22 #endif /* __DMC__ */
24 #include <stdint.h>
25 #include <stdarg.h>
26 #define __STDC_FORMAT_MACROS 1
27 #include <inttypes.h>
28 #include <stdarg.h>
30 #ifdef __DMC__
31 #ifdef DEBUG
32 #undef assert
33 #define assert(e) (static_cast<void>((e) || (printf("assert %s(%d) %s\n", __FILE__, __LINE__, #e), halt())))
34 #endif
35 #endif
37 #ifdef IN_GCC
38 /* Changes for the GDC compiler by David Friedman */
39 #endif
41 #define V1 0
42 #define V2 1 // Version 2.0 features
43 #define BREAKABI 1 // 0 if not ready to break the ABI just yet
45 struct Array;
47 // Put command line switches in here
48 struct Param
50 char obj; // write object file
51 char link; // perform link
52 char lib; // write library file instead of object file(s)
53 char multiobj; // break one object file into multiple ones
54 char oneobj; // write one object file instead of multiple ones
55 char trace; // insert profiling hooks
56 char quiet; // suppress non-error messages
57 char verbose; // verbose compile
58 char symdebug; // insert debug symbolic information
59 char optimize; // run optimizer
60 char cpu; // target CPU
61 char isX86_64; // generate X86_64 bit code
62 char isLinux; // generate code for linux
63 char isWindows; // generate code for Windows
64 char scheduler; // which scheduler to use
65 char useDeprecated; // allow use of deprecated features
66 char useAssert; // generate runtime code for assert()'s
67 char useInvariants; // generate class invariant checks
68 char useIn; // generate precondition checks
69 char useOut; // generate postcondition checks
70 char useArrayBounds; // generate array bounds checks
71 char useSwitchError; // check for switches without a default
72 char useUnitTests; // generate unittest code
73 char useInline; // inline expand functions
74 char release; // build release version
75 char preservePaths; // !=0 means don't strip path from source file
76 char warnings; // enable warnings
77 char pic; // generate position-independent-code for shared libs
78 char cov; // generate code coverage data
79 char nofloat; // code should not pull in floating point support
80 char Dversion; // D version number
81 char ignoreUnsupportedPragmas; // rather than error on them
83 char *argv0; // program name
84 Array *imppath; // array of char*'s of where to look for import modules
85 Array *fileImppath; // array of char*'s of where to look for file import modules
86 char *objdir; // .obj/.lib file output directory
87 char *objname; // .obj file output name
88 char *libname; // .lib file output name
90 char doDocComments; // process embedded documentation comments
91 char *docdir; // write documentation file to docdir directory
92 char *docname; // write documentation file to docname
93 Array *ddocfiles; // macro include files for Ddoc
95 char doHdrGeneration; // process embedded documentation comments
96 char *hdrdir; // write 'header' file to docdir directory
97 char *hdrname; // write 'header' file to docname
99 unsigned debuglevel; // debug level
100 Array *debugids; // debug identifiers
102 unsigned versionlevel; // version level
103 Array *versionids; // version identifiers
105 bool dump_source;
107 char *defaultlibname; // default library for non-debug builds
108 char *debuglibname; // default library for debug builds
110 char *xmlname; // filename for XML output
112 // Hidden debug switches
113 char debuga;
114 char debugb;
115 char debugc;
116 char debugf;
117 char debugr;
118 char debugw;
119 char debugx;
120 char debugy;
122 char run; // run resulting executable
123 size_t runargs_length;
124 char** runargs; // arguments for executable
126 // Linker stuff
127 Array *objfiles;
128 Array *linkswitches;
129 Array *libfiles;
130 char *deffile;
131 char *resfile;
132 char *exefile;
135 struct Global
137 char *mars_ext;
138 char *dlt_ext;
139 char *sym_ext;
140 char *obj_ext;
141 char *lib_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;
152 Param params;
153 unsigned errors; // number of errors reported so far
154 unsigned gag; // !=0 means gag reporting of errors
156 Global();
159 extern Global global;
161 #if __GNUC__
162 //#define memicmp strncasecmp
163 //#define stricmp strcasecmp
164 #endif
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
178 // Be careful not to care about sign when using integer_t
179 typedef uint64_t integer_t;
181 // Signed and unsigned variants
182 typedef int64_t sinteger_t;
183 typedef uint64_t uinteger_t;
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;
194 typedef float d_float32;
195 typedef double d_float64;
196 typedef long double d_float80;
198 typedef d_uns8 d_char;
199 typedef d_uns16 d_wchar;
200 typedef d_uns32 d_dchar;
202 typedef uinteger_t target_size_t;
203 typedef sinteger_t target_ptrdiff_t;
204 #ifdef IN_GCC
205 #include "d-gcc-real.h"
206 #else
207 typedef long double real_t;
208 #endif
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
217 #ifdef IN_GCC
218 #include "d-gcc-complex_t.h"
219 #endif
221 #if __MSVCRT__
222 #define PRIuSIZE "Iu"
223 #define PRIxSIZE "Ix"
224 #elif __NEWLIB_H__
225 #define PRIuSIZE "u"
226 #define PRIxSIZE "x"
227 #else
228 #define PRIuSIZE "zu"
229 #define PRIxSIZE "zx"
230 #endif
232 #define PRIdTSIZE PRIdMAX
233 #define PRIuTSIZE PRIuMAX
234 #define PRIxTSIZE PRIxMAX
236 struct Module;
238 //typedef unsigned Loc; // file location
239 struct Loc
241 char *filename;
242 unsigned linnum;
244 Loc()
246 linnum = 0;
247 filename = NULL;
250 Loc(int x)
252 linnum = x;
253 filename = NULL;
256 Loc(Module *mod, unsigned linnum);
258 char *toChars();
261 #ifndef GCC_SAFE_DMD
262 #define TRUE 1
263 #define FALSE 0
264 #endif
266 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
267 // in interface vtbl[]'s
268 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
269 // in the inheritance graph multiple
270 // times, only one is used
272 enum LINK
274 LINKdefault,
275 LINKd,
276 LINKc,
277 LINKcpp,
278 LINKwindows,
279 LINKpascal,
282 enum DYNCAST
284 DYNCAST_OBJECT,
285 DYNCAST_EXPRESSION,
286 DYNCAST_DSYMBOL,
287 DYNCAST_TYPE,
288 DYNCAST_IDENTIFIER,
289 DYNCAST_TUPLE,
292 enum MATCH
294 MATCHnomatch, // no match
295 MATCHconvert, // match with conversions
296 #if V2
297 MATCHconst, // match with conversion to const
298 #endif
299 MATCHexact // exact match
302 void error(Loc loc, const char *format, ...);
303 void verror(Loc loc, const char *format, va_list);
304 void fatal();
305 void err_nomem();
306 int runLINK();
307 void deleteExeFile();
308 int runProgram();
309 void inifile(char *argv0, char *inifile);
310 void halt();
312 /*** Where to send error messages ***/
313 #if IN_GCC
314 #define stdmsg stderr
315 #else
316 #define stdmsg stdout
317 #endif
319 struct Dsymbol;
320 struct Library;
321 struct File;
322 void obj_start(char *srcfile);
323 void obj_end(Library *library, File *objfile);
324 void obj_append(Dsymbol *s);
325 void obj_write_deferred(Library *library);
327 #endif /* DMD_MARS_H */