annotate dmd/mars.c @ 510:6aee82889553

Merged DMD 1.034, array operations are not yet implemented ;)
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Thu, 14 Aug 2008 06:55:41 +0200
parents a34078905d01
children d30c40f1128d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1 // Compiler implementation of the D programming language
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
2 // Copyright (c) 1999-2008 by Digital Mars
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
3 // All Rights Reserved
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
4 // written by Walter Bright
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
5 // http://www.digitalmars.com
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
6 // License for redistribution is by either the Artistic License
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
7 // in artistic.txt, or the GNU General Public License in gnu.txt.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
8 // See the included readme.txt for details.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
9
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
10 #include <stdio.h>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
11 #include <stdlib.h>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
12 #include <ctype.h>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
13 #include <assert.h>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
14 #include <limits.h>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
15 #include <string>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
16 #include <cstdarg>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
17
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
18 #if __DMC__
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
19 #include <dos.h>
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
20 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
21
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
22 #if linux
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
23 #include <errno.h>
432
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
24 #elif _WIN32
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
25 #include <windows.h>
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
26 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
27
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
28 #include "mem.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
29 #include "root.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
30
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
31 #include "mars.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
32 #include "module.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
33 #include "mtype.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
34 #include "id.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
35 #include "cond.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
36 #include "expression.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
37 #include "lexer.h"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
38
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
39 #include "gen/logger.h"
277
90a8c798b0db [svn r298] Eliminated the dmd/link.c source file entirely in favor of a llvm::sys based approach to the same functionality.
lindquist
parents: 276
diff changeset
40 #include "gen/linker.h"
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
41
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
42 void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
43
284
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 279
diff changeset
44 // llvmdc
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 279
diff changeset
45 void findDefaultTarget();
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 279
diff changeset
46
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
47 Global global;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
48
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
49 Global::Global()
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
50 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
51 mars_ext = "d";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
52 sym_ext = "d";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
53 hdr_ext = "di";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
54 doc_ext = "html";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
55 ddoc_ext = "ddoc";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
56
374
1f20b9f7de1b Fix nativeobj extension for Windows.
Christian Kamm <kamm incasoftware de>
parents: 366
diff changeset
57 // LLVMDC
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
58 obj_ext = "bc";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
59 ll_ext = "ll";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
60 bc_ext = "bc";
374
1f20b9f7de1b Fix nativeobj extension for Windows.
Christian Kamm <kamm incasoftware de>
parents: 366
diff changeset
61 #if _WIN32
1f20b9f7de1b Fix nativeobj extension for Windows.
Christian Kamm <kamm incasoftware de>
parents: 366
diff changeset
62 nativeobj_ext = "obj";
1f20b9f7de1b Fix nativeobj extension for Windows.
Christian Kamm <kamm incasoftware de>
parents: 366
diff changeset
63 #elif linux
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
64 nativeobj_ext = "o";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
65 #else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
66 #error "fix this"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
67 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
68
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
69 copyright = "Copyright (c) 1999-2008 by Digital Mars and Tomas Lindquist Olsen";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
70 written = "written by Walter Bright and Tomas Lindquist Olsen";
366
1d3026702f65 [svn r387] Removed unused MD5 stuff.
lindquist
parents: 336
diff changeset
71 version = "v1.033";
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
72 llvmdc_version = "0.1";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
73 global.structalign = 8;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
74
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
75 memset(&params, 0, sizeof(Param));
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
76 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
77
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
78 char *Loc::toChars() const
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
79 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
80 OutBuffer buf;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
81 char *p;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
82
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
83 if (filename)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
84 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
85 buf.printf("%s", filename);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
86 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
87
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
88 if (linnum)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
89 buf.printf("(%d)", linnum);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
90 buf.writeByte(0);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
91 return (char *)buf.extractData();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
92 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
93
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
94 Loc::Loc(Module *mod, unsigned linnum)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
95 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
96 this->linnum = linnum;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
97 this->filename = mod ? mod->srcfile->toChars() : NULL;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
98 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
99
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
100 /**************************************
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
101 * Print error message and exit.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
102 */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
103
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
104 void error(Loc loc, const char *format, ...)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
105 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
106 va_list ap;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
107 va_start(ap, format);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
108 verror(loc, format, ap);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
109 va_end( ap );
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
110 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
111
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
112 void verror(Loc loc, const char *format, va_list ap)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
113 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
114 if (!global.gag)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
115 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
116 char *p = loc.toChars();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
117
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
118 if (*p)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
119 fprintf(stdmsg, "%s: ", p);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
120 mem.free(p);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
121
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
122 fprintf(stdmsg, "Error: ");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
123 vfprintf(stdmsg, format, ap);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
124 fprintf(stdmsg, "\n");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
125 fflush(stdmsg);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
126 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
127 global.errors++;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
128 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
129
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
130 /***************************************
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
131 * Call this after printing out fatal error messages to clean up and exit
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
132 * the compiler.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
133 */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
134
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
135 void fatal()
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
136 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
137 #if 0
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
138 halt();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
139 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
140 exit(EXIT_FAILURE);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
141 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
142
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
143 /**************************************
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
144 * Try to stop forgetting to remove the breakpoints from
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
145 * release builds.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
146 */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
147 void halt()
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
148 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
149 #ifdef DEBUG
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
150 *(char*)0=0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
151 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
152 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
153
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
154 extern void backend_init();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
155 extern void backend_term();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
156
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
157 void usage()
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
158 {
205
9d44ec83acd1 [svn r221] Update: Switched to the 2.3 LLVM svn branch, http://llvm.org/svn/llvm-project/llvm/branches/release_23 .
lindquist
parents: 159
diff changeset
159 printf("LLVM D Compiler %s (based on DMD %s and LLVM 2.3)\n%s\n%s\n",
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
160 global.llvmdc_version, global.version, global.copyright, global.written);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
161 printf("\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
162 D Language Documentation: http://www.digitalmars.com/d/1.0/index.html\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
163 LLVMDC Homepage: http://www.dsource.org/projects/llvmdc\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
164 Usage:\n\
323
0d52412d5b1a [svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents: 306
diff changeset
165 llvmdc files.d ... { -switch }\n\
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
166 \n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
167 files.d D source files\n%s\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
168 -annotate annotate the bitcode with human readable source code\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
169 -c do not link\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
170 -cov do code coverage analysis\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
171 -D generate documentation\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
172 -Dd<docdir> write documentation file to <docdir> directory\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
173 -Df<filename> write documentation file to <filename>\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
174 -d allow deprecated features\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
175 -debug compile in debug code\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
176 -debug=level compile in debug code <= level\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
177 -debug=ident compile in debug code identified by ident\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
178 -debuglib=name set symbolic debug library to name\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
179 -defaultlib=name set default library to name\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
180 -dis disassemble module after compiling\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
181 -g add symbolic debug info\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
182 -gc add symbolic debug info, pretend to be C\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
183 -H generate 'header' file\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
184 -Hd<hdrdir> write 'header' file to <hdrdir> directory\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
185 -Hf<filename> write 'header' file to <filename>\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
186 --help print help\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
187 -I<path> where to look for imports\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
188 -J<path> where to look for string imports\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
189 -ignore ignore unsupported pragmas\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
190 -inline do function inlining\n\
323
0d52412d5b1a [svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents: 306
diff changeset
191 -L<linkerflag> pass <linkerflag> to llvm-ld\n\
0d52412d5b1a [svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents: 306
diff changeset
192 -m<arch> emit code specific to <arch> being one of:\n\
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
193 x86 x86-64 ppc32 ppc64\n\
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
194 -noasm do not allow use of inline asm\n\
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
195 -nofloat do not emit reference to floating point\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
196 -noruntime do not allow code that generates implicit runtime calls\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
197 -noverify do not run the validation pass before writing bitcode\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
198 -O optimize, same as -O2\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
199 -O<n> optimize at level <n> (0-5)\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
200 -o- do not write object file\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
201 -od<objdir> write object files to directory <objdir>\n\
323
0d52412d5b1a [svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents: 306
diff changeset
202 -of<filename> name output file to <filename>\n\
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
203 -op do not strip paths from source file\n\
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 205
diff changeset
204 -oq write object files with fully qualified names\n\
323
0d52412d5b1a [svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents: 306
diff changeset
205 -profile profile runtime performance of generated code\n\
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
206 -quiet suppress unnecessary messages\n\
323
0d52412d5b1a [svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents: 306
diff changeset
207 -release compile release version\n\
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
208 -run srcfile args... run resulting program, passing args\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
209 -R<path> provide path to the directory containing the runtime library\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
210 -unittest compile in unit tests\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
211 -v verbose\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
212 -vv very verbose (does not include -v)\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
213 -v1 D language version 1\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
214 -version=level compile in version code >= level\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
215 -version=ident compile in version code identified by ident\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
216 -w enable warnings\n\
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
217 ",
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
218 #if WIN32
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
219 " @cmdfile read arguments from cmdfile\n"
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
220 #else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
221 ""
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
222 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
223 );
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
224 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
225
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
226 int main(int argc, char *argv[])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
227 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
228 int i;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
229 Array files;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
230 char *p;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
231 Module *m;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
232 int status = EXIT_SUCCESS;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
233 int argcstart = argc;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
234 char* tt_arch = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
235 char* tt_os = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
236 char* data_layout = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
237 bool very_verbose = false;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
238
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
239 // Check for malformed input
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
240 if (argc < 1 || !argv)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
241 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
242 Largs:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
243 error("missing or null command line arguments");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
244 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
245 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
246 for (i = 0; i < argc; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
247 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
248 if (!argv[i])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
249 goto Largs;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
250 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
251
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
252 #if __DMC__ // DMC unique support for response files
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
253 if (response_expand(&argc,&argv)) // expand response files
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
254 error("can't open response file");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
255 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
256
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
257 files.reserve(argc - 1);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
258
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
259 // Set default values
432
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
260 #if _WIN32
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
261 char buf[MAX_PATH];
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
262 GetModuleFileName(NULL, buf, MAX_PATH);
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
263 global.params.argv0 = buf;
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
264 #else
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
265 global.params.argv0 = argv[0];
432
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
266 #endif
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
267 global.params.link = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
268 global.params.useAssert = 0;
327
781af50846b2 [svn r348] Switch on class invariants (except in release mode).
ChristianK
parents: 323
diff changeset
269 global.params.useInvariants = 1;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
270 global.params.useIn = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
271 global.params.useOut = 1;
439
47b64d06eb9f Enable array bounds check and emit them in IndexExp.
Christian Kamm <kamm incasoftware de>
parents: 432
diff changeset
272 global.params.useArrayBounds = 1;
331
04e1b4930975 [svn r352] Implement SwitchErrorStatement. Fixes #52.
ChristianK
parents: 327
diff changeset
273 global.params.useSwitchError = 1;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
274 global.params.useInline = 0; // this one messes things up to a point where codegen breaks
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
275 global.params.llvmInline = 0; // use this one instead to know if inline passes should be run
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
276 global.params.obj = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
277 global.params.Dversion = 2;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
278 global.params.quiet = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
279
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
280 global.params.linkswitches = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
281 global.params.libfiles = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
282 global.params.objfiles = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
283 global.params.ddocfiles = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
284
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
285 global.params.is64bit = sizeof(void*) == 8 ? 1 : 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
286
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
287 uint16_t endiantest = 0xFF00;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
288 uint8_t endianres = ((uint8_t*)&endiantest)[0];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
289 if (endianres == 0x00)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
290 global.params.isLE = true;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
291 else if (endianres == 0xFF)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
292 global.params.isLE = false;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
293 else {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
294 error("Endian test is broken");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
295 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
296 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
297
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
298 global.params.llvmArch = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
299 global.params.forceBE = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
300 global.params.noruntime = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
301 global.params.novalidate = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
302 global.params.optimizeLevel = -1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
303 global.params.runtimeImppath = 0;
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
304 global.params.useInlineAsm = 1;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
305
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
306 global.params.defaultlibname = "phobos";
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
307 global.params.debuglibname = global.params.defaultlibname;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
308
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
309 // Predefine version identifiers
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
310 #if IN_LLVM
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
311 VersionCondition::addPredefinedGlobalIdent("LLVM");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
312 VersionCondition::addPredefinedGlobalIdent("LLVMDC");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
313 #endif
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 484
diff changeset
314
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
315 #if _WIN32
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
316 VersionCondition::addPredefinedGlobalIdent("Windows");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
317 VersionCondition::addPredefinedGlobalIdent("Win32");
279
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
318 VersionCondition::addPredefinedGlobalIdent("mingw32");
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
319 global.params.isWindows = 1;
250
fc9c1a0eabbd [svn r267] Fixed debug info for global variables.
lindquist
parents: 237
diff changeset
320 tt_os = "-pc-mingw32";
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
321 #elif linux
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
322 VersionCondition::addPredefinedGlobalIdent("linux");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
323 global.params.isLinux = 1;
279
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
324 tt_os = "-pc-linux-gnu";
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
325 #else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
326 #error
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
327 #endif /* linux */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
328
279
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
329 // !win32 == posix for now
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
330 if (!global.params.isWindows)
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
331 VersionCondition::addPredefinedGlobalIdent("Posix");
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
332
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
333 //VersionCondition::addPredefinedGlobalIdent("D_Bits");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
334 VersionCondition::addPredefinedGlobalIdent("all");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
335
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
336 #if _WIN32
432
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
337 inifile(global.params.argv0, "llvmdc.ini");
285
297690b5d4a5 [svn r306] Fixed: it's now possible to compile and link llvmdc with MinGW32 and msys on Win32 :D I tried it myself ;) Building the runtime still needs some work, but it's a step in the right direction.
lindquist
parents: 284
diff changeset
338 #elif linux
432
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
339 inifile(global.params.argv0, "llvmdc.conf");
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
340 #else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
341 #error
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
342 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
343 getenv_setargv("DFLAGS", &argc, &argv);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
344
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
345 #if 0
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
346 for (i = 0; i < argc; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
347 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
348 printf("argv[%d] = '%s'\n", i, argv[i]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
349 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
350 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
351
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
352 for (i = 1; i < argc; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
353 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
354 p = argv[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
355 if (*p == '-')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
356 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
357 if (strcmp(p + 1, "d") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
358 global.params.useDeprecated = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
359 else if (strcmp(p + 1, "c") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
360 global.params.link = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
361 else if (strcmp(p + 1, "cov") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
362 global.params.cov = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
363 else if (strcmp(p + 1, "fPIC") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
364 global.params.pic = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
365 else if (strcmp(p + 1, "g") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
366 global.params.symdebug = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
367 else if (strcmp(p + 1, "gc") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
368 global.params.symdebug = 2;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
369 else if (strcmp(p + 1, "gt") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
370 { error("use -profile instead of -gt\n");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
371 global.params.trace = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
372 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
373 else if (strcmp(p + 1, "profile") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
374 global.params.trace = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
375 else if (strcmp(p + 1, "v") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
376 global.params.verbose = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
377 else if (strcmp(p + 1, "vv") == 0) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
378 Logger::enable();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
379 very_verbose = true;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
380 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
381 else if (strcmp(p + 1, "v1") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
382 global.params.Dversion = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
383 else if (strcmp(p + 1, "w") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
384 global.params.warnings = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
385 else if (p[1] == 'O')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
386 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
387 global.params.optimize = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
388 global.params.optimizeLevel = 2;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
389 if (p[2] != 0) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
390 int optlevel = atoi(p+2);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
391 if (optlevel < 0 || optlevel > 5) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
392 error("Optimization level must be between 0 and 5. Using default (%d)",
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
393 global.params.optimizeLevel);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
394 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
395 else {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
396 global.params.optimizeLevel = optlevel;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
397 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
398 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
399 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
400 else if (strcmp(p + 1, "forcebe") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
401 global.params.forceBE = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
402 else if (strcmp(p + 1, "noruntime") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
403 global.params.noruntime = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
404 else if (strcmp(p + 1, "noverify") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
405 global.params.novalidate = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
406 else if (strcmp(p + 1, "dis") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
407 global.params.disassemble = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
408 else if (strcmp(p + 1, "annotate") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
409 global.params.llvmAnnotate = 1;
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
410 else if (strcmp(p + 1, "noasm") == 0)
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
411 global.params.useInlineAsm = 0;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
412 else if (p[1] == 'o')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
413 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
414 switch (p[2])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
415 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
416 case '-':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
417 global.params.obj = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
418 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
419
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
420 case 'd':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
421 if (!p[3])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
422 goto Lnoarg;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
423 global.params.objdir = p + 3;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
424 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
425
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
426 case 'f':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
427 if (!p[3])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
428 goto Lnoarg;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
429 global.params.objname = p + 3;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
430 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
431
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
432 case 'p':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
433 if (p[3])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
434 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
435 global.params.preservePaths = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
436 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
437
217
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 205
diff changeset
438 case 'q':
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 205
diff changeset
439 if (p[3])
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 205
diff changeset
440 goto Lerror;
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 205
diff changeset
441 global.params.fqnPaths = 1;
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 205
diff changeset
442 break;
0806379a5eca [svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents: 205
diff changeset
443
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
444 case 0:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
445 error("-o no longer supported, use -of or -od");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
446 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
447
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
448 default:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
449 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
450 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
451 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
452 else if (p[1] == 'D')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
453 { global.params.doDocComments = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
454 switch (p[2])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
455 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
456 case 'd':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
457 if (!p[3])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
458 goto Lnoarg;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
459 global.params.docdir = p + 3;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
460 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
461 case 'f':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
462 if (!p[3])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
463 goto Lnoarg;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
464 global.params.docname = p + 3;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
465 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
466
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
467 case 0:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
468 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
469
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
470 default:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
471 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
472 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
473 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
474 #ifdef _DH
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
475 else if (p[1] == 'H')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
476 { global.params.doHdrGeneration = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
477 switch (p[2])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
478 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
479 case 'd':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
480 if (!p[3])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
481 goto Lnoarg;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
482 global.params.hdrdir = p + 3;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
483 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
484
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
485 case 'f':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
486 if (!p[3])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
487 goto Lnoarg;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
488 global.params.hdrname = p + 3;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
489 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
490
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
491 case 0:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
492 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
493
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
494 default:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
495 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
496 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
497 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
498 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
499 else if (strcmp(p + 1, "ignore") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
500 global.params.ignoreUnsupportedPragmas = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
501 else if (strcmp(p + 1, "inline") == 0) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
502 // TODO
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
503 // the ast rewrites dmd does for inlining messes up the ast.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
504 // someday maybe we can support it, for now llvm does an excellent job at inlining
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
505 global.params.useInline = 0; //1
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
506 global.params.llvmInline = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
507 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
508 else if (strcmp(p + 1, "nofloat") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
509 global.params.nofloat = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
510 else if (strcmp(p + 1, "quiet") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
511 global.params.quiet = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
512 else if (strcmp(p + 1, "release") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
513 global.params.release = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
514 else if (strcmp(p + 1, "unittest") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
515 global.params.useUnitTests = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
516 else if (p[1] == 'I')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
517 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
518 if (!global.params.imppath)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
519 global.params.imppath = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
520 global.params.imppath->push(p + 2);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
521 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
522 else if (p[1] == 'J')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
523 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
524 if (!global.params.fileImppath)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
525 global.params.fileImppath = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
526 global.params.fileImppath->push(p + 2);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
527 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
528 else if (p[1] == 'R')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
529 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
530 global.params.runtimePath = p+2;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
531 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
532 else if (memcmp(p + 1, "debug", 5) == 0 && p[6] != 'l')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
533 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
534 // Parse:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
535 // -debug
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
536 // -debug=number
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
537 // -debug=identifier
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
538 if (p[6] == '=')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
539 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
540 if (isdigit(p[7]))
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
541 { long level;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
542
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
543 errno = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
544 level = strtol(p + 7, &p, 10);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
545 if (*p || errno || level > INT_MAX)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
546 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
547 DebugCondition::setGlobalLevel((int)level);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
548 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
549 else if (Lexer::isValidIdentifier(p + 7))
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
550 DebugCondition::addGlobalIdent(p + 7);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
551 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
552 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
553 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
554 else if (p[6])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
555 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
556 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
557 global.params.debuglevel = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
558 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
559 else if (memcmp(p + 1, "version", 5) == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
560 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
561 // Parse:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
562 // -version=number
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
563 // -version=identifier
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
564 if (p[8] == '=')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
565 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
566 if (isdigit(p[9]))
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
567 { long level;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
568
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
569 errno = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
570 level = strtol(p + 9, &p, 10);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
571 if (*p || errno || level > INT_MAX)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
572 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
573 VersionCondition::setGlobalLevel((int)level);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
574 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
575 else if (Lexer::isValidIdentifier(p + 9))
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
576 VersionCondition::addGlobalIdent(p + 9);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
577 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
578 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
579 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
580 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
581 goto Lerror;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
582 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
583 else if (strcmp(p + 1, "-b") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
584 global.params.debugb = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
585 else if (strcmp(p + 1, "-c") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
586 global.params.debugc = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
587 else if (strcmp(p + 1, "-f") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
588 global.params.debugf = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
589 else if (strcmp(p + 1, "-help") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
590 { usage();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
591 exit(EXIT_SUCCESS);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
592 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
593 else if (strcmp(p + 1, "-r") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
594 global.params.debugr = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
595 else if (strcmp(p + 1, "-x") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
596 global.params.debugx = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
597 else if (strcmp(p + 1, "-y") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
598 global.params.debugy = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
599 else if (p[1] == 'L')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
600 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
601 global.params.linkswitches->push(p + 2);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
602 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
603 else if (memcmp(p + 1, "defaultlib=", 11) == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
604 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
605 global.params.defaultlibname = p + 1 + 11;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
606 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
607 else if (memcmp(p + 1, "debuglib=", 9) == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
608 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
609 global.params.debuglibname = p + 1 + 9;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
610 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
611 else if (strcmp(p + 1, "run") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
612 { global.params.run = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
613 global.params.runargs_length = ((i >= argcstart) ? argc : argcstart) - i - 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
614 if (global.params.runargs_length)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
615 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
616 files.push(argv[i + 1]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
617 global.params.runargs = &argv[i + 2];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
618 i += global.params.runargs_length;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
619 global.params.runargs_length--;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
620 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
621 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
622 { global.params.run = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
623 goto Lnoarg;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
624 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
625 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
626 else if (p[1] == 'm')
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
627 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
628 global.params.llvmArch = p+2;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
629 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
630 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
631 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
632 Lerror:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
633 error("unrecognized switch '%s'", argv[i]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
634 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
635
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
636 Lnoarg:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
637 error("argument expected for switch '%s'", argv[i]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
638 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
639 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
640 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
641 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
642 files.push(p);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
643 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
644 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
645 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
646 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
647 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
648 if (files.dim == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
649 { usage();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
650 return EXIT_FAILURE;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
651 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
652
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
653 if (global.params.release)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
654 { global.params.useInvariants = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
655 global.params.useIn = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
656 global.params.useOut = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
657 global.params.useAssert = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
658 global.params.useArrayBounds = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
659 global.params.useSwitchError = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
660 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
661
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
662 if (global.params.run)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
663 global.params.quiet = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
664
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
665 if (global.params.useUnitTests)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
666 global.params.useAssert = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
667
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
668 if (!global.params.obj)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
669 global.params.link = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
670
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
671 if (global.params.link)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
672 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
673 global.params.exefile = global.params.objname;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
674 global.params.objname = NULL;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
675 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
676 else if (global.params.run)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
677 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
678 error("flags conflict with -run");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
679 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
680 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
681 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
682 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
683 if (global.params.objname && files.dim > 1)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
684 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
685 error("multiple source files, but only one .obj name");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
686 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
687 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
688 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
689 if (global.params.cov)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
690 VersionCondition::addPredefinedGlobalIdent("D_Coverage");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
691
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
692 bool allowForceEndianness = false;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
693
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
694 if (global.params.llvmArch == 0) {
284
70c370e97944 [svn r305] Started support for custom class allocators/deallocators. Allocators with more than one argument still need to be fixed.
lindquist
parents: 279
diff changeset
695 findDefaultTarget();
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
696 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
697
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
698 if (strcmp(global.params.llvmArch,"x86")==0) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
699 VersionCondition::addPredefinedGlobalIdent("X86");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
700 global.params.isLE = true;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
701 global.params.is64bit = false;
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
702 global.params.cpu = ARCHx86;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
703 tt_arch = "i686";
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
704 data_layout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-f80:32:32-v64:64:64-v128:128:128-a0:0:64";
445
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 439
diff changeset
705 if (global.params.useInlineAsm) {
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 439
diff changeset
706 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm");
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 439
diff changeset
707 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86");
cc40db549aea Changed the handling of variadic intrinsics a bit.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 439
diff changeset
708 }
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
709 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
710 else if (strcmp(global.params.llvmArch,"x86-64")==0) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
711 VersionCondition::addPredefinedGlobalIdent("X86_64");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
712 global.params.isLE = true;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
713 global.params.is64bit = true;
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
714 global.params.cpu = ARCHx86_64;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
715 tt_arch = "x86_64";
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
716 data_layout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
717 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
718 else if (strcmp(global.params.llvmArch,"ppc32")==0) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
719 VersionCondition::addPredefinedGlobalIdent("PPC");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
720 global.params.isLE = false;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
721 global.params.is64bit = false;
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
722 global.params.cpu = ARCHppc;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
723 tt_arch = "powerpc";
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
724 data_layout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64";
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
725 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
726 else if (strcmp(global.params.llvmArch,"ppc64")==0) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
727 VersionCondition::addPredefinedGlobalIdent("PPC64");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
728 global.params.isLE = false;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
729 global.params.is64bit = true;
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
730 global.params.cpu = ARCHppc_64;
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
731 tt_arch = "powerpc64";
237
a168a2c3ea48 [svn r253] Removed -inlineasm option. inline asm is now enabled by default unless the new -noasm option is passed.
lindquist
parents: 220
diff changeset
732 data_layout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64";
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
733 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
734 else {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
735 assert(0 && "Invalid arch");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
736 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
737
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
738 if (allowForceEndianness && global.params.forceBE) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
739 VersionCondition::addPredefinedGlobalIdent("BigEndian");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
740 global.params.isLE = false;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
741 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
742 else if (global.params.isLE) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
743 VersionCondition::addPredefinedGlobalIdent("LittleEndian");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
744 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
745 else {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
746 VersionCondition::addPredefinedGlobalIdent("BigEndian");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
747 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
748
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
749 if (global.params.is64bit) {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
750 VersionCondition::addPredefinedGlobalIdent("LLVM64");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
751 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
752
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
753 assert(tt_arch != 0);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
754 assert(tt_os != 0);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
755 assert(data_layout != 0);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
756 global.params.tt_arch = tt_arch;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
757 global.params.tt_os = tt_os;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
758 global.params.data_layout = data_layout;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
759
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
760 // Initialization
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
761 Type::init();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
762 Id::initialize();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
763 Module::init();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
764 initPrecedence();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
765
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
766 backend_init();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
767
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
768 //printf("%d source files\n",files.dim);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
769
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
770 // Build import search path
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
771 if (global.params.imppath)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
772 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
773 for (i = 0; i < global.params.imppath->dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
774 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
775 char *path = (char *)global.params.imppath->data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
776 Array *a = FileName::splitPath(path);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
777
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
778 if (a)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
779 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
780 if (!global.path)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
781 global.path = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
782 global.path->append(a);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
783 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
784 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
785 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
786
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
787 // Build string import search path
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
788 if (global.params.fileImppath)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
789 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
790 for (i = 0; i < global.params.fileImppath->dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
791 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
792 char *path = (char *)global.params.fileImppath->data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
793 Array *a = FileName::splitPath(path);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
794
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
795 if (a)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
796 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
797 if (!global.filePath)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
798 global.filePath = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
799 global.filePath->append(a);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
800 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
801 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
802 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
803
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
804 // Create Modules
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
805 Array modules;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
806 modules.reserve(files.dim);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
807 for (i = 0; i < files.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
808 { Identifier *id;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
809 char *ext;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
810 char *name;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
811
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
812 p = (char *) files.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
813
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
814 p = FileName::name(p); // strip path
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
815 ext = FileName::ext(p);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
816 if (ext)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
817 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
818 #if IN_LLVM
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
819 if (strcmp(ext, global.nativeobj_ext) == 0 ||
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
820 strcmp(ext, global.obj_ext) == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
821 #elif TARGET_LINUX
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
822 if (strcmp(ext, global.obj_ext) == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
823 #else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
824 if (stricmp(ext, global.obj_ext) == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
825 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
826 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
827 global.params.objfiles->push(files.data[i]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
828 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
829 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
830
279
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
831 #if TARGET_LINUX || __MINGW32__
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
832 if (strcmp(ext, "a") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
833 #else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
834 if (stricmp(ext, "lib") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
835 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
836 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
837 global.params.libfiles->push(files.data[i]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
838 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
839 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
840
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
841 if (strcmp(ext, global.ddoc_ext) == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
842 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
843 global.params.ddocfiles->push(files.data[i]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
844 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
845 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
846
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
847 #if !TARGET_LINUX
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
848 if (stricmp(ext, "res") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
849 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
850 global.params.resfile = (char *)files.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
851 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
852 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
853
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
854 if (stricmp(ext, "def") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
855 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
856 global.params.deffile = (char *)files.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
857 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
858 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
859
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
860 if (stricmp(ext, "exe") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
861 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
862 global.params.exefile = (char *)files.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
863 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
864 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
865 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
866
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
867 if (stricmp(ext, global.mars_ext) == 0 ||
510
6aee82889553 Merged DMD 1.034, array operations are not yet implemented ;)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 486
diff changeset
868 stricmp(ext, global.hdr_ext) == 0 ||
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
869 stricmp(ext, "htm") == 0 ||
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
870 stricmp(ext, "html") == 0 ||
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
871 stricmp(ext, "xhtml") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
872 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
873 ext--; // skip onto '.'
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
874 assert(*ext == '.');
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
875 name = (char *)mem.malloc((ext - p) + 1);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
876 memcpy(name, p, ext - p);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
877 name[ext - p] = 0; // strip extension
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
878
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
879 if (name[0] == 0 ||
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
880 strcmp(name, "..") == 0 ||
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
881 strcmp(name, ".") == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
882 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
883 Linvalid:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
884 error("invalid file name '%s'", (char *)files.data[i]);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
885 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
886 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
887 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
888 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
889 { error("unrecognized file extension %s\n", ext);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
890 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
891 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
892 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
893 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
894 { name = p;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
895 if (!*name)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
896 goto Linvalid;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
897 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
898
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
899 id = new Identifier(name, 0);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
900 m = new Module((char *) files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
901 modules.push(m);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
902
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
903 global.params.objfiles->push(m->objfile->name->str);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
904 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
905
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
906 // Read files, parse them
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
907 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
908 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
909 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
910 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
911 printf("parse %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
912 if (!Module::rootModule)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
913 Module::rootModule = m;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
914 m->importedFrom = m;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
915 m->deleteObjFile();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
916 m->read(0);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
917 m->parse();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
918 if (m->isDocFile)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
919 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
920 m->gendocfile();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
921
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
922 // Remove m from list of modules
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
923 modules.remove(i);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
924 i--;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
925
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
926 // Remove m's object file from list of object files
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
927 for (int j = 0; j < global.params.objfiles->dim; j++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
928 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
929 if (m->objfile->name->str == global.params.objfiles->data[j])
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
930 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
931 global.params.objfiles->remove(j);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
932 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
933 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
934 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
935
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
936 if (global.params.objfiles->dim == 0)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
937 global.params.link = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
938 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
939 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
940 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
941 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
942 #ifdef _DH
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
943 if (global.params.doHdrGeneration)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
944 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
945 /* Generate 'header' import files.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
946 * Since 'header' import files must be independent of command
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
947 * line switches and what else is imported, they are generated
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
948 * before any semantic analysis.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
949 */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
950 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
951 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
952 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
953 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
954 printf("import %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
955 m->genhdrfile();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
956 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
957 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
958 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
959 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
960 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
961
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
962 // Do semantic analysis
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
963 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
964 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
965 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
966 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
967 printf("semantic %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
968 m->semantic();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
969 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
970 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
971 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
972
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
973 // Do pass 2 semantic analysis
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
974 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
975 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
976 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
977 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
978 printf("semantic2 %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
979 m->semantic2();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
980 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
981 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
982 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
983
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
984 // Do pass 3 semantic analysis
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
985 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
986 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
987 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
988 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
989 printf("semantic3 %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
990 m->semantic3();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
991 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
992 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
993 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
994
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
995 #if !IN_LLVM
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
996 // Scan for functions to inline
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
997 if (global.params.useInline)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
998 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
999 /* The problem with useArrayBounds and useAssert is that the
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1000 * module being linked to may not have generated them, so if
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1001 * we inline functions from those modules, the symbols for them will
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1002 * not be found at link time.
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1003 */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1004 if (!global.params.useArrayBounds && !global.params.useAssert)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1005 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1006 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1007 // Do pass 3 semantic analysis on all imported modules,
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1008 // since otherwise functions in them cannot be inlined
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1009 for (i = 0; i < Module::amodules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1010 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1011 m = (Module *)Module::amodules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1012 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1013 printf("semantic3 %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1014 m->semantic3();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1015 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1016 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1017 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1018 #if !IN_LLVM
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1019 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1020
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1021 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1022 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1023 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1024 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1025 printf("inline scan %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1026 m->inlineScan();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1027 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1028 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1029 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1030 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1031 #endif
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1032
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1033 // Generate output files
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1034 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1035 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1036 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1037 if (global.params.verbose)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1038 printf("code %s\n", m->toChars());
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1039 if (global.params.obj)
336
aaade6ded589 [svn r357] Merged DMD 1.033
lindquist
parents: 331
diff changeset
1040 m->genobjfile(0);
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1041 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1042 m->deleteObjFile();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1043 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1044 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1045 if (global.params.doDocComments)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1046 m->gendocfile();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1047 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1048 }
279
a137ed004205 [svn r300] Removed some win32 stuff that was causing problems on mingw32.
lindquist
parents: 277
diff changeset
1049
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1050 backend_term();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1051 if (global.errors)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1052 fatal();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1053
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1054 if (!global.params.objfiles->dim)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1055 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1056 if (global.params.link)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1057 error("no object files to link");
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1058 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1059 else
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1060 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1061 if (global.params.link)
276
21f85bac0b1a [svn r297] Fixed: rewrote linker code to use LLVM's Program facilities instead of DMD's oldschool broken "native" approach.
lindquist
parents: 262
diff changeset
1062 //status = runLINK();
432
ecf70fe065b9 fixed configuration file loading issues on windows
elrood
parents: 374
diff changeset
1063 linkExecutable(global.params.argv0);
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1064
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1065 if (global.params.run)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1066 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1067 if (!status)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1068 {
277
90a8c798b0db [svn r298] Eliminated the dmd/link.c source file entirely in favor of a llvm::sys based approach to the same functionality.
lindquist
parents: 276
diff changeset
1069 status = runExectuable();
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1070
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1071 /* Delete .obj files and .exe file
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1072 */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1073 for (i = 0; i < modules.dim; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1074 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1075 m = (Module *)modules.data[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1076 m->deleteObjFile();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1077 }
277
90a8c798b0db [svn r298] Eliminated the dmd/link.c source file entirely in favor of a llvm::sys based approach to the same functionality.
lindquist
parents: 276
diff changeset
1078 deleteExecutable();
159
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1079 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1080 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1081 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1082
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1083 return status;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1084 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1085
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1086
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1087
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1088 /***********************************
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1089 * Parse and append contents of environment variable envvar
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1090 * to argc and argv[].
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1091 * The string is separated into arguments, processing \ and ".
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1092 */
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1093
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1094 void getenv_setargv(const char *envvar, int *pargc, char** *pargv)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1095 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1096 char *env;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1097 char *p;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1098 Array *argv;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1099 int argc;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1100
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1101 int wildcard; // do wildcard expansion
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1102 int instring;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1103 int slash;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1104 char c;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1105 int j;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1106
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1107 env = getenv(envvar);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1108 if (!env)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1109 return;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1110
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1111 env = mem.strdup(env); // create our own writable copy
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1112
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1113 argc = *pargc;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1114 argv = new Array();
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1115 argv->setDim(argc);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1116
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1117 for (int i = 0; i < argc; i++)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1118 argv->data[i] = (void *)(*pargv)[i];
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1119
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1120 j = 1; // leave argv[0] alone
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1121 while (1)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1122 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1123 wildcard = 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1124 switch (*env)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1125 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1126 case ' ':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1127 case '\t':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1128 env++;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1129 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1130
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1131 case 0:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1132 goto Ldone;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1133
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1134 case '"':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1135 wildcard = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1136 default:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1137 argv->push(env); // append
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1138 //argv->insert(j, env); // insert at position j
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1139 j++;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1140 argc++;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1141 p = env;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1142 slash = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1143 instring = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1144 c = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1145
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1146 while (1)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1147 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1148 c = *env++;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1149 switch (c)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1150 {
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1151 case '"':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1152 p -= (slash >> 1);
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1153 if (slash & 1)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1154 { p--;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1155 goto Laddc;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1156 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1157 instring ^= 1;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1158 slash = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1159 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1160
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1161 case ' ':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1162 case '\t':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1163 if (instring)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1164 goto Laddc;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1165 *p = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1166 //if (wildcard)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1167 //wildcardexpand(); // not implemented
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1168 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1169
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1170 case '\\':
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1171 slash++;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1172 *p++ = c;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1173 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1174
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1175 case 0:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1176 *p = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1177 //if (wildcard)
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1178 //wildcardexpand(); // not implemented
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1179 goto Ldone;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1180
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1181 default:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1182 Laddc:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1183 slash = 0;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1184 *p++ = c;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1185 continue;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1186 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1187 break;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1188 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1189 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1190 }
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1191
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1192 Ldone:
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1193 *pargc = argc;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1194 *pargv = (char **)argv->data;
5acec6b2eef8 [svn r175] merged dmd 1.029
ChristianK
parents: 151
diff changeset
1195 }