comparison dmd/mars.h @ 1103:b30fe7e1dbb9

- Updated to DMD frontend 1.041. - Removed dmd/inifile.c , it's not under a free license, replaced with libconfig based config file.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Thu, 12 Mar 2009 20:37:27 +0100
parents f0b6549055ab
children e7f0c2b48047
comparison
equal deleted inserted replaced
1102:ae950bd712d3 1103:b30fe7e1dbb9
1 1
2 // Compiler implementation of the D programming language 2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2007 by Digital Mars 3 // Copyright (c) 1999-2009 by Digital Mars
4 // All Rights Reserved 4 // All Rights Reserved
5 // written by Walter Bright 5 // written by Walter Bright
6 // http://www.digitalmars.com 6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License 7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt. 8 // in artistic.txt, or the GNU General Public License in gnu.txt.
11 #ifndef DMD_MARS_H 11 #ifndef DMD_MARS_H
12 #define DMD_MARS_H 12 #define DMD_MARS_H
13 13
14 #ifdef __DMC__ 14 #ifdef __DMC__
15 #pragma once 15 #pragma once
16 #endif /* __DMC__ */ 16 #endif
17
18 /*
19 It is very important to use version control macros correctly - the
20 idea is that host and target are independent. If these are done
21 correctly, cross compilers can be built.
22 The host compiler and host operating system are also different,
23 and are predefined by the host compiler. The ones used in
24 dmd are:
25
26 Macros defined by the compiler, not the code:
27
28 Compiler:
29 __DMC__ Digital Mars compiler
30 _MSC_VER Microsoft compiler
31 __GNUC__ Gnu compiler
32
33 Host operating system:
34 _WIN32 Microsoft NT, Windows 95, Windows 98, Win32s,
35 Windows 2000, Win XP, Vista
36 _WIN64 Windows for AMD64
37 linux Linux
38 __APPLE__ Mac OSX
39
40 For the target systems, there are the target operating system and
41 the target object file format:
42
43 Target operating system:
44 TARGET_WINDOS Covers 32 bit windows and 64 bit windows
45 TARGET_LINUX Covers 32 and 64 bit linux
46 TARGET_OSX Covers 32 and 64 bit Mac OSX
47
48 It is expected that the compiler for each platform will be able
49 to generate 32 and 64 bit code from the same compiler binary.
50
51 Target object module format:
52 OMFOBJ Intel Object Module Format, used on Windows
53 ELFOBJ Elf Object Module Format, used on linux
54 MACHOBJ Mach-O Object Module Format, used on Mac OSX
55
56 There are currently no macros for byte endianness order.
57 */
58
17 59
18 #include <stdint.h> 60 #include <stdint.h>
19 #include <stdarg.h> 61 #include <stdarg.h>
20 #include <stddef.h> 62 #include <stddef.h>
21 #define __STDC_FORMAT_MACROS 1 63 #define __STDC_FORMAT_MACROS 1
33 /* Changes for the GDC compiler by David Friedman */ 75 /* Changes for the GDC compiler by David Friedman */
34 #endif 76 #endif
35 77
36 #define DMDV2 0 // Version 2.0 features 78 #define DMDV2 0 // Version 2.0 features
37 #define BREAKABI 1 // 0 if not ready to break the ABI just yet 79 #define BREAKABI 1 // 0 if not ready to break the ABI just yet
80 #define STRUCTTHISREF V2 // if 'this' for struct is a reference, not a pointer
81
82 /* Other targets are TARGET_LINUX and TARGET_OSX, which are
83 * set on the command line via the compiler makefile.
84 */
85
86 #if _WIN32
87 #define TARGET_WINDOS 1 // Windows dmd generates Windows targets
88 #define OMFOBJ 1
89 #endif
90
91 #if TARGET_LINUX
92 #ifndef ELFOBJ
93 #define ELFOBJ 1
94 #endif
95 #endif
96
97 #if TARGET_OSX
98 #ifndef MACHOBJ
99 #define MACHOBJ 1
100 #endif
101 #endif
102
38 103
39 struct Array; 104 struct Array;
40 105
41 // LDC 106 // LDC
42 enum ARCH 107 enum ARCH
88 bool useSwitchError; // check for switches without a default 153 bool useSwitchError; // check for switches without a default
89 bool useUnitTests; // generate unittest code 154 bool useUnitTests; // generate unittest code
90 bool useInline; // inline expand functions 155 bool useInline; // inline expand functions
91 bool warnings; // enable warnings 156 bool warnings; // enable warnings
92 char Dversion; // D version number 157 char Dversion; // D version number
158 char safe; // enforce safe memory model
93 159
94 char *argv0; // program name 160 char *argv0; // program name
95 Array *imppath; // array of char*'s of where to look for import modules 161 Array *imppath; // array of char*'s of where to look for import modules
96 Array *fileImppath; // array of char*'s of where to look for file import modules 162 Array *fileImppath; // array of char*'s of where to look for file import modules
97 char *objdir; // .obj file output directory 163 char *objdir; // .obj file output directory
115 bool dump_source; 181 bool dump_source;
116 182
117 Array *defaultlibnames; // default libraries for non-debug builds 183 Array *defaultlibnames; // default libraries for non-debug builds
118 Array *debuglibnames; // default libraries for debug builds 184 Array *debuglibnames; // default libraries for debug builds
119 185
120 char *xmlname; // filename for XML output 186 const char *xmlname; // filename for XML output
121 187
122 // Hidden debug switches 188 // Hidden debug switches
123 bool debuga; 189 bool debuga;
124 bool debugb; 190 bool debugb;
125 bool debugc; 191 bool debugc;
154 const char *dataLayout; 220 const char *dataLayout;
155 }; 221 };
156 222
157 struct Global 223 struct Global
158 { 224 {
159 char *mars_ext; 225 const char *mars_ext;
160 char *sym_ext; 226 const char *sym_ext;
161 char *obj_ext; 227 const char *obj_ext;
162 #if _WIN32 228 #if _WIN32
163 char *obj_ext_alt; 229 char *obj_ext_alt;
164 #endif 230 #endif
165 char *ll_ext; 231 char *ll_ext;
166 char *bc_ext; 232 char *bc_ext;
167 char *s_ext; 233 char *s_ext;
168 char *doc_ext; // for Ddoc generated files 234 const char *lib_ext;
169 char *ddoc_ext; // for Ddoc macro include files 235 const char *doc_ext; // for Ddoc generated files
170 char *hdr_ext; // for D 'header' import files 236 const char *ddoc_ext; // for Ddoc macro include files
171 char *copyright; 237 const char *hdr_ext; // for D 'header' import files
172 char *written; 238 const char *copyright;
239 const char *written;
173 Array *path; // Array of char*'s which form the import lookup path 240 Array *path; // Array of char*'s which form the import lookup path
174 Array *filePath; // Array of char*'s which form the file import lookup path 241 Array *filePath; // Array of char*'s which form the file import lookup path
175 int structalign; 242 int structalign;
176 char *version; 243 const char *version;
177 char *ldc_version; 244 char *ldc_version;
178 char *llvm_version; 245 char *llvm_version;
179 246
180 Param params; 247 Param params;
181 unsigned errors; // number of errors reported so far 248 unsigned errors; // number of errors reported so far
249 316
250 #ifdef IN_GCC 317 #ifdef IN_GCC
251 #include "d-gcc-complex_t.h" 318 #include "d-gcc-complex_t.h"
252 #endif 319 #endif
253 320
254 // taken from GDC
255 // for handling printf incompatibilities
256 #if __MSVCRT__
257 #define PRIuSIZE "Iu"
258 #define PRIxSIZE "Ix"
259 #elif __MINGW32__
260 #define PRIuSIZE "u"
261 #define PRIxSIZE "x"
262 #else
263 #define PRIuSIZE "zu"
264 #define PRIxSIZE "zx"
265 #endif
266
267 struct Module; 321 struct Module;
268 322
269 //typedef unsigned Loc; // file location 323 //typedef unsigned Loc; // file location
270 struct Loc 324 struct Loc
271 { 325 {
331 MATCHconst, // match with conversion to const 385 MATCHconst, // match with conversion to const
332 #endif 386 #endif
333 MATCHexact // exact match 387 MATCHexact // exact match
334 }; 388 };
335 389
390 void warning(Loc loc, const char *format, ...);
336 void error(Loc loc, const char *format, ...); 391 void error(Loc loc, const char *format, ...);
337 void verror(Loc loc, const char *format, va_list); 392 void verror(Loc loc, const char *format, va_list);
338 void fatal(); 393 void fatal();
339 void err_nomem(); 394 void err_nomem();
340 void inifile(char *argv0, const char *inifile); 395 void inifile(char *argv0, const char *inifile);