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 0 // 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
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
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
153 unsigned errors
; // number of errors reported so far
154 unsigned gag
; // !=0 means gag reporting of errors
159 extern Global global
;
162 //#define memicmp strncasecmp
163 //#define stricmp strcasecmp
167 typedef _Complex
long double complex_t
;
170 #include "complex_t.h"
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
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
;
205 #include "d-gcc-real.h"
207 typedef long double real_t
;
209 // Modify OutBuffer::writewchar to write the correct size of wchar
211 #define writewchar writeword
213 // This needs a configuration test...
214 #define writewchar write4
218 #include "d-gcc-complex_t.h"
222 #define PRIuSIZE "Iu"
223 #define PRIxSIZE "Ix"
228 #define PRIuSIZE "zu"
229 #define PRIxSIZE "zx"
232 #define PRIdTSIZE PRIdMAX
233 #define PRIuTSIZE PRIuMAX
234 #define PRIxTSIZE PRIxMAX
238 //typedef unsigned Loc; // file location
256 Loc(Module
*mod
, unsigned linnum
);
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
294 MATCHnomatch
, // no match
295 MATCHconvert
, // match with conversions
297 MATCHconst
, // match with conversion to const
299 MATCHexact
// exact match
302 void error(Loc loc
, const char *format
, ...);
303 void verror(Loc loc
, const char *format
, va_list);
307 void deleteExeFile();
309 void inifile(char *argv0
, char *inifile
);
312 /*** Where to send error messages ***/
314 #define stdmsg stderr
316 #define stdmsg stdout
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 */