Don't include dynamic arrays in non-null checks
[delight/core.git] / dmd2 / mars.h
blob723d3592ba4a9bbc259f7bb3d618e906ac0f4a0e
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 *sym_ext;
139 char *obj_ext;
140 char *lib_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;
151 Param params;
152 unsigned errors; // number of errors reported so far
153 unsigned gag; // !=0 means gag reporting of errors
155 Global();
158 extern Global global;
160 #if __GNUC__
161 //#define memicmp strncasecmp
162 //#define stricmp strcasecmp
163 #endif
165 #ifdef __DMC__
166 typedef _Complex long double complex_t;
167 #else
168 #ifndef IN_GCC
169 #include "complex_t.h"
170 #endif
171 #ifdef __APPLE__
172 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h"
173 #define integer_t dmd_integer_t
174 #endif
175 #endif
177 // Be careful not to care about sign when using integer_t
178 typedef uint64_t integer_t;
180 // Signed and unsigned variants
181 typedef int64_t sinteger_t;
182 typedef uint64_t uinteger_t;
184 typedef int8_t d_int8;
185 typedef uint8_t d_uns8;
186 typedef int16_t d_int16;
187 typedef uint16_t d_uns16;
188 typedef int32_t d_int32;
189 typedef uint32_t d_uns32;
190 typedef int64_t d_int64;
191 typedef uint64_t d_uns64;
193 typedef float d_float32;
194 typedef double d_float64;
195 typedef long double d_float80;
197 typedef d_uns8 d_char;
198 typedef d_uns16 d_wchar;
199 typedef d_uns32 d_dchar;
201 typedef uinteger_t target_size_t;
202 typedef sinteger_t target_ptrdiff_t;
203 #ifdef IN_GCC
204 #include "d-gcc-real.h"
205 #else
206 typedef long double real_t;
207 #endif
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
216 #ifdef IN_GCC
217 #include "d-gcc-complex_t.h"
218 #endif
220 #if __MSVCRT__
221 #define PRIuSIZE "Iu"
222 #define PRIxSIZE "Ix"
223 #elif __NEWLIB_H__
224 #define PRIuSIZE "u"
225 #define PRIxSIZE "x"
226 #else
227 #define PRIuSIZE "zu"
228 #define PRIxSIZE "zx"
229 #endif
231 #define PRIdTSIZE PRIdMAX
232 #define PRIuTSIZE PRIuMAX
233 #define PRIxTSIZE PRIxMAX
235 struct Module;
237 //typedef unsigned Loc; // file location
238 struct Loc
240 char *filename;
241 unsigned linnum;
243 Loc()
245 linnum = 0;
246 filename = NULL;
249 Loc(int x)
251 linnum = x;
252 filename = NULL;
255 Loc(Module *mod, unsigned linnum);
257 char *toChars();
260 #ifndef GCC_SAFE_DMD
261 #define TRUE 1
262 #define FALSE 0
263 #endif
265 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
266 // in interface vtbl[]'s
267 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
268 // in the inheritance graph multiple
269 // times, only one is used
271 enum LINK
273 LINKdefault,
274 LINKd,
275 LINKc,
276 LINKcpp,
277 LINKwindows,
278 LINKpascal,
281 enum DYNCAST
283 DYNCAST_OBJECT,
284 DYNCAST_EXPRESSION,
285 DYNCAST_DSYMBOL,
286 DYNCAST_TYPE,
287 DYNCAST_IDENTIFIER,
288 DYNCAST_TUPLE,
291 enum MATCH
293 MATCHnomatch, // no match
294 MATCHconvert, // match with conversions
295 #if V2
296 MATCHconst, // match with conversion to const
297 #endif
298 MATCHexact // exact match
301 void error(Loc loc, const char *format, ...);
302 void verror(Loc loc, const char *format, va_list);
303 void fatal();
304 void err_nomem();
305 int runLINK();
306 void deleteExeFile();
307 int runProgram();
308 void inifile(char *argv0, char *inifile);
309 void halt();
311 /*** Where to send error messages ***/
312 #if IN_GCC
313 #define stdmsg stderr
314 #else
315 #define stdmsg stdout
316 #endif
318 struct Dsymbol;
319 struct Library;
320 struct File;
321 void obj_start(char *srcfile);
322 void obj_end(Library *library, File *objfile);
323 void obj_append(Dsymbol *s);
324 void obj_write_deferred(Library *library);
326 #endif /* DMD_MARS_H */