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
|
|
97 // Hidden debug switches
|
|
98 char debuga;
|
|
99 char debugb;
|
|
100 char debugc;
|
|
101 char debugf;
|
|
102 char debugr;
|
|
103 char debugw;
|
|
104 char debugx;
|
|
105 char debugy;
|
|
106
|
|
107 char run; // run resulting executable
|
|
108 size_t runargs_length;
|
|
109 char** runargs; // arguments for executable
|
|
110
|
|
111 // Linker stuff
|
|
112 Array *objfiles;
|
|
113 Array *linkswitches;
|
|
114 Array *libfiles;
|
|
115 char *deffile;
|
|
116 char *resfile;
|
|
117 char *exefile;
|
|
118
|
|
119 // LLVM stuff
|
|
120 char *llvmArch;
|
|
121 char forceBE;
|
|
122 char *tt_arch;
|
|
123 char *tt_os;
|
|
124 char *data_layout;
|
|
125 };
|
|
126
|
|
127 struct Global
|
|
128 {
|
|
129 char *mars_ext;
|
|
130 char *sym_ext;
|
|
131 char *obj_ext;
|
|
132 char *ll_ext;
|
|
133 char *bc_ext;
|
|
134 char *nativeobj_ext;
|
|
135 char *doc_ext; // for Ddoc generated files
|
|
136 char *ddoc_ext; // for Ddoc macro include files
|
|
137 char *hdr_ext; // for D 'header' import files
|
|
138 char *copyright;
|
|
139 char *written;
|
|
140 Array *path; // Array of char*'s which form the import lookup path
|
|
141 Array *filePath; // Array of char*'s which form the file import lookup path
|
|
142 int structalign;
|
|
143 char *version;
|
|
144 char *llvmdc_version;
|
|
145
|
|
146 Param params;
|
|
147 unsigned errors; // number of errors reported so far
|
|
148 unsigned gag; // !=0 means gag reporting of errors
|
|
149
|
|
150 Global();
|
|
151 };
|
|
152
|
|
153 extern Global global;
|
|
154
|
|
155 #if __GNUC__
|
|
156 //#define memicmp strncasecmp
|
|
157 //#define stricmp strcasecmp
|
|
158 #endif
|
|
159
|
|
160 #ifdef __DMC__
|
|
161 typedef _Complex long double complex_t;
|
|
162 #else
|
|
163 #ifndef IN_GCC
|
|
164 #include "complex_t.h"
|
|
165 #endif
|
|
166 #ifdef __APPLE__
|
|
167 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h"
|
|
168 #define integer_t dmd_integer_t
|
|
169 #endif
|
|
170 #endif
|
|
171
|
|
172 // Be careful not to care about sign when using integer_t
|
|
173 typedef uint64_t integer_t;
|
|
174
|
|
175 // Signed and unsigned variants
|
|
176 typedef int64_t sinteger_t;
|
|
177 typedef uint64_t uinteger_t;
|
|
178
|
|
179 typedef int8_t d_int8;
|
|
180 typedef uint8_t d_uns8;
|
|
181 typedef int16_t d_int16;
|
|
182 typedef uint16_t d_uns16;
|
|
183 typedef int32_t d_int32;
|
|
184 typedef uint32_t d_uns32;
|
|
185 typedef int64_t d_int64;
|
|
186 typedef uint64_t d_uns64;
|
|
187
|
|
188 typedef float d_float32;
|
|
189 typedef double d_float64;
|
|
190 typedef long double d_float80;
|
|
191
|
|
192 typedef d_uns8 d_char;
|
|
193 typedef d_uns16 d_wchar;
|
|
194 typedef d_uns32 d_dchar;
|
|
195
|
|
196 #ifdef IN_GCC
|
|
197 #include "d-gcc-real.h"
|
|
198 #else
|
|
199 typedef long double real_t;
|
|
200 #endif
|
|
201
|
|
202 // Modify OutBuffer::writewchar to write the correct size of wchar
|
|
203 #if _WIN32
|
|
204 #define writewchar writeword
|
|
205 #else
|
|
206 // This needs a configuration test...
|
|
207 #define writewchar write4
|
|
208 #endif
|
|
209
|
|
210 #ifdef IN_GCC
|
|
211 #include "d-gcc-complex_t.h"
|
|
212 #endif
|
|
213
|
|
214 struct Module;
|
|
215
|
|
216 //typedef unsigned Loc; // file location
|
|
217 struct Loc
|
|
218 {
|
|
219 char *filename;
|
|
220 unsigned linnum;
|
|
221
|
|
222 Loc()
|
|
223 {
|
|
224 linnum = 0;
|
|
225 filename = NULL;
|
|
226 }
|
|
227
|
|
228 Loc(int x)
|
|
229 {
|
|
230 linnum = x;
|
|
231 filename = NULL;
|
|
232 }
|
|
233
|
|
234 Loc(Module *mod, unsigned linnum);
|
|
235
|
|
236 char *toChars();
|
|
237 };
|
|
238
|
|
239 #ifndef GCC_SAFE_DMD
|
|
240 #define TRUE 1
|
|
241 #define FALSE 0
|
|
242 #endif
|
|
243
|
|
244 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
|
|
245 // in interface vtbl[]'s
|
|
246 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
|
|
247 // in the inheritance graph multiple
|
|
248 // times, only one is used
|
|
249
|
|
250 enum LINK
|
|
251 {
|
|
252 LINKdefault,
|
|
253 LINKd,
|
|
254 LINKc,
|
|
255 LINKcpp,
|
|
256 LINKwindows,
|
|
257 LINKpascal,
|
|
258 };
|
|
259
|
|
260 enum DYNCAST
|
|
261 {
|
|
262 DYNCAST_OBJECT,
|
|
263 DYNCAST_EXPRESSION,
|
|
264 DYNCAST_DSYMBOL,
|
|
265 DYNCAST_TYPE,
|
|
266 DYNCAST_IDENTIFIER,
|
|
267 DYNCAST_TUPLE,
|
|
268 };
|
|
269
|
|
270 enum MATCH
|
|
271 {
|
|
272 MATCHnomatch, // no match
|
|
273 MATCHconvert, // match with conversions
|
|
274 #if V2
|
|
275 MATCHconst, // match with conversion to const
|
|
276 #endif
|
|
277 MATCHexact // exact match
|
|
278 };
|
|
279
|
|
280 void error(Loc loc, const char *format, ...);
|
|
281 void verror(Loc loc, const char *format, va_list);
|
|
282 void fatal();
|
|
283 void err_nomem();
|
|
284 int runLINK();
|
|
285 void deleteExeFile();
|
|
286 int runProgram();
|
|
287 void inifile(char *argv0, char *inifile);
|
|
288 void halt();
|
|
289
|
|
290 /*** Where to send error messages ***/
|
|
291 #if IN_GCC
|
|
292 #define stdmsg stderr
|
|
293 #else
|
|
294 #define stdmsg stdout
|
|
295 #endif
|
|
296
|
|
297 #endif /* DMD_MARS_H */
|