annotate dmd/backend/glue.d @ 183:190ba98276b3

Several changes to make it build on posix systems. I've only tried to build on Mac OS X but it should build on Linux now as well. This should also fix ticket #9.
author Jacob Carlborg <doob@me.com>
date Mon, 25 Oct 2010 15:36:13 +0200
parents cd48cb899aee
children 9f4e5ac4f0a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.backend.glue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 79
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.File;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.FileName;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Library;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Module;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.AssertExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Param;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.backend.Config;
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
17 import dmd.backend.elem;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.backend.Configv;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.backend.StringTab;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import core.stdc.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
23 version (Windows)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
24 {
25
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
25 extern (C++) extern
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
26 {
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
27 int go_flag(char* cp);
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
28 void util_set64();
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
29 void util_set386();
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
30 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
31 }
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
32 else version (linux)
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
33 {
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
34 extern (C++)
25
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
35 {
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
36 int go_flag(char* cp);
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
37 void util_set64();
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
38 void util_set386();
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
39 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 }
183
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
41 else version (OSX)
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
42 {
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
43 extern (C++)
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
44 {
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
45 int go_flag(char* cp);
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
46 void util_set64();
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
47 void util_set386();
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
48 }
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
49 }
79
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
50 else
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
51 {
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
52 static assert(false, "fix this");
43073c7c7769 updated to 2.035
Trass3r
parents: 74
diff changeset
53 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
183
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
55 version (CPP_MANGLE)
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
56 extern (C++) char* cpp_mangle(Dsymbol s);
190ba98276b3 Several changes to make it build on posix systems.
Jacob Carlborg <doob@me.com>
parents: 179
diff changeset
57
34
544b922227c7 update to work with dmd 2.048
korDen
parents: 25
diff changeset
58 import std.exception;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 import std.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 struct Outbuffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 ubyte* buf; // the buffer itself
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 ubyte* pend; // pointer past the end of the buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 ubyte* p; // current position in buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 uint len; // size of buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 uint inc; // default increment size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 this(uint inc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 }
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
73
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 ~this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 }
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
77
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 void reset()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 // Reserve nbytes in buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 void reserve(uint nbytes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 // Write n zeros; return pointer to start of zeros
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 void* writezeros(uint n)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 // Position buffer to accept the specified number of bytes at offset
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 int position(uint offset, uint nbytes);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 // Write an array to the buffer, no reserve check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 void writen(const(void)* b, int len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 memcpy(p,b,len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 p += len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 // Clear bytes, no reserve check
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 void clearn(int len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 int i;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 for (i=0; i< len; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 *p++ = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 // Write an array to the buffer.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 void write(const void *b, int len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 void write(Outbuffer* b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 write(b.buf, b.p - b.buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 * Flushes the stream. This will write any buffered
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 * output bytes.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 void flush() { }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 * Writes an 8 bit byte, no reserve check.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 void writeByten(char v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 *p++ = v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 * Writes an 8 bit byte.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 void writeByte(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 * Writes a 16 bit little-end short, no reserve check.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 void writeWordn(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 *cast(ushort*)p = cast(short)v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 } else {
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: 0
diff changeset
154 assert(0, "Check this");
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: 0
diff changeset
155 p[0] = cast(ubyte)v;
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: 0
diff changeset
156 p[1] = cast(ubyte)(v >> 8);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 p += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 * Writes a 16 bit little-end short.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 void writeWord(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 reserve(2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 writeWordn(v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 * Writes a 16 bit big-end short.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 void writeShort(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 if (pend - p < 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 reserve(2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 p[0] = (cast(ubyte*)&v)[1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 p[1] = v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 ubyte* q = p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 q[0] = cast(ubyte)(v >> 8);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 q[1] = cast(ubyte)v;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 p += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 * Writes a 16 bit char.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 void writeChar(int v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 writeShort(v);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 * Writes a 32 bit int.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 void write32(long v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 * Writes a 64 bit long.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 ///#if __INTSIZE == 4
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 void write64(long v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 ///#endif
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 * Writes a 32 bit float.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 void writeFloat(float v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 * Writes a 64 bit double.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 void writeDouble(double v)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 void write(const(char)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 void write(const(ubyte)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 void writeString(const(char)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 void prependBytes(const(char)* s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 void bracket(char c1, char c2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 /**
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 * Returns the number of bytes written.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 int size()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 return p - buf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 char* toString()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 }
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
268
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 void setsize(uint size)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 void writesLEB128(long value)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 }
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
278
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 void writeuLEB128(uint value)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 /**************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 * Append s to list of object files to generate later.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 */
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
288
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 void obj_append(Dsymbol s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 {
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
291 global.obj_symbols_towrite.push(cast(void*)s);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293
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: 0
diff changeset
294 version (Bug4059)
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: 0
diff changeset
295 {
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: 0
diff changeset
296 private extern (C) void _Z8obj_initP9OutbufferPKcS2_(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);
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: 0
diff changeset
297 void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname) { return _Z8obj_initP9OutbufferPKcS2_(objbuf, filename, csegname); }
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: 0
diff changeset
298 }
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: 0
diff changeset
299 else
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: 0
diff changeset
300 {
25
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
301 extern (C++) {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
302 void obj_init(Outbuffer* objbuf, const(char)* filename, const(char)* csegname);
25
3f834bed4f13 FWindows linking issues fixed
korDen
parents: 16
diff changeset
303 }
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: 0
diff changeset
304 }
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: 0
diff changeset
305
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 extern (C++) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 void backend_init();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 void backend_term();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 void obj_term();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 void rtlsym_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 void slist_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 void el_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 void cg87_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 void out_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 void clearStringTab()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 //printf("clearStringTab()\n");
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
320 memset(global.stringTab.ptr, 0, global.stringTab.sizeof);
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
321 global.stidx = 0;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322
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: 140
diff changeset
323 // assertexp_sfilename = null;
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: 140
diff changeset
324 // assertexp_name = null;
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: 140
diff changeset
325 // assertexp_mn = null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 void obj_start(char *srcfile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 //printf("obj_start()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 out_config_init();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 rtlsym_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 slist_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 clearStringTab();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
338 obj_init(&global.objbuf, srcfile, null);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 el_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 cg87_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 out_reset();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 void obj_end(Library library, File objfile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 obj_term();
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
348
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
349 auto objbuf = &global.objbuf;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 if (library)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 // Transfer image to library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 library.addObject(objfile.name.toChars(), objbuf.buf, objbuf.p - objbuf.buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 objbuf.buf = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 // Transfer image to file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 objfile.setbuffer(objbuf.buf, objbuf.p - objbuf.buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 objbuf.buf = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 string p = FileName.path(objfile.name.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 FileName.ensurePathExists(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 //mem.free(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 //printf("write obj %s\n", objfile.name.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 objfile.writev();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 objbuf.pend = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 objbuf.p = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 objbuf.len = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 objbuf.inc = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 void obj_write_deferred(Library library)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 {
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
379 auto obj_symbols_towrite = global.obj_symbols_towrite;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 for (int i = 0; i < obj_symbols_towrite.dim; i++)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
381 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 Dsymbol s = cast(Dsymbol)obj_symbols_towrite.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 Module m = s.getModule();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 string mname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 if (m)
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
387 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 mname = m.srcfile.toChars();
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
389 global.lastmname = mname;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 //mname = s->ident->toChars();
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
394 mname = global.lastmname;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 assert(mname.length != 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 obj_start(cast(char*)toStringz(mname));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399
176
fa9a71a9f5a8 Moved all the mutable globals to Global
korDen
parents: 175
diff changeset
400 int count = ++global.count; // sequence for generating names
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 /* Create a module that's a doppelganger of m, with just
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 * enough to be able to create the moduleinfo.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 */
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 34
diff changeset
405 auto idbuf = new OutBuffer();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 idbuf.printf("%s.%d", m ? m.ident.toChars() : mname, count);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 string idstr = idbuf.extractString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 idbuf.data = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 Identifier id = new Identifier(idstr, TOK.TOKidentifier);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410
74
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 34
diff changeset
411 auto md = new Module(mname, id, 0, 0);
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 34
diff changeset
412 md.members = new Dsymbols();
7e0d548de9e6 Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents: 34
diff changeset
413 md.members.push(s); // its only 'member' is s
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 if (m)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 md.doppelganger = 1; // identify this module as doppelganger
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 md.md = m.md;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 md.aimports.push(cast(void*)m); // it only 'imports' m
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 md.massert = m.massert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 md.marray = m.marray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 md.genobjfile(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 /* Set object file name to be source name with sequence number,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 * as mangled symbol names get way too long.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 string fname = FileName.removeExt(mname);
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
429
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 OutBuffer namebuf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 uint hash = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 foreach (char c; s.toChars())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 hash += c;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 namebuf.printf("%s_%x_%x.%s", fname, count, hash, global.obj_ext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 fname = namebuf.extractString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 //printf("writing '%s'\n", fname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 File objfile = new File(fname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 obj_end(library, objfile);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 obj_symbols_towrite.dim = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 /**************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 * Initialize config variables.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 void out_config_init()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 Param* params = &global.params;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 if (!config.target_cpu)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 config.target_cpu = TARGET_PentiumPro;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 config.target_scheduler = config.target_cpu;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 config.fulltypes = CVNONE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 config.inline8087 = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 config.memmodel = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 config.flags |= CFGuchar; // make sure TYchar is unsigned
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 version (TARGET_WINDOS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 config.exe = EX_WIN64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 config.exe = EX_NT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 // Win32 eh
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 config.flags2 |= CFG2seh;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 if (params.run)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 config.wflags |= WFexe; // EXE file only optimizations
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 else if (params.link && !global.params.deffile)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 config.wflags |= WFexe; // EXE file only optimizations
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 else if (params.exefile) // if writing out EXE file
178
e3afd1303184 Many small bugs fixed
korDen
parents: 177
diff changeset
477 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 size_t len = params.exefile.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 if (len >= 4 && icmp(params.exefile[len-3..len], "exe") == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 config.wflags |= WFexe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 config.flags4 |= CFG4underscore;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 version (TARGET_LINUX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 config.exe = EX_LINUX64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 config.exe = EX_LINUX;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 config.exe = EX_OSX64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 config.exe = EX_OSX;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 version (TARGET_FREEBSD) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 config.exe = EX_FREEBSD64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 config.exe = EX_FREEBSD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 version (TARGET_SOLARIS) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 config.exe = EX_SOLARIS64;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 config.exe = EX_SOLARIS;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 config.flags |= CFGnoebp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 if (params.pic)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 config.flags3 |= CFG3pic;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 config.flags2 |= CFG2nodeflib; // no default library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 config.flags3 |= CFG3eseqds;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 if (env.getEEcontext().EEcompile != 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 config.flags4 |= CFG4allcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 if (env.nochecks())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 config.flags4 |= CFG4nochecks; // no runtime checking
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 } else version (TARGET_OSX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 config.flags4 |= CFG4allcomdat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 if (params.trace)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 config.flags |= CFGtrace; // turn on profiler
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 if (params.nofloat)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 config.flags3 |= CFG3wkfloat;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 configv.verbose = params.verbose;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 if (params.optimize)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 go_flag(cast(char*)"-o".ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 if (params.symdebug)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 version (ELFOBJ_OR_MACHOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 configv.addlinenumbers = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 config.fulltypes = (params.symdebug == 1) ? CVDWARF_D : CVDWARF_C;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 version (OMFOBJ) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 configv.addlinenumbers = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 config.fulltypes = CV4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 if (!params.optimize)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 config.flags |= CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560 configv.addlinenumbers = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 config.fulltypes = CVNONE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 //config.flags &= ~CFGalwaysframe;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565 if (params.isX86_64)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 util_set64();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568 cod3_set64();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572 util_set386();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 cod3_set386();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 debug {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 debugb = params.debugb;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 debugc = params.debugc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579 debugf = params.debugf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 debugr = params.debugr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581 debugw = params.debugw;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 debugx = params.debugx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 debugy = params.debugy;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 }
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: 0
diff changeset
585 }