annotate main.d @ 191:52188e7e3fb5

Fixed deprecated features, now compiles with DMD2.058 Also changed Array allocation policy: Now doesn't reallocate but malloc's, followed by a memcpy (no free). (this fixes a crash while compiling druntime. Same bug in dmd)
author korDen@korDen-pc
date Sun, 25 Mar 2012 03:11:12 +0400
parents 190ba98276b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module main;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
99
903b95002d4e Id and Macro are quite experimental currently
Trass3r
parents: 79
diff changeset
3 import dmd.Macro;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Module;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.VersionCondition;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.DebugCondition;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Lexer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.FileName;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.File;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Identifier;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
17 import dmd.Json;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Library;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.String;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.backend.glue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
191
52188e7e3fb5 Fixed deprecated features, now compiles with DMD2.058
korDen@korDen-pc
parents: 183
diff changeset
23 import core.vararg;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import std.string : toStringz;
34
544b922227c7 update to work with dmd 2.048
korDen
parents: 25
diff changeset
25 import std.exception;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import core.stdc.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import core.stdc.stdio;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import core.stdc.ctype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import core.stdc.errno;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import core.stdc.stdlib;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import core.stdc.limits;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import core.memory;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
183
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
36 version (Windows)
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
37 import dbg.CallStackInfo;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 enum ExitCode
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 EXIT_SUCCESS = 0,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45
191
52188e7e3fb5 Fixed deprecated features, now compiles with DMD2.058
korDen@korDen-pc
parents: 183
diff changeset
46 //version = CrashHandler;
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
47
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
48 version (CrashHandler) {
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
49 version(Linux)
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
50 {
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
51 extern (C) extern __gshared bool rt_trapExceptions;
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
52
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
53 static this() {
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
54 rt_trapExceptions = false;
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
55 }
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
56
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
57 }
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
58
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
59
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
60 version(Windows)
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
61 {
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
62
70
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
63 version (Windows)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
64 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
65 private import core.stdc.wchar_;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
66
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
67 extern (Windows) alias int function() FARPROC;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
68 extern (Windows) FARPROC GetProcAddress(void*, in char*);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
69 extern (Windows) void* LoadLibraryA(in char*);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
70 extern (Windows) int FreeLibrary(void*);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
71 extern (Windows) void* LocalFree(void*);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
72 extern (Windows) wchar_t* GetCommandLineW();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
73 extern (Windows) wchar_t** CommandLineToArgvW(wchar_t*, int*);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
74 extern (Windows) export int WideCharToMultiByte(uint, uint, wchar_t*, int, char*, int, char*, int);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
75 pragma(lib, "shell32.lib"); // needed for CommandLineToArgvW
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
76 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
77
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
78 shared bool _d_isHalting = false;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
79 __gshared string[] _d_args = null;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
80
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
81 version(Posix)
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
82 {
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
83 extern (C) void _STI_monitor_staticctor();
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
84 extern (C) void _STD_monitor_staticdtor();
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
85 extern (C) void _STI_critical_init();
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
86 extern (C) void _STD_critical_term();
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
87 }
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
88
70
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
89 extern (C) void gc_init();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
90 extern (C) void gc_term();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
91 extern (C) void _minit();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
92 extern (C) void _moduleCtor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
93 extern (C) void _moduleDtor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
94 extern (C) bool runModuleUnitTests();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
95 extern (C) void thread_joinAll();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
96
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
97 import rt.memory;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
98
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
99 extern (C) int main(int argc, char** argv)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
100 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
101 char[][] args;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
102 int result;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
103
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
104 version (OSX)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
105 { /* OSX does not provide a way to get at the top of the
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
106 * stack, except for the magic value 0xC0000000.
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
107 * But as far as the gc is concerned, argv is at the top
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
108 * of the main thread's stack, so save the address of that.
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
109 */
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
110 __osx_stack_end = cast(void*)&argv;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
111 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
112
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
113 version (FreeBSD) version (D_InlineAsm_X86)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
114 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
115 /*
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
116 * FreeBSD/i386 sets the FPU precision mode to 53 bit double.
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
117 * Make it 64 bit extended.
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
118 */
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
119 ushort fpucw;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
120 asm
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
121 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
122 fstsw fpucw;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
123 or fpucw, 0b11_00_111111; // 11: use 64 bit extended-precision
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
124 // 111111: mask all FP exceptions
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
125 fldcw fpucw;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
126 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
127 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
128
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
129 version (Posix)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
130 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
131 _STI_monitor_staticctor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
132 _STI_critical_init();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
133 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
70
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
135 version (Windows)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
136 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
137 wchar_t* wcbuf = GetCommandLineW();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
138 size_t wclen = wcslen(wcbuf);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
139 int wargc = 0;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
140 wchar_t** wargs = CommandLineToArgvW(wcbuf, &wargc);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
141 assert(wargc == argc);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
142
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
143 char* cargp = null;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
144 size_t cargl = WideCharToMultiByte(65001, 0, wcbuf, wclen, null, 0, null, 0);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
145
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
146 cargp = cast(char*) alloca(cargl);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
147 args = ((cast(char[]*) alloca(wargc * (char[]).sizeof)))[0 .. wargc];
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
148
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
149 for (size_t i = 0, p = 0; i < wargc; i++)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
150 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
151 int wlen = wcslen(wargs[i]);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
152 int clen = WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, null, 0, null, 0);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
153 args[i] = cargp[p .. p+clen];
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
154 p += clen; assert(p <= cargl);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
155 WideCharToMultiByte(65001, 0, &wargs[i][0], wlen, &args[i][0], clen, null, 0);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
156 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
157 LocalFree(wargs);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
158 wargs = null;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
159 wargc = 0;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
160 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
161 else version (Posix)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
162 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
163 char[]* am = cast(char[]*) malloc(argc * (char[]).sizeof);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
164 scope(exit) free(am);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
165
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
166 for (size_t i = 0; i < argc; i++)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
167 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
168 auto len = strlen(argv[i]);
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
169 am[i] = argv[i][0 .. len];
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
170 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
171 args = am[0 .. argc];
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
172 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
173 _d_args = cast(string[]) args;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
174
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
175 void runMain()
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
176 {
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
177 CrashHandlerInit();
165
25ede4f66bda Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents: 164
diff changeset
178 // while (true)
25ede4f66bda Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents: 164
diff changeset
179 {
25ede4f66bda Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents: 164
diff changeset
180 result = main(_d_args);
25ede4f66bda Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents: 164
diff changeset
181 }
70
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
182 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
183
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
184 void runAll()
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
185 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
186 gc_init();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
187 initStaticDataGC();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
188 version (Windows)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
189 _minit();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
190 _moduleCtor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
191 _moduleTlsCtor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
192 if (runModuleUnitTests())
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
193 runMain();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
194 else
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
195 result = EXIT_FAILURE;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
196 _moduleTlsDtor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
197 thread_joinAll();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
198 _d_isHalting = true;
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
199 _moduleDtor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
200 gc_term();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
201 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
202
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
203 runAll();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
204
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
205 version (Posix)
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
206 {
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
207 _STD_critical_term();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
208 _STD_monitor_staticdtor();
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
209 }
6bdecc3f4569 Get rid of win32 bindings
korDen
parents: 34
diff changeset
210 return result;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 }
25
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 22
diff changeset
212
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
213 }
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
214 }
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 70
diff changeset
215
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 int main(string[] args)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 {
165
25ede4f66bda Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents: 164
diff changeset
218 GC.disable();
25ede4f66bda Temporarily disabled GC (again) because phobos fails to compile with it (looks like some ObjSymbols are being falsely collected, see Library.d:666)
korDen
parents: 164
diff changeset
219
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 Array files = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 Array libmodules = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 Module m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 int status = ExitCode.EXIT_SUCCESS;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 int argcstart = args.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 int setdebuglib = 0;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
226 byte noboundscheck = 0;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 global = new Global();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 /// if (response_expand(&argc,&argv)) // expand response files
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 /// error("can't open response file");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 files.reserve(args.length - 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 // Set default values
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 global.params.argv0 = args[0];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 global.params.link = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 global.params.useAssert = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 global.params.useInvariants = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 global.params.useIn = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 global.params.useOut = 1;
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
242 global.params.useArrayBounds = 2; // default to all functions
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 global.params.useSwitchError = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 global.params.useInline = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 global.params.obj = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 global.params.Dversion = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 global.params.quiet = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 global.params.linkswitches = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 global.params.libfiles = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 global.params.objfiles = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 global.params.ddocfiles = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 global.params.defaultlibname = "phobos";
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
256 } else version (POSIX) { //#elif TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 global.params.defaultlibname = "phobos2";
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 } else version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 static assert(false, "fix this");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 // Predefine version identifiers
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 VersionCondition.addPredefinedGlobalIdent("DigitalMars");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 VersionCondition.addPredefinedGlobalIdent("Windows");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 global.params.isWindows = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 version (TARGET_NET) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 // TARGET_NET macro is NOT mutually-exclusive with TARGET_WINDOS
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 VersionCondition.addPredefinedGlobalIdent("D_NET");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 } else version (TARGET_LINUX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 VersionCondition.addPredefinedGlobalIdent("Posix");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 VersionCondition.addPredefinedGlobalIdent("linux");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 global.params.isLinux = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 } else version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 VersionCondition.addPredefinedGlobalIdent("Posix");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 VersionCondition.addPredefinedGlobalIdent("OSX");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 global.params.isOSX = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 // For legacy compatibility
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 VersionCondition.addPredefinedGlobalIdent("darwin");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 } else version (TARGET_FREEBSD) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 VersionCondition.addPredefinedGlobalIdent("Posix");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 VersionCondition.addPredefinedGlobalIdent("FreeBSD");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 global.params.isFreeBSD = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 } else version (TARGET_SOLARIS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 VersionCondition.addPredefinedGlobalIdent("Posix");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 VersionCondition.addPredefinedGlobalIdent("Solaris");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 global.params.isSolaris = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 static assert (false, "fix this");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 VersionCondition.addPredefinedGlobalIdent("LittleEndian");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 //VersionCondition.addPredefinedGlobalIdent("D_Bits");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 VersionCondition.addPredefinedGlobalIdent("D_Version2");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 VersionCondition.addPredefinedGlobalIdent("all");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
303 version (Windows)
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
304 {
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
305 inifile(args[0], "sc.ini");
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
306 }
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
307 else version (Posix) ///linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
308 {
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
309 inifile(args[0], "dmd.conf");
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
310 }
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
311 else
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
312 {
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
313 static assert (false, "fix this");
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 args = getenv_setargv("DFLAGS", args);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 version (disabled) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 for (i = 0; i < argc; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 writef("argv[%d] = '%s'\n", i, argv[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 foreach(i; 1..args.length)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 auto arg = args[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327 auto p = arg.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 if (*p == '-')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 arg = arg[1..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 if (arg == "d")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 global.params.useDeprecated = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 else if (arg == "c")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 global.params.link = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 else if (arg == "cov")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 global.params.cov = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 ///version (XXX) {// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 /// else if (arg == "fPIC")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 /// global.params.pic = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 ///}
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
341 else if (arg == "map")
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
342 global.params.map = 1;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 else if (arg == "multiobj")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 global.params.multiobj = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 else if (arg == "g")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 global.params.symdebug = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 else if (arg == "gc")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 global.params.symdebug = 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 else if (arg == "gt")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 { error("use -profile instead of -gt\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 global.params.trace = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 else if (arg == "m64")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 global.params.isX86_64 = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 else if (arg == "profile")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 global.params.trace = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 else if (arg == "v")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 global.params.verbose = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 ///version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 else if (arg == "vtls")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 global.params.vtls = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 else if (arg == "v1")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 version (DMDV1) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 global.params.Dversion = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 error("use DMD 1.0 series compilers for -v1 switch");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 else if (arg == "w")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 global.params.warnings = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 else if (arg == "O")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 global.params.optimize = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 else if (p[1] == 'o')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 switch (p[2])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 case '-':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 global.params.obj = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 case 'd':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 if (!p[3])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 global.params.objdir = arg[(p - arg.ptr) + 3..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 case 'f':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 if (!p[3])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 global.params.objname = arg[(p - arg.ptr) + 3..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 case 'p':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 if (p[3])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 global.params.preservePaths = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 case 0:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 error("-o no longer supported, use -of or -od");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 else if (p[1] == 'D')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 { global.params.doDocComments = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 switch (p[2])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 case 'd':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 if (!p[3])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 global.params.docdir = arg[(p - arg.ptr) + 3..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 case 'f':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 if (!p[3])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 global.params.docname = arg[(p - arg.ptr) + 3..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 case 0:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 ///version (_DH) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 else if (p[1] == 'H')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 { global.params.doHdrGeneration = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 switch (p[2])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 case 'd':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 if (!p[3])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 global.params.hdrdir = arg[(p - arg.ptr) + 3..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 case 'f':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 if (!p[3])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 global.params.hdrname = arg[(p - arg.ptr) + 3..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 case 0:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 ///}
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
460 else if (p[1] == 'X')
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
461 {
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
462 global.params.doXGeneration = 1;
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
463 switch (p[2])
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
464 {
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
465 case 'f':
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
466 if (!p[3])
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
467 goto Lnoarg;
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
468 global.params.xfilename = arg[(p - arg.ptr) + 3..$];
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
469 break;
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
470
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
471 case 0:
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
472 break;
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
473
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
474 default:
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
475 goto Lerror;
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
476 }
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
477 }
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
478
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 else if (arg == "ignore")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 global.params.ignoreUnsupportedPragmas = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 else if (arg == "inline")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 global.params.useInline = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 else if (arg == "lib")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 global.params.lib = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 else if (arg == "nofloat")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 global.params.nofloat = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 else if (arg == "quiet")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 global.params.quiet = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 else if (arg == "release")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 global.params.release = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 ///version (DMDV2) {
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
492 else if (arg == "noboundscheck")
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
493 noboundscheck = 1;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 else if (arg == "unittest")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 global.params.useUnitTests = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 else if (p[1] == 'I')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 global.params.imppath.push(cast(void*)new String(arg[(p - arg.ptr) + 2..$])); ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 else if (p[1] == 'J')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 if (!global.params.fileImppath)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 global.params.fileImppath = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 global.params.fileImppath.push(cast(void*)new String(arg[(p - arg.ptr) + 2..$]));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 else if (memcmp(p + 1, "debug".ptr, 5) == 0 && p[6] != 'l')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 // Parse:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 // -debug
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 // -debug=number
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 // -debug=identifier
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 if (p[6] == '=')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 if (isdigit(p[7]))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 { long level;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 errno = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 level = strtol(p + 7, cast(char**)&p, 10);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 if (*p || errno || level > INT_MAX)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 DebugCondition.setGlobalLevel(cast(int)level);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 else if (Lexer.isValidIdentifier(arg[(p - arg.ptr) + 7..$])) ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 DebugCondition.addGlobalIdent(p + 7);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 else if (p[6])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 global.params.debuglevel = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 else if (memcmp(p + 1, "version".ptr, 5) == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 // Parse:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 // -version=number
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 // -version=identifier
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539 if (p[8] == '=')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541 if (isdigit(p[9]))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 { long level;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 errno = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 level = strtol(p + 9, cast(char**)&p, 10); ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 if (*p || errno || level > INT_MAX)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 VersionCondition.setGlobalLevel(cast(int)level);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 else if (Lexer.isValidIdentifier(arg[(p - arg.ptr) + 9..$])) ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 VersionCondition.addGlobalIdent(arg[(p - arg.ptr) + 9..$]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 goto Lerror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 else if (arg == "-b")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559 global.params.debugb = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560 else if (arg == "-c")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 global.params.debugc = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 else if (arg == "-f")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 global.params.debugf = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564 else if (arg == "-help")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565 { usage();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 exit(EXIT_SUCCESS);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568 else if (arg == "-r")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569 global.params.debugr = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 else if (arg == "-x")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 global.params.debugx = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 else if (arg == "-y")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 global.params.debugy = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 else if (p[1] == 'L')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 global.params.linkswitches.push(cast(void*)p + 2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 else if (memcmp(p + 1, "defaultlib=".ptr, 11) == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 global.params.defaultlibname = p + 1 + 11;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 else if (memcmp(p + 1, "debuglib=".ptr, 9) == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 setdebuglib = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 global.params.debuglibname = p + 1 + 9;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587 else if (memcmp(p + 1, "deps=".ptr, 5) == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
589 global.params.moduleDepsFile = arg[(p - arg.ptr) + 1 + 5..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
590 if (!global.params.moduleDepsFile[0])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
591 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
592 global.params.moduleDeps = new OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
593 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 else if (memcmp(p + 1, "man".ptr, 3) == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 {
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
596 version (Windows) {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597 version (DMDV1) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598 browse("http://www.digitalmars.com/d/1.0/dmd-windows.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600 browse("http://www.digitalmars.com/d/2.0/dmd-windows.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
602 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603 version (linux) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604 version (DMDV1) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605 browse("http://www.digitalmars.com/d/1.0/dmd-linux.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
607 browse("http://www.digitalmars.com/d/2.0/dmd-linux.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
609 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610 version (__APPLE__) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611 version (DMDV1) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612 browse("http://www.digitalmars.com/d/1.0/dmd-osx.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 browse("http://www.digitalmars.com/d/2.0/dmd-osx.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
617 version (__FreeBSD__) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618 version (DMDV1) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 browse("http://www.digitalmars.com/d/1.0/dmd-freebsd.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 browse("http://www.digitalmars.com/d/2.0/dmd-freebsd.html");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
624 exit(EXIT_SUCCESS);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 else if (arg == "run")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 { global.params.run = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628 global.params.runargs_length = ((i >= argcstart) ? args.length : argcstart) - i - 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 if (global.params.runargs_length)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631 files.push(cast(void*)args[i + 1].ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
632 global.params.runargs = args[i + 2..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 i += global.params.runargs_length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634 global.params.runargs_length--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637 { global.params.run = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 goto Lnoarg;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 Lerror:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 error("unrecognized switch '%s'", args[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 Lnoarg:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 error("argument expected for switch '%s'", args[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 string ext = FileName.ext(p[0..arg.length]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 if (ext != null && FileName.compare(ext, "exe") == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 global.params.objname = arg[(p - arg.ptr)..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 files.push(cast(void*)new String(arg[(p - arg.ptr)..$]));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669 if (files.dim == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 { usage();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 return EXIT_FAILURE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 if (!setdebuglib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 global.params.debuglibname = global.params.defaultlibname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 global.params.pic = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 if (global.params.release)
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
682 {
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
683 global.params.useInvariants = 0;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684 global.params.useIn = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685 global.params.useOut = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 global.params.useAssert = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 global.params.useArrayBounds = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 global.params.useSwitchError = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 }
130
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
690
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
691 if (noboundscheck)
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
692 global.params.useArrayBounds = 0;
60bb0fe4563e dmdfe 2.037 first main iteration
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 114
diff changeset
693
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 if (global.params.run)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 global.params.quiet = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 if (global.params.useUnitTests)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 global.params.useAssert = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700 if (!global.params.obj || global.params.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701 global.params.link = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 if (global.params.link)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 global.params.exefile = global.params.objname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 global.params.oneobj = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 if (global.params.objname)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 /* Use this to name the one object file with the same
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 * name as the exe file.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 global.params.objname = FileName.forceExt(global.params.objname, global.obj_ext).toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 /* If output directory is given, use that path rather than
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 * the exe file path.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717 if (global.params.objdir)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 string name = FileName.name(global.params.objname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 global.params.objname = FileName.combine(global.params.objdir, name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 else if (global.params.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 global.params.libname = global.params.objname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 global.params.objname = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 // Haven't investigated handling these options with multiobj
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730 if (!global.params.cov && !global.params.trace)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 global.params.multiobj = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733 else if (global.params.run)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 error("flags conflict with -run");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 if (global.params.objname && files.dim > 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742 global.params.oneobj = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 //error("multiple source files, but only one .obj name");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744 //fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747 if (global.params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86_64");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 VersionCondition.addPredefinedGlobalIdent("X86_64");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 VersionCondition.addPredefinedGlobalIdent("D_LP64");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 VersionCondition.addPredefinedGlobalIdent("Win64");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 VersionCondition.addPredefinedGlobalIdent("D_InlineAsm_X86");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 VersionCondition.addPredefinedGlobalIdent("X86");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 VersionCondition.addPredefinedGlobalIdent("Win32");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 if (global.params.doDocComments)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 VersionCondition.addPredefinedGlobalIdent("D_Ddoc");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 if (global.params.cov)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 VersionCondition.addPredefinedGlobalIdent("D_Coverage");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 if (global.params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 VersionCondition.addPredefinedGlobalIdent("D_PIC");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771 version (DMDV2) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772 if (global.params.useUnitTests)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 VersionCondition.addPredefinedGlobalIdent("unittest");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 // Initialization
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 Type.init();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778 Id.initialize();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779 initPrecedence();
170
96c0fff6897d more global state cleanup
korDen
parents: 169
diff changeset
780 global.initClasssym();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 backend_init();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 //printf("%d source files\n",files.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 // Build import search path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787 if (global.params.imppath)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
788 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 for (int i = 0; i < global.params.imppath.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 string path = (cast(String)global.params.imppath.data[i]).str;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 string[] a = FileName.splitPath(path);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 global.path ~= a;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798 // Build string import search path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 if (global.params.fileImppath)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 for (int i = 0; i < global.params.fileImppath.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 string path = (cast(String)global.params.fileImppath.data[i]).str;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804 string[] a = FileName.splitPath(path);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 global.filePath ~= a;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
807 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810 // Create Modules
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
811 Array modules = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
812 modules.reserve(files.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
813 int firstmodule = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
814 for (int i = 0; i < files.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
815 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
816 string ext;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
817 string name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
818
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
819 String s = cast(String) files.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
820 string mp = s.str;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
821
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 99
diff changeset
822 version (Windows) {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
823 char[] copy = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
824 // Convert / to \ so linker will work
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
825 foreach (j, c; mp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
826 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
827 if (c == '/') {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
828 if (copy is null) copy = mp.dup;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
829 copy[j] = '\\';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
830 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
831 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
832
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
833 if (copy !is null) mp = assumeUnique(copy);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
834 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
835 string p = mp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
836
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
837 p = FileName.name(p); // strip path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
838 ext = FileName.ext(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
839
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
840 if (ext.length != 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
841 { /* Deduce what to do with a file based on its extension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
842 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
843 if (FileName.equals(ext, global.obj_ext))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
844 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
845 global.params.objfiles.push(files.data[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
846 libmodules.push(files.data[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
847 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
848 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
849
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
850 if (FileName.equals(ext, global.lib_ext))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
851 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
852 global.params.libfiles.push(files.data[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
853 libmodules.push(files.data[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
854 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
855 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
856
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
857 if (ext == global.ddoc_ext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
858 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
859 global.params.ddocfiles.push(files.data[i]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
860 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
861 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
862
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
863 if (FileName.equals(ext, global.json_ext))
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
864 {
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
865 global.params.doXGeneration = 1;
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
866 global.params.xfilename = (cast(String)files.data[i]).str;
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
867 continue;
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
868 }
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
869
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
870 if (FileName.equals(ext, global.map_ext))
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
871 {
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
872 global.params.mapfile = (cast(String)files.data[i]).str;
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
873 continue;
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
874 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
875
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
876 version (TARGET_WINDOS)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
877 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
878 if (FileName.equals(ext, "res"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
879 {
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
880 global.params.resfile = (cast(String)files.data[i]).str;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
881 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
882 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
883
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
884 if (FileName.equals(ext, "def"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
885 {
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
886 global.params.deffile = (cast(String)files.data[i]).str;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
887 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
888 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
889
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
890 if (FileName.equals(ext, "exe"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
891 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
892 assert(0); // should have already been handled
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
893 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
894 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
895
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
896 /* Examine extension to see if it is a valid
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
897 * D source file extension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
898 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
899 if (FileName.equals(ext, global.mars_ext) ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
900 FileName.equals(ext, global.hdr_ext) ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
901 FileName.equals(ext, "dd") ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
902 FileName.equals(ext, "htm") ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
903 FileName.equals(ext, "html") ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
904 FileName.equals(ext, "xhtml"))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
905 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
906 immutable(char)* e = ext.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
907 e--; // skip onto '.'
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
908 assert(*e == '.');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
909
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
910 immutable(char)* n = p.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
911
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
912 name = n[0..(e-n)]; // strip extension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
913
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
914 if (name.length == 0 || name == ".." || name == ".")
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
915 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
916 Linvalid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
917 error("invalid file name '%s'", (cast(String)files.data[i]).str);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
918 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
919 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
920 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
921 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
922 { error("unrecognized file extension %s\n", ext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
923 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
924 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
925 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
926 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
927 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
928 name = p;
191
52188e7e3fb5 Fixed deprecated features, now compiles with DMD2.058
korDen@korDen-pc
parents: 183
diff changeset
929 if (!*name.ptr)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
930 goto Linvalid;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
931 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
932
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
933 /* At this point, name is the D source file name stripped of
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
934 * its path and extension.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
935 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
936
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
937 Identifier id = new Identifier(name, TOK.TOKreserved);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
938 m = new Module((cast(String) files.data[i]).str, id, global.params.doDocComments, global.params.doHdrGeneration);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
939 modules.push(cast(void*)m);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
940
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
941 if (firstmodule)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
942 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
943 global.params.objfiles.push(cast(void*)m.objfile.name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
944 firstmodule = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
945 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
946 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
947
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
948 // Read files
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
949 //version = ASYNCREAD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
950 version (ASYNCREAD) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
951 // Multi threaded
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
952 AsyncRead *aw = AsyncRead.create(modules.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
953 for (i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
954 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
955 m = cast(Module *)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
956 aw.addFile(m.srcfile);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
957 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
958 aw.start();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
959 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
960 // Single threaded
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
961 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
962 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
963 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
964 m.read(Loc(0));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
965 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
966 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
967
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
968 // Parse files
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
969 int anydocfiles = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
970 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
971 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
972 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
973 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
974 writef("parse %s\n", m.toChars());
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 165
diff changeset
975 if (!global.rootModule)
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 165
diff changeset
976 global.rootModule = m;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
977 m.importedFrom = m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
978 if (!global.params.oneobj || i == 0 || m.isDocFile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
979 m.deleteObjFile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
980 version (ASYNCREAD) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
981 if (aw.read(i))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
982 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
983 error("cannot read file %s", m.srcfile.name.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
984 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
985 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
986
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
987 m.parse();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
988 if (m.isDocFile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
989 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
990 anydocfiles = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
991 m.gendocfile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
992
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
993 // Remove m from list of modules
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
994 modules.remove(i);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
995 i--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
996
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
997 // Remove m's object file from list of object files
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
998 for (int j = 0; j < global.params.objfiles.dim; j++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
999 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1000 if (m.objfile.name.str == (cast(FileName)global.params.objfiles.data[j]).str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1001 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1002 global.params.objfiles.remove(j);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1003 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1004 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1005 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1006
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1007 if (global.params.objfiles.dim == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1008 global.params.link = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1009 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1010 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1011 version (ASYNCREAD) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1012 AsyncRead.dispose(aw);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1013 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1014
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1015 if (anydocfiles && modules.dim &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1016 (global.params.oneobj || global.params.objname))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1017 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1018 error("conflicting Ddoc and obj generation options");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1019 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1020 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1021 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1022 fatal();
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1023 version (_DH)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1024 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1025 if (global.params.doHdrGeneration)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1026 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1027 /* Generate 'header' import files.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1028 * Since 'header' import files must be independent of command
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1029 * line switches and what else is imported, they are generated
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1030 * before any semantic analysis.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1031 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1032 for (i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1033 {
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1034 m = cast(Module)modules.data[i];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1035 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1036 writef("import %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1037 m.genhdrfile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1038 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1039 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1040 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1041 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1042 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1043 //load all unconditional imports for better symbol resolving
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1044 for (int i = 0; i < modules.dim; i++)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1045 {
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1046 m = cast(Module)modules.data[i];
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1047 if (global.params.verbose)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1048 writef("importall %s\n", m.toChars());
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1049 m.importAll(null);
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1050 }
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1051 if (global.errors)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1052 fatal();
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
1053
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1054 // Do semantic analysis
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1055 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1056 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1057 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1058 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1059 writef("semantic %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1060 m.semantic();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1061 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1062 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1063 fatal();
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
1064
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
1065 global.dprogress = 1;
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
1066 Module.runDeferredSemantic();
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
1067
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1068 // Do pass 2 semantic analysis
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1069 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1070 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1071 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1072 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1073 writef("semantic2 %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1074 m.semantic2();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1075 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1076 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1077 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1078
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1079 // Do pass 3 semantic analysis
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1080 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1081 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1082 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1083 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1084 writef("semantic3 %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1085 m.semantic3();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1086 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1087 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1088 fatal();
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
1089
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1090 if (global.params.moduleDeps !is null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1091 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1092 assert(global.params.moduleDepsFile !is null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1093
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1094 File deps = new File(global.params.moduleDepsFile);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1095 OutBuffer ob = global.params.moduleDeps;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1096 deps.setbuffer(cast(void*)ob.data, ob.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1097 deps.writev();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1098 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1099
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1100
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1101 // Scan for functions to inline
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1102 if (global.params.useInline)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1103 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1104 /* The problem with useArrayBounds and useAssert is that the
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1105 * module being linked to may not have generated them, so if
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1106 * we inline functions from those modules, the symbols for them will
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1107 * not be found at link time.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1108 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1109 if (!global.params.useArrayBounds && !global.params.useAssert)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1110 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1111 // Do pass 3 semantic analysis on all imported modules,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1112 // since otherwise functions in them cannot be inlined
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 165
diff changeset
1113 for (int i = 0; i < global.amodules.dim; i++)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1114 {
169
e7769d53e750 Moves static variables from Module to Global
korDen
parents: 165
diff changeset
1115 m = cast(Module)global.amodules.data[i];
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1116 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1117 writef("semantic3 %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1118 m.semantic3();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1119 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1120 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1121 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1122 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1123
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1124 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1125 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1126 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1127 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1128 writef("inline scan %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1130 m.inlineScan();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1131 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1132 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1133 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1134 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1135
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1136 Library library = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1137 if (global.params.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1138 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1139 library = new Library();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1140 library.setFilename(global.params.objdir, global.params.libname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1141
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1142 // Add input object and input library files to output library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1143 for (int i = 0; i < libmodules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1144 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1145 string p = (cast(String)libmodules.data[i]).str;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1146 library.addObject(p, null, 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1147 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1148 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1149
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1150 // Generate output files
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1151 if (global.params.doXGeneration)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1152 json_generate(modules);
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
1153
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1154 if (global.params.oneobj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1155 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1156 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1157 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1158 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1159 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1160 writef("code %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1161 if (i == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1162 obj_start(cast(char*)toStringz(m.srcfile.toChars()));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1163 m.genobjfile(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1164 if (!global.errors && global.params.doDocComments)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1165 m.gendocfile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1166 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1167 if (!global.errors && modules.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1168 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1169 obj_end(library, (cast(Module)modules.data[0]).objfile);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1170 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1171 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1172 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1173 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1174 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1175 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1176 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1177 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1178 writef("code %s\n", m.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1179 if (global.params.obj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1180 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1181 obj_start(cast(char*)toStringz(m.srcfile.toChars()));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1182 m.genobjfile(global.params.multiobj);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1183 obj_end(library, m.objfile);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1184 obj_write_deferred(library);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1185 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1186 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1187 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1188 if (!global.params.lib)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1189 m.deleteObjFile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1190 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1191 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1192 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1193 if (global.params.doDocComments)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1194 m.gendocfile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1195 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1196 }
164
8bf07a566fdf GC is working now
korDen
parents: 130
diff changeset
1197 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1198
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1199 if (global.params.lib && !global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1200 library.write();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1201
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1202 backend_term();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1203 if (global.errors)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1204 fatal();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1205
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1206 if (!global.params.objfiles.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1208 if (global.params.link)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1209 error("no object files to link");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1210 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1211 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1212 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1213 if (global.params.link)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1214 status = runLINK();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1215
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1216 if (global.params.run)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1217 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1218 if (!status)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1219 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1220 status = runProgram();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1221
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1222 /* Delete .obj files and .exe file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1223 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1224 for (int i = 0; i < modules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1225 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1226 m = cast(Module)modules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1227 m.deleteObjFile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1228 if (global.params.oneobj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1229 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1230 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1231 deleteExeFile();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1232 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1233 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1234 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1235
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1236 return status;
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1237 }