2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2008 by Digital Mars
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
26 #define __STDC_FORMAT_MACROS 1
33 #define assert(e) (static_cast<void>((e) || (printf("assert %s(%d) %s\n", __FILE__, __LINE__, #e), halt())))
38 /* Changes for the GDC compiler by David Friedman */
42 #define V2 1 // Version 2.0 features
43 #define BREAKABI 1 // 0 if not ready to break the ABI just yet
47 // Put command line switches in here
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
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
122 char run
; // run resulting executable
123 size_t runargs_length
;
124 char** runargs
; // arguments for executable
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
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
152 unsigned errors
; // number of errors reported so far
153 unsigned gag
; // !=0 means gag reporting of errors
158 extern Global global
;
161 //#define memicmp strncasecmp
162 //#define stricmp strcasecmp
166 typedef _Complex
long double complex_t
;
169 #include "complex_t.h"
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
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
;
204 #include "d-gcc-real.h"
206 typedef long double real_t
;
208 // Modify OutBuffer::writewchar to write the correct size of wchar
210 #define writewchar writeword
212 // This needs a configuration test...
213 #define writewchar write4
217 #include "d-gcc-complex_t.h"
221 #define PRIuSIZE "Iu"
222 #define PRIxSIZE "Ix"
227 #define PRIuSIZE "zu"
228 #define PRIxSIZE "zx"
231 #define PRIdTSIZE PRIdMAX
232 #define PRIuTSIZE PRIuMAX
233 #define PRIxTSIZE PRIxMAX
237 //typedef unsigned Loc; // file location
255 Loc(Module
*mod
, unsigned linnum
);
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
293 MATCHnomatch
, // no match
294 MATCHconvert
, // match with conversions
296 MATCHconst
, // match with conversion to const
298 MATCHexact
// exact match
301 void error(Loc loc
, const char *format
, ...);
302 void verror(Loc loc
, const char *format
, va_list);
306 void deleteExeFile();
308 void inifile(char *argv0
, char *inifile
);
311 /*** Where to send error messages ***/
313 #define stdmsg stderr
315 #define stdmsg stdout
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 */