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
|
|
71 char Dversion; // D version number
|
|
72
|
|
73 char *argv0; // program name
|
|
74 Array *imppath; // array of char*'s of where to look for import modules
|
|
75 Array *fileImppath; // array of char*'s of where to look for file import modules
|
|
76 char *runtimeImppath; // char* of where to look for the core runtime
|
|
77 char *objdir; // .obj file output directory
|
|
78 char *objname; // .obj file output name
|
|
79
|
|
80 char doDocComments; // process embedded documentation comments
|
|
81 char *docdir; // write documentation file to docdir directory
|
|
82 char *docname; // write documentation file to docname
|
|
83 Array *ddocfiles; // macro include files for Ddoc
|
|
84
|
|
85 char doHdrGeneration; // process embedded documentation comments
|
|
86 char *hdrdir; // write 'header' file to docdir directory
|
|
87 char *hdrname; // write 'header' file to docname
|
|
88
|
|
89 unsigned debuglevel; // debug level
|
|
90 Array *debugids; // debug identifiers
|
|
91
|
|
92 unsigned versionlevel; // version level
|
|
93 Array *versionids; // version identifiers
|
|
94
|
|
95 bool dump_source;
|
|
96
|
19
|
97 char *defaultlibname; // default library for non-debug builds
|
|
98 char *debuglibname; // default library for debug builds
|
|
99
|
|
100 char *xmlname; // filename for XML output
|
|
101
|
1
|
102 // Hidden debug switches
|
|
103 char debuga;
|
|
104 char debugb;
|
|
105 char debugc;
|
|
106 char debugf;
|
|
107 char debugr;
|
|
108 char debugw;
|
|
109 char debugx;
|
|
110 char debugy;
|
|
111
|
|
112 char run; // run resulting executable
|
|
113 size_t runargs_length;
|
|
114 char** runargs; // arguments for executable
|
|
115
|
|
116 // Linker stuff
|
|
117 Array *objfiles;
|
|
118 Array *linkswitches;
|
|
119 Array *libfiles;
|
|
120 char *deffile;
|
|
121 char *resfile;
|
|
122 char *exefile;
|
|
123
|
|
124 // LLVM stuff
|
|
125 char *llvmArch;
|
|
126 char forceBE;
|
|
127 char *tt_arch;
|
|
128 char *tt_os;
|
|
129 char *data_layout;
|
|
130 };
|
|
131
|
|
132 struct Global
|
|
133 {
|
|
134 char *mars_ext;
|
|
135 char *sym_ext;
|
|
136 char *obj_ext;
|
|
137 char *ll_ext;
|
|
138 char *bc_ext;
|
|
139 char *nativeobj_ext;
|
|
140 char *doc_ext; // for Ddoc generated files
|
|
141 char *ddoc_ext; // for Ddoc macro include files
|
|
142 char *hdr_ext; // for D 'header' import files
|
|
143 char *copyright;
|
|
144 char *written;
|
|
145 Array *path; // Array of char*'s which form the import lookup path
|
|
146 Array *filePath; // Array of char*'s which form the file import lookup path
|
|
147 int structalign;
|
|
148 char *version;
|
|
149 char *llvmdc_version;
|
|
150
|
|
151 Param params;
|
|
152 unsigned errors; // number of errors reported so far
|
|
153 unsigned gag; // !=0 means gag reporting of errors
|
|
154
|
|
155 Global();
|
|
156 };
|
|
157
|
|
158 extern Global global;
|
|
159
|
|
160 #if __GNUC__
|
|
161 //#define memicmp strncasecmp
|
|
162 //#define stricmp strcasecmp
|
|
163 #endif
|
|
164
|
|
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
|
|
176
|
|
177 // Be careful not to care about sign when using integer_t
|
|
178 typedef uint64_t integer_t;
|
|
179
|
|
180 // Signed and unsigned variants
|
|
181 typedef int64_t sinteger_t;
|
|
182 typedef uint64_t uinteger_t;
|
|
183
|
|
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;
|
|
192
|
|
193 typedef float d_float32;
|
|
194 typedef double d_float64;
|
|
195 typedef long double d_float80;
|
|
196
|
|
197 typedef d_uns8 d_char;
|
|
198 typedef d_uns16 d_wchar;
|
|
199 typedef d_uns32 d_dchar;
|
|
200
|
|
201 #ifdef IN_GCC
|
|
202 #include "d-gcc-real.h"
|
|
203 #else
|
|
204 typedef long double real_t;
|
|
205 #endif
|
|
206
|
|
207 // Modify OutBuffer::writewchar to write the correct size of wchar
|
|
208 #if _WIN32
|
|
209 #define writewchar writeword
|
|
210 #else
|
|
211 // This needs a configuration test...
|
|
212 #define writewchar write4
|
|
213 #endif
|
|
214
|
|
215 #ifdef IN_GCC
|
|
216 #include "d-gcc-complex_t.h"
|
|
217 #endif
|
|
218
|
|
219 struct Module;
|
|
220
|
|
221 //typedef unsigned Loc; // file location
|
|
222 struct Loc
|
|
223 {
|
|
224 char *filename;
|
|
225 unsigned linnum;
|
|
226
|
|
227 Loc()
|
|
228 {
|
|
229 linnum = 0;
|
|
230 filename = NULL;
|
|
231 }
|
|
232
|
|
233 Loc(int x)
|
|
234 {
|
|
235 linnum = x;
|
|
236 filename = NULL;
|
|
237 }
|
|
238
|
|
239 Loc(Module *mod, unsigned linnum);
|
|
240
|
|
241 char *toChars();
|
|
242 };
|
|
243
|
|
244 #ifndef GCC_SAFE_DMD
|
|
245 #define TRUE 1
|
|
246 #define FALSE 0
|
|
247 #endif
|
|
248
|
|
249 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
|
|
250 // in interface vtbl[]'s
|
|
251 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
|
|
252 // in the inheritance graph multiple
|
|
253 // times, only one is used
|
|
254
|
|
255 enum LINK
|
|
256 {
|
|
257 LINKdefault,
|
|
258 LINKd,
|
|
259 LINKc,
|
|
260 LINKcpp,
|
|
261 LINKwindows,
|
|
262 LINKpascal,
|
|
263 };
|
|
264
|
|
265 enum DYNCAST
|
|
266 {
|
|
267 DYNCAST_OBJECT,
|
|
268 DYNCAST_EXPRESSION,
|
|
269 DYNCAST_DSYMBOL,
|
|
270 DYNCAST_TYPE,
|
|
271 DYNCAST_IDENTIFIER,
|
|
272 DYNCAST_TUPLE,
|
|
273 };
|
|
274
|
|
275 enum MATCH
|
|
276 {
|
|
277 MATCHnomatch, // no match
|
|
278 MATCHconvert, // match with conversions
|
|
279 #if V2
|
|
280 MATCHconst, // match with conversion to const
|
|
281 #endif
|
|
282 MATCHexact // exact match
|
|
283 };
|
|
284
|
|
285 void error(Loc loc, const char *format, ...);
|
|
286 void verror(Loc loc, const char *format, va_list);
|
|
287 void fatal();
|
|
288 void err_nomem();
|
|
289 int runLINK();
|
|
290 void deleteExeFile();
|
|
291 int runProgram();
|
|
292 void inifile(char *argv0, char *inifile);
|
|
293 void halt();
|
|
294
|
|
295 /*** Where to send error messages ***/
|
|
296 #if IN_GCC
|
|
297 #define stdmsg stderr
|
|
298 #else
|
|
299 #define stdmsg stdout
|
|
300 #endif
|
|
301
|
|
302 #endif /* DMD_MARS_H */
|