Mercurial > projects > ddmd
annotate dmd/Module.d @ 192:eb38fdcb3e62 default tip
updated to compile with dmd2.062
author | korDen |
---|---|
date | Sat, 02 Mar 2013 01:25:52 -0800 |
parents | b0d41ff5e0df |
children |
rev | line source |
---|---|
0 | 1 module dmd.Module; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.Package; |
5 import dmd.DsymbolTable; | |
6 import dmd.backend.TYM; | |
7 import dmd.Array; | |
8 import dmd.StaticDtorDeclaration; | |
9 import dmd.Scope; | |
10 import dmd.Id; | |
179 | 11 import dmd.SharedStaticCtorDeclaration; |
12 import dmd.SharedStaticDtorDeclaration; | |
0 | 13 import dmd.Import; |
14 import dmd.ClassDeclaration; | |
15 import dmd.ModuleDeclaration; | |
16 import dmd.File; | |
17 import dmd.Identifier; | |
79 | 18 import dmd.Json; |
0 | 19 import dmd.Dsymbol; |
20 import dmd.ModuleInfoDeclaration; | |
21 import dmd.FuncDeclaration; | |
22 import dmd.Loc; | |
23 import dmd.Macro; | |
24 import dmd.Escape; | |
25 import dmd.OutBuffer; | |
26 import dmd.HdrGenState; | |
27 import dmd.ArrayTypes; | |
28 import dmd.FileName; | |
29 import dmd.Global; | |
30 import dmd.Parser; | |
31 import dmd.Lexer; | |
32 import dmd.Util; | |
33 import dmd.String; | |
34 import dmd.ScopeDsymbol; | |
35 import dmd.Type; | |
36 import dmd.backend.TYPE; | |
37 import dmd.backend.Cstate; | |
38 import dmd.backend.OPER; | |
39 import dmd.backend.REG; | |
40 import dmd.backend.Symbol; | |
41 import dmd.backend.elem; | |
42 import dmd.backend.mTYman; | |
43 import dmd.backend.Util; | |
44 import dmd.backend.SC; | |
45 import dmd.backend.FL; | |
46 import dmd.backend.SFL; | |
47 import dmd.backend.TF; | |
48 import dmd.backend.RTLSYM; | |
49 import dmd.backend.BC; | |
50 import dmd.backend.block; | |
51 import dmd.backend.targ_types; | |
52 import dmd.backend.dt_t; | |
53 import dmd.backend.TYM; | |
54 import dmd.backend.Util; | |
55 import dmd.backend.Classsym; | |
56 import dmd.backend.glue; | |
57 import dmd.backend.LIST; | |
58 import dmd.codegen.Util; | |
59 | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
60 import dmd.DDMDExtensions; |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
61 |
0 | 62 import core.stdc.string; |
63 import core.stdc.stdlib; | |
64 | |
4 | 65 import core.memory; |
2 | 66 |
0 | 67 uint readwordLE(ushort* p) |
68 { | |
69 version (__I86__) { | |
70 return *p; | |
71 } else { | |
72 return ((cast(ubyte*)p)[1] << 8) | (cast(ubyte*)p)[0]; | |
73 } | |
74 } | |
75 | |
76 uint readwordBE(ushort* p) | |
77 { | |
78 return ((cast(ubyte*)p)[0] << 8) | (cast(ubyte*)p)[1]; | |
79 } | |
80 | |
81 uint readlongLE(uint* p) | |
82 { | |
83 version (__I86__) { | |
84 return *p; | |
85 } else { | |
86 return (cast(ubyte*)p)[0] | | |
87 ((cast(ubyte*)p)[1] << 8) | | |
88 ((cast(ubyte*)p)[2] << 16) | | |
89 ((cast(ubyte*)p)[3] << 24); | |
90 } | |
91 } | |
92 | |
93 uint readlongBE(uint* p) | |
94 { | |
95 return (cast(ubyte*)p)[3] | | |
96 ((cast(ubyte*)p)[2] << 8) | | |
97 ((cast(ubyte*)p)[1] << 16) | | |
98 ((cast(ubyte*)p)[0] << 24); | |
99 } | |
100 | |
101 /* Segments */ | |
102 enum Segment { | |
103 CODE = 1, /* code segment */ | |
104 DATA = 2, /* initialized data */ | |
105 CDATA = 3, /* constant data */ | |
106 UDATA = 4, /* uninitialized data */ | |
107 UNKNOWN = -1, /* unknown segment */ | |
108 } | |
109 | |
174 | 110 struct seg_data |
0 | 111 { |
112 int SDseg; // omf file segment index | |
113 targ_size_t SDoffset; // starting offset for data | |
114 | |
115 bool isfarseg; | |
116 int seg; // segment number | |
117 int lnameidx; // lname idx of segment name | |
118 int classidx; // lname idx of class name | |
119 uint attr; // segment attribute | |
120 targ_size_t origsize; // original size | |
121 int seek; // seek position in output file | |
122 } | |
123 | |
124 extern (C) extern __gshared seg_data** SegData; | |
125 | |
126 ref targ_size_t Offset(Segment seg) { | |
127 return SegData[seg].SDoffset; | |
128 } | |
129 | |
130 ref targ_size_t Doffset() { | |
131 return SegData[Segment.DATA].SDoffset; | |
132 } | |
133 | |
134 ref targ_size_t CDoffset() { | |
135 return SegData[Segment.CDATA].SDoffset; | |
136 } | |
137 | |
138 ref targ_size_t UDoffset() { | |
139 return SegData[Segment.UDATA].SDoffset; | |
140 } | |
141 | |
142 enum CF { | |
143 CFes = 1, // generate an ES: segment override for this instr | |
144 CFjmp16 = 2, // need 16 bit jump offset (long branch) | |
145 CFtarg = 4, // this code is the target of a jump | |
146 CFseg = 8, // get segment of immediate value | |
147 CFoff = 0x10, // get offset of immediate value | |
148 CFss = 0x20, // generate an SS: segment override (not with | |
149 // CFes at the same time, though!) | |
150 CFpsw = 0x40, // we need the flags result after this instruction | |
151 CFopsize = 0x80, // prefix with operand size | |
152 CFaddrsize = 0x100, // prefix with address size | |
174 | 153 CFds = 0x200, // need DS override (not with es, ss, or cs ) |
0 | 154 CFcs = 0x400, // need CS override |
155 CFfs = 0x800, // need FS override | |
156 CFgs = (CFcs | CFfs), // need GS override | |
157 CFwait = 0x1000, // If I32 it indicates when to output a WAIT | |
158 CFselfrel = 0x2000, // if self-relative | |
159 CFunambig = 0x4000, // indicates cannot be accessed by other addressing | |
160 // modes | |
161 CFtarg2 = 0x8000, // like CFtarg, but we can't optimize this away | |
162 CFvolatile = 0x10000, // volatile reference, do not schedule | |
163 CFclassinit = 0x20000, // class init code | |
164 | |
165 CFSEG = (CFes | CFss | CFds | CFcs | CFfs | CFgs), | |
166 CFPREFIX = (CFSEG | CFopsize | CFaddrsize), | |
167 } | |
168 | |
169 class Module : Package | |
170 { | |
187
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
171 mixin insertMemberExtension!(typeof(this)); |
b0d41ff5e0df
Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents:
179
diff
changeset
|
172 |
0 | 173 string arg; // original argument name |
174 ModuleDeclaration md; // if !null, the contents of the ModuleDeclaration declaration | |
175 File srcfile; // input source file | |
176 File objfile; // output .obj file | |
177 File hdrfile; // 'header' file | |
178 File symfile; // output symbol file | |
179 File docfile; // output documentation file | |
180 uint errors; // if any errors in file | |
181 uint numlines; // number of lines in source file | |
182 int isHtml; // if it is an HTML file | |
183 int isDocFile; // if it is a documentation input file, not D source | |
184 int needmoduleinfo; /// TODO: change to bool | |
185 version (IN_GCC) { | |
186 int strictlyneedmoduleinfo; | |
187 } | |
188 | |
189 int selfimports; // 0: don't know, 1: does not, 2: does | |
190 int selfImports() // returns !=0 if module imports itself | |
191 { | |
192 assert(false); | |
193 } | |
194 | |
195 int insearch; | |
196 Identifier searchCacheIdent; | |
197 Dsymbol searchCacheSymbol; // cached value of search | |
198 int searchCacheFlags; // cached flags | |
199 | |
200 int semanticstarted; // has semantic() been started? | |
201 int semanticRun; // has semantic() been done? | |
202 int root; // != 0 if this is a 'root' module, | |
203 // i.e. a module that will be taken all the | |
204 // way to an object file | |
205 Module importedFrom; // module from command line we're imported from, | |
206 // i.e. a module that will be taken all the | |
207 // way to an object file | |
208 | |
209 Array decldefs; // top level declarations for this Module | |
210 | |
211 Array aimports; // all imported modules | |
212 | |
213 ModuleInfoDeclaration vmoduleinfo; | |
214 | |
215 uint debuglevel; // debug level | |
129 | 216 Vector!string debugids; // debug identifiers |
217 Vector!string debugidsNot; // forward referenced debug identifiers | |
0 | 218 |
219 uint versionlevel; // version level | |
178 | 220 Vector!(string) versionids; // version identifiers |
221 Vector!(string) versionidsNot; // forward referenced version identifiers | |
0 | 222 |
223 Macro macrotable; // document comment macros | |
224 Escape escapetable; // document comment escapes | |
225 bool safe; // TRUE if module is marked as 'safe' | |
226 | |
227 this(string filename, Identifier ident, int doDocComment, int doHdrGen) | |
228 { | |
178 | 229 register(); |
230 | |
0 | 231 super(ident); |
178 | 232 |
233 versionids = new Vector!string; | |
234 versionidsNot = new Vector!string; | |
235 | |
0 | 236 FileName objfilename; |
174 | 237 |
0 | 238 aimports = new Array(); |
239 | |
174 | 240 //writefln("Module.Module(filename = '%s', ident = '%s')", filename, ident.toChars()); |
0 | 241 this.arg = filename; |
242 | |
243 FileName srcfilename = FileName.defaultExt(filename, global.mars_ext); | |
244 if (!srcfilename.equalsExt(global.mars_ext) && | |
245 !srcfilename.equalsExt(global.hdr_ext) && | |
246 !srcfilename.equalsExt("dd")) | |
247 { | |
248 if (srcfilename.equalsExt("html") || | |
249 srcfilename.equalsExt("htm") || | |
250 srcfilename.equalsExt("xhtml")) | |
251 { | |
252 if (!global.params.useDeprecated) | |
253 error("html source files is deprecated %s", srcfilename.toChars()); | |
254 isHtml = 1; | |
255 } | |
256 else | |
257 { | |
258 error("source file name '%s' must have .%s extension", srcfilename.toChars(), global.mars_ext); | |
259 fatal(); | |
260 } | |
261 } | |
262 | |
263 string argobj; | |
264 if (global.params.objname) | |
265 argobj = global.params.objname; | |
266 else if (global.params.preservePaths) | |
267 argobj = filename; | |
268 else | |
269 argobj = FileName.name(filename); | |
270 if (!FileName.absolute(argobj)) | |
271 { | |
272 argobj = FileName.combine(global.params.objdir, argobj); | |
273 } | |
274 | |
275 if (global.params.objname) | |
276 objfilename = new FileName(argobj); | |
277 else | |
278 objfilename = FileName.forceExt(argobj, global.obj_ext); | |
279 | |
280 FileName symfilename = FileName.forceExt(filename, global.sym_ext); | |
281 | |
174 | 282 //writeln(srcfilename.toChars()); |
0 | 283 srcfile = new File(srcfilename); |
284 | |
285 if (doDocComment) { | |
286 setDocfile(); | |
287 } | |
288 | |
289 if (doHdrGen) { | |
290 setHdrfile(); | |
291 } | |
292 | |
293 objfile = new File(objfilename); | |
294 symfile = new File(symfilename); | |
295 } | |
296 | |
129 | 297 static Module load(Loc loc, Vector!Identifier packages, Identifier ident) |
0 | 298 { |
299 Module m; | |
300 string filename; | |
301 | |
302 //writef("Module.load(ident = '%s')\n", ident.toChars()); | |
303 | |
304 // Build module filename by turning: | |
305 // foo.bar.baz | |
306 // into: | |
307 // foo\bar\baz | |
308 filename = ident.toChars(); | |
309 if (packages && packages.dim) | |
310 { | |
129 | 311 scope OutBuffer buf = new OutBuffer(); |
0 | 312 |
128
e6e542f37b94
Some more Array -> Vector conversions
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
126
diff
changeset
|
313 foreach (pid; packages) |
174 | 314 { |
0 | 315 buf.writestring(pid.toChars()); |
114 | 316 version (Windows) |
317 { | |
0 | 318 buf.writeByte('\\'); |
114 | 319 } |
320 else | |
321 { | |
0 | 322 buf.writeByte('/'); |
323 } | |
324 } | |
325 buf.writestring(filename); | |
326 filename = buf.extractString(); | |
327 } | |
328 | |
329 m = new Module(filename, ident, 0, 0); | |
330 m.loc = loc; | |
331 | |
332 /* Search along global.path for .di file, then .d file. | |
333 */ | |
334 string result = null; | |
335 FileName fdi = FileName.forceExt(filename, global.hdr_ext); | |
336 FileName fd = FileName.forceExt(filename, global.mars_ext); | |
337 string sdi = fdi.toChars(); | |
338 string sd = fd.toChars(); | |
174 | 339 |
0 | 340 if (FileName.exists(sdi)) { |
341 result = sdi; | |
342 } else if (FileName.exists(sd)) { | |
343 result = sd; | |
344 } else if (FileName.absolute(filename)) { | |
345 ; | |
346 } | |
347 else | |
348 { | |
349 foreach (p; global.path) | |
350 { | |
351 string n = FileName.combine(p, sdi); | |
352 | |
353 if (FileName.exists(n)) | |
354 { | |
355 result = n; | |
356 break; | |
357 } | |
358 | |
359 n = FileName.combine(p, sd); | |
360 if (FileName.exists(n)) | |
361 { | |
362 result = n; | |
363 break; | |
364 } | |
365 } | |
366 } | |
367 | |
174 | 368 if (result) { |
0 | 369 m.srcfile = new File(result); |
174 | 370 } |
0 | 371 |
372 if (global.params.verbose) | |
373 { | |
178 | 374 write("import "); |
0 | 375 if (packages) |
376 { | |
128
e6e542f37b94
Some more Array -> Vector conversions
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
126
diff
changeset
|
377 foreach (pid; packages) |
174 | 378 { |
0 | 379 writef("%s.", pid.toChars()); |
380 } | |
381 } | |
382 writef("%s\t(%s)\n", ident.toChars(), m.srcfile.toChars()); | |
383 } | |
384 | |
385 m.read(loc); | |
386 m.parse(); | |
387 | |
388 version (IN_GCC) { | |
389 d_gcc_magic_module(m); | |
390 } | |
391 | |
392 return m; | |
393 } | |
394 | |
72 | 395 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 396 { |
397 assert(false); | |
398 } | |
174 | 399 |
79 | 400 override void toJsonBuffer(OutBuffer buf) |
401 { | |
96 | 402 buf.writestring("{\n"); |
79 | 403 |
96 | 404 if (md) |
405 JsonProperty(buf, Pname, md.toChars()); | |
79 | 406 |
96 | 407 JsonProperty(buf, Pkind, kind()); |
79 | 408 |
96 | 409 JsonProperty(buf, Pfile, srcfile.toChars()); |
79 | 410 |
96 | 411 if (comment) |
412 JsonProperty(buf, Pcomment, comment); | |
79 | 413 |
96 | 414 JsonString(buf, Pmembers); |
415 buf.writestring(" : [\n"); | |
79 | 416 |
96 | 417 size_t offset = buf.offset; |
418 foreach (Dsymbol s; members) | |
419 { | |
420 if (offset != buf.offset) | |
421 { | |
422 buf.writestring(",\n"); | |
423 offset = buf.offset; | |
424 } | |
425 s.toJsonBuffer(buf); | |
426 } | |
79 | 427 |
96 | 428 JsonRemoveComma(buf); |
429 buf.writestring("]\n"); | |
79 | 430 |
96 | 431 buf.writestring("}\n"); |
432 } | |
174 | 433 |
72 | 434 override string kind() |
0 | 435 { |
436 return "module"; | |
437 } | |
174 | 438 |
0 | 439 void setDocfile() // set docfile member |
440 { | |
441 assert(false); | |
442 } | |
174 | 443 |
0 | 444 void read(Loc loc) // read file |
445 { | |
174 | 446 //writefln("Module.read('%s') file '%s'", toChars(), srcfile.toChars()); |
0 | 447 if (srcfile.read()) |
448 { | |
449 error(loc, "cannot read file '%s'", srcfile.toChars()); | |
450 fatal(); | |
451 } | |
452 } | |
174 | 453 |
0 | 454 version (IN_GCC) { |
455 void parse(bool dump_source = false) // syntactic parse | |
456 { | |
457 assert(false); | |
458 } | |
459 } else { | |
460 void parse() // syntactic parse | |
461 { | |
462 uint le; | |
463 uint bom; | |
464 | |
465 //printf("Module.parse()\n"); | |
466 | |
467 string srcname = srcfile.name.toChars(); | |
468 //printf("Module.parse(srcname = '%s')\n", srcname); | |
469 | |
470 ubyte* buf = srcfile.buffer; | |
471 uint buflen = srcfile.len; | |
472 | |
473 if (buflen >= 2) | |
474 { | |
475 /* Convert all non-UTF-8 formats to UTF-8. | |
476 * BOM : http://www.unicode.org/faq/utf_bom.html | |
477 * 00 00 FE FF UTF-32BE, big-endian | |
478 * FF FE 00 00 UTF-32LE, little-endian | |
479 * FE FF UTF-16BE, big-endian | |
480 * FF FE UTF-16LE, little-endian | |
481 * EF BB BF UTF-8 | |
482 */ | |
483 | |
484 bom = 1; // assume there's a BOM | |
485 if (buf[0] == 0xFF && buf[1] == 0xFE) | |
486 { | |
487 if (buflen >= 4 && buf[2] == 0 && buf[3] == 0) | |
488 { // UTF-32LE | |
489 le = 1; | |
490 | |
491 Lutf32: | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
492 OutBuffer dbuf = new OutBuffer(); |
0 | 493 uint* pu = cast(uint*)buf; |
494 uint* pumax = &pu[buflen / 4]; | |
495 | |
496 if (buflen & 3) | |
497 { error("odd length of UTF-32 char source %u", buflen); | |
498 fatal(); | |
499 } | |
500 | |
501 dbuf.reserve(buflen / 4); | |
502 for (pu += bom; pu < pumax; pu++) | |
174 | 503 { |
0 | 504 uint u = le ? readlongLE(pu) : readlongBE(pu); |
505 if (u & ~0x7F) | |
506 { | |
507 if (u > 0x10FFFF) | |
508 { error("UTF-32 value %08x greater than 0x10FFFF", u); | |
509 fatal(); | |
510 } | |
511 dbuf.writeUTF8(u); | |
512 } | |
513 else | |
514 dbuf.writeByte(u); | |
515 } | |
516 dbuf.writeByte(0); // add 0 as sentinel for scanner | |
517 buflen = dbuf.offset - 1; // don't include sentinel in count | |
518 buf = cast(ubyte*) dbuf.extractData(); | |
519 } | |
520 else | |
174 | 521 { |
0 | 522 // UTF-16LE (X86) |
523 // Convert it to UTF-8 | |
524 le = 1; | |
525 | |
526 Lutf16: | |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
527 OutBuffer dbuf = new OutBuffer(); |
0 | 528 ushort* pu = cast(ushort*)(buf); |
529 ushort *pumax = &pu[buflen / 2]; | |
530 | |
531 if (buflen & 1) | |
532 { error("odd length of UTF-16 char source %u", buflen); | |
533 fatal(); | |
534 } | |
535 | |
536 dbuf.reserve(buflen / 2); | |
537 for (pu += bom; pu < pumax; pu++) | |
538 { | |
539 uint u = le ? readwordLE(pu) : readwordBE(pu); | |
540 if (u & ~0x7F) | |
541 { | |
542 if (u >= 0xD800 && u <= 0xDBFF) | |
543 { uint u2; | |
544 | |
545 if (++pu > pumax) | |
546 { error("surrogate UTF-16 high value %04x at EOF", u); | |
547 fatal(); | |
548 } | |
549 u2 = le ? readwordLE(pu) : readwordBE(pu); | |
550 if (u2 < 0xDC00 || u2 > 0xDFFF) | |
551 { error("surrogate UTF-16 low value %04x out of range", u2); | |
552 fatal(); | |
553 } | |
554 u = (u - 0xD7C0) << 10; | |
555 u |= (u2 - 0xDC00); | |
556 } | |
557 else if (u >= 0xDC00 && u <= 0xDFFF) | |
558 { | |
559 error("unpaired surrogate UTF-16 value %04x", u); | |
560 fatal(); | |
561 } | |
562 else if (u == 0xFFFE || u == 0xFFFF) | |
563 { | |
564 error("illegal UTF-16 value %04x", u); | |
565 fatal(); | |
566 } | |
567 dbuf.writeUTF8(u); | |
568 } | |
569 else | |
570 dbuf.writeByte(u); | |
571 } | |
572 dbuf.writeByte(0); // add 0 as sentinel for scanner | |
573 buflen = dbuf.offset - 1; // don't include sentinel in count | |
574 buf = cast(ubyte*) dbuf.extractData(); | |
575 } | |
576 } | |
577 else if (buf[0] == 0xFE && buf[1] == 0xFF) | |
578 { // UTF-16BE | |
579 le = 0; | |
580 goto Lutf16; | |
581 } | |
582 else if (buflen >= 4 && buf[0] == 0 && buf[1] == 0 && buf[2] == 0xFE && buf[3] == 0xFF) | |
583 { // UTF-32BE | |
584 le = 0; | |
585 goto Lutf32; | |
586 } | |
587 else if (buflen >= 3 && buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF) | |
588 { // UTF-8 | |
589 | |
590 buf += 3; | |
591 buflen -= 3; | |
592 } | |
593 else | |
594 { | |
595 /* There is no BOM. Make use of Arcane Jill's insight that | |
596 * the first char of D source must be ASCII to | |
597 * figure out the encoding. | |
598 */ | |
599 | |
600 bom = 0; | |
601 if (buflen >= 4) | |
602 { if (buf[1] == 0 && buf[2] == 0 && buf[3] == 0) | |
603 { // UTF-32LE | |
604 le = 1; | |
605 goto Lutf32; | |
606 } | |
607 else if (buf[0] == 0 && buf[1] == 0 && buf[2] == 0) | |
608 { // UTF-32BE | |
609 le = 0; | |
610 goto Lutf32; | |
611 } | |
612 } | |
613 if (buflen >= 2) | |
614 { | |
615 if (buf[1] == 0) | |
616 { // UTF-16LE | |
617 le = 1; | |
618 goto Lutf16; | |
619 } | |
620 else if (buf[0] == 0) | |
621 { // UTF-16BE | |
622 le = 0; | |
623 goto Lutf16; | |
624 } | |
625 } | |
626 | |
627 // It's UTF-8 | |
628 if (buf[0] >= 0x80) | |
629 { error("source file must start with BOM or ASCII character, not \\x%02X", buf[0]); | |
630 fatal(); | |
631 } | |
632 } | |
633 } | |
634 | |
635 version (IN_GCC) { | |
174 | 636 // dump utf-8 encoded source |
0 | 637 if (dump_source) |
638 { // %% srcname could contain a path ... | |
639 d_gcc_dump_source(srcname, "utf-8", buf, buflen); | |
640 } | |
641 } | |
642 | |
643 /* If it starts with the string "Ddoc", then it's a documentation | |
644 * source file. | |
645 */ | |
646 if (buflen >= 4 && memcmp(buf, "Ddoc".ptr, 4) == 0) | |
647 { | |
79 | 648 comment = cast(string) ((buf + 4)[0 .. buflen]); |
0 | 649 isDocFile = 1; |
650 if (!docfile) | |
651 setDocfile(); | |
652 return; | |
653 } | |
654 if (isHtml) | |
655 { | |
656 assert(false); | |
657 ///OutBuffer dbuf = new OutBuffer(); | |
658 ///Html h = new Html(srcname, buf, buflen); | |
659 ///h.extractCode(dbuf); | |
660 ///buf = dbuf.data; | |
661 ///buflen = dbuf.offset; | |
662 | |
79 | 663 version (IN_GCC) |
664 { | |
0 | 665 // dump extracted source |
666 ///if (dump_source) | |
667 /// d_gcc_dump_source(srcname, "d.utf-8", buf, buflen); | |
668 } | |
669 } | |
670 | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
671 auto p = new Parser(this, buf, buflen, docfile !is null); |
0 | 672 p.nextToken(); |
673 members = p.parseModule(); | |
674 md = p.md; | |
675 numlines = p.loc.linnum; | |
676 | |
677 DsymbolTable dst; | |
678 | |
679 if (md !is null) | |
680 { | |
681 this.ident = md.id; | |
682 this.safe = md.safe; | |
683 dst = super.resolve(md.packages, &this.parent, null); | |
684 } | |
685 else | |
686 { | |
169 | 687 dst = global.modules; |
0 | 688 |
689 /* Check to see if module name is a valid identifier | |
690 */ | |
691 if (!Lexer.isValidIdentifier(this.ident.toChars())) | |
692 error("has non-identifier characters in filename, use module declaration instead"); | |
693 } | |
174 | 694 |
0 | 695 // Update global list of modules |
696 if (!dst.insert(this)) | |
697 { | |
698 if (md) | |
699 error(loc, "is in multiple packages %s", md.toChars()); | |
700 else | |
701 error(loc, "is in multiple defined"); | |
702 } | |
703 else | |
704 { | |
169 | 705 global.amodules.push(cast(void*)this); |
0 | 706 } |
707 } | |
708 } | |
709 | |
79 | 710 override void importAll(Scope prevsc) |
711 { | |
712 //writef("+Module.importAll(this = %p, '%s'): parent = %p\n", this, toChars(), parent); | |
174 | 713 |
79 | 714 if (scope_ !is null) |
715 return; // already done | |
716 | |
717 /* Note that modules get their own scope, from scratch. | |
718 * This is so regardless of where in the syntax a module | |
719 * gets imported, it is unaffected by context. | |
720 * Ignore prevsc. | |
721 */ | |
722 Scope sc = Scope.createGlobal(this); // create root scope | |
174 | 723 |
79 | 724 // Add import of "object" if this module isn't "object" |
725 if (ident != Id.object) | |
726 { | |
727 if (members.dim == 0 || members[0].ident != Id.object) | |
728 { | |
729 Import im = new Import(Loc(), null, Id.object, null, 0); | |
730 members.shift(im); | |
731 } | |
732 } | |
733 | |
734 if (!symtab) | |
735 { | |
736 // Add all symbols into module's symbol table | |
737 symtab = new DsymbolTable(); | |
738 foreach (Dsymbol s; members) | |
739 s.addMember(null, sc.scopesym, 1); | |
740 } | |
741 // anything else should be run after addMember, so version/debug symbols are defined | |
174 | 742 |
79 | 743 /* Set scope for the symbols so that if we forward reference |
744 * a symbol, it can possibly be resolved on the spot. | |
745 * If this works out well, it can be extended to all modules | |
746 * before any semantic() on any of them. | |
747 */ | |
748 setScope(sc); // remember module scope for semantic | |
749 foreach (Dsymbol s; members) | |
750 s.setScope(sc); | |
174 | 751 |
79 | 752 foreach (Dsymbol s; members) |
753 s.importAll(sc); | |
174 | 754 |
79 | 755 sc = sc.pop(); |
756 sc.pop(); // 2 pops because Scope::createGlobal() created 2 | |
757 } | |
758 | |
0 | 759 void semantic() // semantic analysis |
760 { | |
761 if (semanticstarted) | |
762 return; | |
763 | |
764 //printf("+Module.semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); | |
765 semanticstarted = 1; | |
766 | |
767 // Note that modules get their own scope, from scratch. | |
768 // This is so regardless of where in the syntax a module | |
769 // gets imported, it is unaffected by context. | |
79 | 770 Scope sc = scope_; // // see if already got one from importAll() |
771 if (!sc) | |
772 { | |
773 writef("test2\n"); | |
774 Scope.createGlobal(this); // create root scope | |
775 } | |
0 | 776 |
79 | 777 //writef("Module = %p, linkage = %d\n", sc.scopesym, sc.linkage); |
0 | 778 |
79 | 779 static if (false) |
780 { | |
0 | 781 // Add import of "object" if this module isn't "object" |
782 if (ident !is Id.object) | |
783 { | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
784 auto im = new Import(Loc(0), null, Id.object, null, 0); |
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
785 members.shift(im); |
0 | 786 } |
787 | |
788 // Add all symbols into module's symbol table | |
789 symtab = new DsymbolTable(); | |
74
7e0d548de9e6
Switch Arrays of Dsymbols to the new templated Vector type
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
73
diff
changeset
|
790 foreach(s; members) |
174 | 791 { |
13 | 792 s.addMember(null, sc.scopesym, true); |
0 | 793 } |
794 | |
795 /* Set scope for the symbols so that if we forward reference | |
796 * a symbol, it can possibly be resolved on the spot. | |
797 * If this works out well, it can be extended to all modules | |
798 * before any semantic() on any of them. | |
799 */ | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
800 foreach(Dsymbol s; members) |
0 | 801 s.setScope(sc); |
79 | 802 } |
0 | 803 |
804 // Pass 1 semantic routines: do public side of the definition | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
805 foreach (Dsymbol s; members) |
174 | 806 { |
0 | 807 //writef("\tModule('%s'): '%s'.semantic()\n", toChars(), s.toChars()); |
808 s.semantic(sc); | |
809 runDeferredSemantic(); | |
810 } | |
811 | |
79 | 812 if (!scope_) |
813 { | |
814 sc = sc.pop(); | |
815 sc.pop(); // 2 pops because Scope.createGlobal() created 2 | |
816 } | |
0 | 817 semanticRun = semanticstarted; |
818 //printf("-Module.semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); | |
819 } | |
174 | 820 |
0 | 821 void semantic2() // pass 2 semantic analysis |
822 { | |
169 | 823 auto deferred = global.deferred; |
0 | 824 if (deferred.dim) |
825 { | |
826 for (int i = 0; i < deferred.dim; i++) | |
827 { | |
828 Dsymbol sd = cast(Dsymbol)deferred.data[i]; | |
829 | |
830 sd.error("unable to resolve forward reference in definition"); | |
831 } | |
832 return; | |
833 } | |
834 //printf("Module.semantic2('%s'): parent = %p\n", toChars(), parent); | |
835 if (semanticstarted >= 2) | |
836 return; | |
837 assert(semanticstarted == 1); | |
838 semanticstarted = 2; | |
839 | |
840 // Note that modules get their own scope, from scratch. | |
841 // This is so regardless of where in the syntax a module | |
842 // gets imported, it is unaffected by context. | |
843 Scope sc = Scope.createGlobal(this); // create root scope | |
844 //printf("Module = %p\n", sc.scopesym); | |
845 | |
846 // Pass 2 semantic routines: do initializers and function bodies | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
847 foreach(Dsymbol s; members) |
0 | 848 s.semantic2(sc); |
849 | |
850 sc = sc.pop(); | |
851 sc.pop(); | |
852 semanticRun = semanticstarted; | |
853 //printf("-Module.semantic2('%s'): parent = %p\n", toChars(), parent); | |
854 } | |
174 | 855 |
0 | 856 void semantic3() // pass 3 semantic analysis |
857 { | |
858 //printf("Module.semantic3('%s'): parent = %p\n", toChars(), parent); | |
859 if (semanticstarted >= 3) | |
860 return; | |
861 assert(semanticstarted == 2); | |
862 semanticstarted = 3; | |
863 | |
864 // Note that modules get their own scope, from scratch. | |
865 // This is so regardless of where in the syntax a module | |
866 // gets imported, it is unaffected by context. | |
867 Scope sc = Scope.createGlobal(this); // create root scope | |
868 //printf("Module = %p\n", sc.scopesym); | |
869 | |
870 // Pass 3 semantic routines: do initializers and function bodies | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
871 foreach(Dsymbol s; members) |
174 | 872 { |
0 | 873 //printf("Module %s: %s.semantic3()\n", toChars(), s.toChars()); |
874 s.semantic3(sc); | |
875 } | |
876 | |
877 sc = sc.pop(); | |
878 sc.pop(); | |
879 semanticRun = semanticstarted; | |
880 } | |
174 | 881 |
72 | 882 override void inlineScan() // scan for functions to inline |
0 | 883 { |
884 if (semanticstarted >= 4) | |
885 return; | |
886 | |
887 assert(semanticstarted == 3); | |
888 semanticstarted = 4; | |
889 | |
890 // Note that modules get their own scope, from scratch. | |
891 // This is so regardless of where in the syntax a module | |
892 // gets imported, it is unaffected by context. | |
893 //printf("Module = %p\n", sc.scopesym); | |
894 | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
895 foreach(Dsymbol s; members) |
174 | 896 { |
0 | 897 //if (global.params.verbose) |
898 //printf("inline scan symbol %s\n", s.toChars()); | |
899 s.inlineScan(); | |
900 } | |
901 | |
902 semanticRun = semanticstarted; | |
903 } | |
174 | 904 |
0 | 905 void setHdrfile() // set hdrfile member |
906 { | |
907 FileName hdrfilename; | |
908 string arghdr; | |
909 | |
910 if (global.params.hdrname) | |
911 arghdr = global.params.hdrname; | |
912 else if (global.params.preservePaths) | |
913 arghdr = arg; | |
914 else | |
915 arghdr = FileName.name(arg); | |
916 if (!FileName.absolute(arghdr)) | |
174 | 917 { |
0 | 918 //FileName.ensurePathExists(global.params.hdrdir); |
919 arghdr = FileName.combine(global.params.hdrdir, arghdr); | |
920 } | |
921 if (global.params.hdrname) | |
922 hdrfilename = new FileName(arghdr); | |
923 else | |
924 hdrfilename = FileName.forceExt(arghdr, global.hdr_ext); | |
925 | |
926 if (hdrfilename.str == srcfile.name.str) | |
174 | 927 { |
0 | 928 error("Source file and 'header' file have same name '%s'", srcfile.name.str); |
929 fatal(); | |
930 } | |
931 | |
932 hdrfile = new File(hdrfilename); | |
933 } | |
174 | 934 |
0 | 935 version (_DH) { |
936 void genhdrfile() // generate D import file | |
937 { | |
938 assert(false); | |
939 } | |
940 } | |
174 | 941 |
0 | 942 /************************************** |
943 * Generate .obj file for Module. | |
944 */ | |
945 void genobjfile(int multiobj) | |
946 { | |
947 //EEcontext *ee = env.getEEcontext(); | |
948 | |
949 //printf("Module.genobjfile(multiobj = %d) %s\n", multiobj, toChars()); | |
950 | |
176 | 951 auto lastmname = global.lastmname = srcfile.toChars(); |
0 | 952 |
953 obj_initfile(toStringz(lastmname), null, toStringz(toPrettyChars())); | |
954 | |
176 | 955 global.eictor = null; |
956 global.ictorlocalgot = null; | |
957 global.ector = null; | |
958 global.ectorgates.setDim(0); | |
959 global.edtor = null; | |
179 | 960 global.esharedctor = null; |
961 global.esharedctorgates.setDim(0); | |
962 global.eshareddtor = null; | |
176 | 963 global.etest = null; |
964 global.dtorcount = 0; | |
179 | 965 global.shareddtorcount = 0; |
0 | 966 |
967 if (doppelganger) | |
968 { | |
969 /* Generate a reference to the moduleinfo, so the module constructors | |
970 * and destructors get linked in. | |
971 */ | |
972 Module m = cast(Module)aimports.data[0]; | |
973 assert(m); | |
179 | 974 if (m.sictor || m.sctor || m.sdtor || m.ssharedctor || m.sshareddtor) |
0 | 975 { |
976 Symbol* s = m.toSymbol(); | |
977 //objextern(s); | |
978 //if (!s.Sxtrnnum) objextdef(s.Sident); | |
979 if (!s.Sxtrnnum) | |
980 { | |
981 //printf("%s\n", s.Sident); | |
982 static if (false) { | |
983 /* This should work, but causes optlink to fail in common/newlib.asm */ | |
984 objextdef(s.Sident); | |
985 } else { | |
22
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
16
diff
changeset
|
986 version (ELFOBJ_OR_MACHOBJ) {///ELFOBJ || MACHOBJ |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
16
diff
changeset
|
987 int nbytes = reftoident(Segment.DATA, Offset(Segment.DATA), s, 0, CF.CFoff); |
fd4acc376c45
Implemented object file output and linking on linux.
Robert Clipsham <robert@octarineparrot.com>
parents:
16
diff
changeset
|
988 Offset(Segment.DATA) += nbytes; |
0 | 989 } else { |
990 int nbytes = reftoident(Segment.DATA, Doffset, s, 0, CF.CFoff); | |
991 Doffset() += nbytes; | |
992 } | |
993 } | |
994 } | |
995 } | |
996 } | |
997 | |
998 if (global.params.cov) | |
999 { | |
1000 /* Create coverage identifier: | |
1001 * private uint[numlines] __coverage; | |
1002 */ | |
1003 cov = symbol_calloc("__coverage"); | |
1004 cov.Stype = type_fake(TYM.TYint); | |
1005 cov.Stype.Tmangle = mTYman.mTYman_c; | |
1006 cov.Stype.Tcount++; | |
1007 cov.Sclass = SC.SCstatic; | |
1008 cov.Sfl = FL.FLdata; | |
1009 version (ELFOBJ_OR_MACHOBJ) { | |
1010 cov.Sseg = Segment.UDATA; | |
1011 } | |
1012 dtnzeros(&cov.Sdt, 4 * numlines); | |
1013 outdata(cov); | |
1014 slist_add(cov); | |
1015 | |
4 | 1016 covb = cast(uint*)GC.calloc(((numlines + 32) / 32) * (*covb).sizeof); |
0 | 1017 } |
174 | 1018 |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
1019 foreach(Dsymbol member; members) |
0 | 1020 member.toObjFile(multiobj); |
174 | 1021 |
0 | 1022 if (global.params.cov) |
1023 { | |
1024 /* Generate | |
1025 * bit[numlines] __bcoverage; | |
1026 */ | |
1027 Symbol* bcov = symbol_calloc("__bcoverage"); | |
1028 bcov.Stype = type_fake(TYM.TYuint); | |
1029 bcov.Stype.Tcount++; | |
1030 bcov.Sclass = SC.SCstatic; | |
1031 bcov.Sfl = FL.FLdata; | |
1032 version (ELFOBJ_OR_MACHOBJ) { | |
1033 bcov.Sseg = Segment.DATA; | |
1034 } | |
1035 dtnbytes(&bcov.Sdt, (numlines + 32) / 32 * (*covb).sizeof, cast(char*)covb); | |
1036 outdata(bcov); | |
1037 | |
2 | 1038 ///free(covb); |
0 | 1039 covb = null; |
1040 | |
1041 /* Generate: | |
1042 * _d_cover_register(uint[] __coverage, BitArray __bcoverage, string filename); | |
1043 * and prepend it to the static constructor. | |
1044 */ | |
1045 | |
1046 /* t will be the type of the functions generated: | |
1047 * extern (C) void func(); | |
1048 */ | |
1049 type* t = type_alloc(TYM.TYnfunc); | |
1050 t.Tflags |= TF.TFprototype | TF.TFfixed; | |
1051 t.Tmangle = mTYman.mTYman_c; | |
1052 t.Tnext = tsvoid; | |
1053 tsvoid.Tcount++; | |
1054 | |
1055 sictor = toSymbolX("__modictor", SC.SCglobal, t, "FZv"); | |
1056 cstate.CSpsymtab = &sictor.Sfunc.Flocsym; | |
176 | 1057 global.localgot = global.ictorlocalgot; |
0 | 1058 elem* e; |
1059 | |
1060 e = el_params(el_ptr(cov), el_long(TYM.TYuint, numlines), | |
1061 el_ptr(bcov), el_long(TYM.TYuint, numlines), | |
1062 toEfilename(), | |
1063 null); | |
1064 e = el_bin(OPER.OPcall, TYM.TYvoid, el_var(rtlsym[RTLSYM.RTLSYM_DCOVER]), e); | |
176 | 1065 global.eictor = el_combine(e, global.eictor); |
1066 global.ictorlocalgot = global.localgot; | |
0 | 1067 } |
1068 | |
1069 // If coverage / static constructor / destructor / unittest calls | |
179 | 1070 if (global.eictor || global.ector || global.ectorgates.dim || global.edtor || global.esharedctor || global.esharedctorgates.dim || global.eshareddtor || global.etest) |
0 | 1071 { |
1072 /* t will be the type of the functions generated: | |
1073 * extern (C) void func(); | |
1074 */ | |
1075 type* t = type_alloc(TYM.TYnfunc); | |
1076 t.Tflags |= TF.TFprototype | TF.TFfixed; | |
1077 t.Tmangle = mTYman.mTYman_c; | |
1078 t.Tnext = tsvoid; | |
1079 tsvoid.Tcount++; | |
1080 | |
170 | 1081 enum moddeco = "FZv"; |
0 | 1082 |
176 | 1083 if (global.eictor) |
0 | 1084 { |
176 | 1085 global.localgot = global.ictorlocalgot; |
0 | 1086 |
1087 block* b = block_calloc(); | |
1088 b.BC = BC.BCret; | |
176 | 1089 b.Belem = global.eictor; |
0 | 1090 sictor.Sfunc.Fstartblock = b; |
1091 writefunc(sictor); | |
1092 } | |
1093 | |
176 | 1094 if (global.ector || global.ectorgates.dim) |
0 | 1095 { |
176 | 1096 global.localgot = null; |
0 | 1097 sctor = toSymbolX("__modctor", SC.SCglobal, t, moddeco); |
1098 cstate.CSpsymtab = &sctor.Sfunc.Flocsym; | |
1099 | |
176 | 1100 for (int i = 0; i < global.ectorgates.dim; i++) |
174 | 1101 { |
176 | 1102 StaticDtorDeclaration f = cast(StaticDtorDeclaration)global.ectorgates.data[i]; |
0 | 1103 |
1104 Symbol* s = f.vgate.toSymbol(); | |
1105 elem* e = el_var(s); | |
1106 e = el_bin(OPER.OPaddass, TYM.TYint, e, el_long(TYM.TYint, 1)); | |
176 | 1107 global.ector = el_combine(global.ector, e); |
0 | 1108 } |
1109 | |
1110 block* b = block_calloc(); | |
1111 b.BC = BC.BCret; | |
176 | 1112 b.Belem = global.ector; |
0 | 1113 sctor.Sfunc.Fstartblock = b; |
1114 writefunc(sctor); | |
1115 version (STATICCTOR) { | |
1116 obj_staticctor(sctor, dtorcount, 1); | |
1117 } | |
1118 } | |
1119 | |
176 | 1120 if (global.edtor) |
0 | 1121 { |
176 | 1122 global.localgot = null; |
0 | 1123 sdtor = toSymbolX("__moddtor", SC.SCglobal, t, moddeco); |
1124 | |
1125 block* b = block_calloc(); | |
1126 b.BC = BC.BCret; | |
176 | 1127 b.Belem = global.edtor; |
0 | 1128 sdtor.Sfunc.Fstartblock = b; |
1129 writefunc(sdtor); | |
1130 } | |
179 | 1131 |
1132 if (global.esharedctor || global.esharedctorgates.dim) | |
1133 { | |
1134 global.localgot = null; | |
1135 ssharedctor = toSymbolX("__modsharedctor", SCglobal, t, moddeco); | |
1136 cstate.CSpsymtab = &ssharedctor.Sfunc.Flocsym; | |
1137 | |
1138 for (int i = 0; i < global.esharedctorgates.dim; i++) | |
1139 { | |
1140 SharedStaticDtorDeclaration f = cast(SharedStaticDtorDeclaration)global.esharedctorgates.data[i]; | |
1141 | |
1142 Symbol* s = f.vgate.toSymbol(); | |
1143 elem* e = el_var(s); | |
1144 e = el_bin(OPaddass, TYint, e, el_long(TYint, 1)); | |
1145 global.esharedctor = el_combine(global.esharedctor, e); | |
1146 } | |
1147 | |
1148 block* b = block_calloc(); | |
1149 b.BC = BCret; | |
1150 b.Belem = global.esharedctor; | |
1151 ssharedctor.Sfunc.Fstartblock = b; | |
1152 writefunc(ssharedctor); | |
1153 version (STATICCTOR) { | |
1154 obj_staticctor(ssharedctor, shareddtorcount, 1); | |
1155 } | |
1156 } | |
1157 | |
1158 if (global.eshareddtor) | |
1159 { | |
1160 global.localgot = null; | |
1161 sshareddtor = toSymbolX("__modshareddtor", SCglobal, t, moddeco); | |
1162 | |
1163 block *b = block_calloc(); | |
1164 b.BC = BCret; | |
1165 b.Belem = global.eshareddtor; | |
1166 sshareddtor.Sfunc.Fstartblock = b; | |
1167 writefunc(sshareddtor); | |
1168 } | |
1169 | |
0 | 1170 |
176 | 1171 if (global.etest) |
0 | 1172 { |
176 | 1173 global.localgot = null; |
0 | 1174 stest = toSymbolX("__modtest", SC.SCglobal, t, moddeco); |
1175 | |
1176 block* b = block_calloc(); | |
1177 b.BC = BC.BCret; | |
176 | 1178 b.Belem = global.etest; |
0 | 1179 stest.Sfunc.Fstartblock = b; |
1180 writefunc(stest); | |
1181 } | |
1182 | |
1183 if (doppelganger) | |
1184 genmoduleinfo(); | |
1185 } | |
1186 | |
1187 if (doppelganger) | |
1188 { | |
1189 obj_termfile(); | |
1190 return; | |
1191 } | |
1192 | |
1193 if (global.params.multiobj) | |
1194 { /* This is necessary because the main .obj for this module is written | |
1195 * first, but determining whether marray or massert are needed is done | |
1196 * possibly later in the doppelganger modules. | |
1197 * Another way to fix it is do the main one last. | |
1198 */ | |
1199 toModuleAssert(); | |
1200 toModuleArray(); | |
1201 } | |
1202 | |
1203 // If module assert | |
1204 for (int i = 0; i < 2; i++) | |
1205 { | |
1206 Symbol* ma = i ? marray : massert; | |
1207 | |
1208 if (ma) | |
1209 { | |
1210 elem* elinnum; | |
1211 elem* efilename; | |
1212 | |
176 | 1213 global.localgot = null; |
0 | 1214 |
1215 // Call dassert(filename, line) | |
1216 // Get sole parameter, linnum | |
1217 { | |
1218 Symbol* sp; | |
1219 | |
1220 sp = symbol_calloc("linnum".ptr); | |
1221 sp.Stype = type_fake(TYM.TYint); | |
1222 sp.Stype.Tcount++; | |
1223 sp.Sclass = SC.SCfastpar; | |
1224 sp.Spreg = REG.AX; | |
1225 sp.Sflags &= ~SFL.SFLspill; | |
1226 sp.Sfl = FL.FLpara; // FLauto? | |
1227 cstate.CSpsymtab = &ma.Sfunc.Flocsym; | |
1228 symbol_add(sp); | |
1229 | |
1230 elinnum = el_var(sp); | |
1231 } | |
1232 | |
1233 efilename = toEmodulename(); | |
1234 | |
1235 elem *e = el_var(rtlsym[i ? RTLSYM.RTLSYM_DARRAY : RTLSYM.RTLSYM_DASSERT]); | |
1236 e = el_bin(OPER.OPcall, TYM.TYvoid, e, el_param(elinnum, efilename)); | |
1237 | |
1238 block* b = block_calloc(); | |
1239 b.BC = BC.BCret; | |
1240 b.Belem = e; | |
1241 ma.Sfunc.Fstartblock = b; | |
1242 ma.Sclass = SC.SCglobal; | |
1243 ma.Sfl = 0; | |
1244 writefunc(ma); | |
1245 } | |
1246 } | |
174 | 1247 |
0 | 1248 |
1249 static if (true) { | |
1250 // Always generate module info, because of templates and -cov | |
1251 if (1 || needModuleInfo()) | |
1252 genmoduleinfo(); | |
5
63623152e82a
Fixed memory corruption bug which was introduced when attempting to restore GC functionality
dkoroskin <>
parents:
4
diff
changeset
|
1253 } |
174 | 1254 |
0 | 1255 obj_termfile(); |
1256 } | |
174 | 1257 |
0 | 1258 void gensymfile() |
1259 { | |
1260 assert(false); | |
1261 } | |
174 | 1262 |
0 | 1263 void gendocfile() |
1264 { | |
1265 assert(false); | |
1266 } | |
174 | 1267 |
0 | 1268 /********************************** |
1269 * Determine if we need to generate an instance of ModuleInfo | |
1270 * for this Module. | |
1271 */ | |
1272 bool needModuleInfo() | |
1273 { | |
96 | 1274 // writef("needModuleInfo() %s, %d, %d\n", toChars(), needmoduleinfo, global.params.cov); |
0 | 1275 return needmoduleinfo || global.params.cov; |
1276 } | |
174 | 1277 |
72 | 1278 override Dsymbol search(Loc loc, Identifier ident, int flags) |
0 | 1279 { |
1280 /* Since modules can be circularly referenced, | |
1281 * need to stop infinite recursive searches. | |
79 | 1282 * This is done with the cache. |
0 | 1283 */ |
1284 | |
1285 //printf("%s Module.search('%s', flags = %d) insearch = %d\n", toChars(), ident.toChars(), flags, insearch); | |
1286 Dsymbol s; | |
1287 if (insearch) | |
1288 s = null; | |
79 | 1289 else if (searchCacheIdent == ident && searchCacheFlags == flags) |
73 | 1290 { |
0 | 1291 s = searchCacheSymbol; |
73 | 1292 //printf("%s Module.search('%s', flags = %d) insearch = %d searchCacheSymbol = %s\n", toChars(), ident.toChars(), flags, insearch, searchCacheSymbol ? searchCacheSymbol.toChars() : "null"); |
1293 } | |
0 | 1294 else |
1295 { | |
1296 insearch = 1; | |
1297 s = ScopeDsymbol.search(loc, ident, flags); | |
1298 insearch = 0; | |
1299 | |
1300 searchCacheIdent = ident; | |
1301 searchCacheSymbol = s; | |
1302 searchCacheFlags = flags; | |
1303 } | |
1304 return s; | |
1305 } | |
174 | 1306 |
0 | 1307 void deleteObjFile() |
1308 { | |
1309 if (global.params.obj) | |
1310 objfile.remove(); | |
1311 if (docfile) | |
1312 docfile.remove(); | |
1313 } | |
1314 | |
79 | 1315 override Dsymbol symtabInsert(Dsymbol s) |
1316 { | |
1317 searchCacheIdent = null; // symbol is inserted, so invalidate cache | |
1318 return Package.symtabInsert(s); | |
1319 } | |
1320 | |
29
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1321 /******************************************* |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1322 * Can't run semantic on s now, try again later. |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1323 */ |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1324 void addDeferredSemantic(Dsymbol s) |
0 | 1325 { |
169 | 1326 auto deferred = global.deferred; |
29
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1327 // Don't add it if it is already there |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1328 for (int i = 0; i < deferred.dim; i++) |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1329 { |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1330 Dsymbol sd = cast(Dsymbol)deferred.data[i]; |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1331 |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1332 if (sd == s) |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1333 return; |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1334 } |
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1335 |
79 | 1336 //printf("Module::addDeferredSemantic('%s')\n", s.toChars()); |
29
9fe59705c82d
Implemented Module.addDeferredSemantic, removed -release from the linux commands file.
Robert Clipsham <robert@octarineparrot.com>
parents:
23
diff
changeset
|
1337 deferred.push(cast(void*)s); |
0 | 1338 } |
174 | 1339 |
0 | 1340 /****************************************** |
1341 * Run semantic() on deferred symbols. | |
1342 */ | |
1343 | |
179 | 1344 static void runDeferredSemantic() |
0 | 1345 { |
179 | 1346 if (global.dprogress == 0) |
1347 return; | |
1348 | |
170 | 1349 if (global.nested) |
1350 return; | |
1351 //if (deferred.dim) printf("+Module.runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); | |
1352 global.nested++; | |
174 | 1353 |
169 | 1354 auto deferred = global.deferred; |
174 | 1355 |
179 | 1356 size_t len; |
0 | 1357 do |
1358 { | |
169 | 1359 global.dprogress = 0; |
0 | 1360 len = deferred.dim; |
1361 if (!len) | |
1362 break; | |
1363 | |
1364 Dsymbol *todo; | |
1365 Dsymbol tmp; | |
1366 if (len == 1) | |
1367 { | |
1368 todo = &tmp; | |
1369 } | |
1370 else | |
1371 { | |
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:
5
diff
changeset
|
1372 version(Bug4054) |
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:
5
diff
changeset
|
1373 todo = cast(Dsymbol*)GC.malloc(len * (Dsymbol*).sizeof); |
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:
5
diff
changeset
|
1374 else |
0 | 1375 todo = cast(Dsymbol*)alloca(len * (Dsymbol*).sizeof); |
1376 assert(todo); | |
1377 } | |
1378 memcpy(todo, deferred.data, len * (Dsymbol*).sizeof); | |
1379 deferred.setDim(0); | |
1380 | |
1381 for (int i = 0; i < len; i++) | |
1382 { | |
1383 Dsymbol s = todo[i]; | |
1384 | |
1385 s.semantic(null); | |
1386 //printf("deferred: %s, parent = %s\n", s.toChars(), s.parent.toChars()); | |
1387 } | |
1388 //printf("\tdeferred.dim = %d, len = %d, dprogress = %d\n", deferred.dim, len, dprogress); | |
169 | 1389 } while (deferred.dim < len || global.dprogress); // while making progress |
170 | 1390 global.nested--; |
0 | 1391 //printf("-Module.runDeferredSemantic('%s'), len = %d\n", toChars(), deferred.dim); |
1392 } | |
81 | 1393 |
1394 /************************************ | |
1395 * Recursively look at every module this module imports, | |
1396 * return TRUE if it imports m. | |
1397 * Can be used to detect circular imports. | |
1398 */ | |
1399 bool imports(Module m) | |
0 | 1400 { |
81 | 1401 // writef("%s Module::imports(%s)\n", toChars(), m.toChars()); |
1402 int aimports_dim = aimports.dim; | |
1403 static if (false) | |
1404 { | |
1405 for (int i = 0; i < aimports.dim; i++) | |
1406 { Module mi = cast(Module)aimports.data[i]; | |
1407 writef("\t[%d] %s\n", i, mi.toChars()); | |
1408 } | |
1409 } | |
1410 for (int i = 0; i < aimports.dim; i++) | |
1411 { Module mi = cast(Module)aimports.data[i]; | |
1412 if (mi == m) | |
1413 return true; | |
1414 if (!mi.insearch) | |
1415 { | |
1416 mi.insearch = 1; | |
1417 bool r = mi.imports(m); | |
1418 if (r) | |
1419 return r; | |
1420 } | |
1421 } | |
1422 return false; | |
0 | 1423 } |
1424 | |
1425 // Back end | |
1426 | |
1427 int doppelganger; // sub-module | |
1428 Symbol* cov; // private uint[] __coverage; | |
1429 uint* covb; // bit array of valid code line numbers | |
1430 | |
1431 Symbol* sictor; // module order independent constructor | |
1432 Symbol* sctor; // module constructor | |
1433 Symbol* sdtor; // module destructor | |
179 | 1434 Symbol* ssharedctor; // module shared constructor |
1435 Symbol* sshareddtor; // module shared destructor | |
0 | 1436 Symbol* stest; // module unit test |
1437 | |
1438 Symbol* sfilename; // symbol for filename | |
1439 | |
1440 Symbol* massert; // module assert function | |
1441 Symbol* toModuleAssert() // get module assert function | |
1442 { | |
1443 if (!massert) | |
1444 { | |
1445 type* t; | |
1446 | |
1447 t = type_alloc(TYjfunc); | |
1448 t.Tflags |= TFprototype | TFfixed; | |
1449 t.Tmangle = mTYman_d; | |
1450 t.Tnext = tsvoid; | |
1451 tsvoid.Tcount++; | |
1452 | |
1453 massert = toSymbolX("__assert", SCextern, t, "FiZv"); | |
1454 massert.Sfl = FLextern; | |
1455 massert.Sflags |= SFLnodebug; | |
1456 slist_add(massert); | |
1457 } | |
1458 return massert; | |
1459 } | |
1460 | |
1461 Symbol* marray; // module array bounds function | |
1462 | |
1463 Symbol* toModuleArray() // get module array bounds function | |
1464 { | |
1465 if (!marray) | |
1466 { | |
1467 type* t; | |
1468 | |
1469 t = type_alloc(TYjfunc); | |
1470 t.Tflags |= TFprototype | TFfixed; | |
1471 t.Tmangle = mTYman_d; | |
1472 t.Tnext = tsvoid; | |
1473 tsvoid.Tcount++; | |
1474 | |
1475 marray = toSymbolX("__array", SCextern, t, "Z"); | |
1476 marray.Sfl = FLextern; | |
1477 marray.Sflags |= SFLnodebug; | |
1478 slist_add(marray); | |
1479 } | |
1480 return marray; | |
1481 } | |
1482 | |
1483 static Symbol* gencritsec() | |
1484 { | |
1485 assert(false); | |
1486 } | |
174 | 1487 |
0 | 1488 elem* toEfilename() |
1489 { | |
1490 elem* efilename; | |
1491 | |
1492 if (!sfilename) | |
1493 { | |
1494 dt_t* dt = null; | |
1495 | |
1496 string id = srcfile.toChars(); | |
1497 int len = id.length; | |
1498 dtdword(&dt, len); | |
1499 dtabytes(&dt,TYnptr, 0, len + 1, toStringz(id)); | |
1500 | |
1501 sfilename = symbol_generate(SCstatic,type_fake(TYdarray)); | |
1502 sfilename.Sdt = dt; | |
1503 sfilename.Sfl = FLdata; | |
1504 version (ELFOBJ) { | |
1505 sfilename.Sseg = Segment.CDATA; | |
1506 } | |
1507 version (MACHOBJ) { | |
1508 // Because of PIC and CDATA being in the _TEXT segment, cannot | |
1509 // have pointers in CDATA | |
1510 sfilename.Sseg = Segment.DATA; | |
1511 } | |
1512 outdata(sfilename); | |
1513 } | |
1514 | |
1515 efilename = el_var(sfilename); | |
1516 return efilename; | |
1517 } | |
174 | 1518 |
0 | 1519 /************************************** |
1520 * Generate elem that is a pointer to the module file name. | |
1521 */ | |
1522 elem* toEmodulename() | |
1523 { | |
1524 elem *efilename; | |
1525 | |
1526 // Get filename | |
1527 if (needModuleInfo()) | |
174 | 1528 { |
0 | 1529 /* Class ModuleInfo is defined in std.moduleinfo. |
1530 * The first member is the name of it, char name[], | |
1531 * which will be at offset 8. | |
1532 */ | |
1533 | |
1534 Symbol* si = toSymbol(); | |
1535 static if (true) { | |
1536 // Use this instead so -fPIC will work | |
1537 efilename = el_ptr(si); | |
1538 efilename = el_bin(OPadd, TYnptr, efilename, el_long(TYuint, 8)); | |
1539 efilename = el_una(OPind, TYdarray, efilename); | |
1540 } else { | |
1541 efilename = el_var(si); | |
1542 efilename.Ety = TYdarray; | |
1543 efilename.EV.sp.Voffset += 8; | |
1544 } | |
1545 } | |
1546 else // generate our own filename | |
1547 { | |
1548 efilename = toEfilename(); | |
1549 } | |
1550 return efilename; | |
1551 } | |
1552 | |
1553 /************************************* | |
1554 * Create the "ModuleInfo" symbol | |
1555 */ | |
72 | 1556 override Symbol* toSymbol() |
0 | 1557 { |
1558 if (!csym) | |
1559 { | |
1560 Symbol* s; | |
1561 | |
170 | 1562 s = toSymbolX("__ModuleInfo", SC.SCextern, global.scc.Stype, "Z"); |
0 | 1563 s.Sfl = FL.FLextern; |
1564 s.Sflags |= SFL.SFLnodebug; | |
1565 csym = s; | |
1566 slist_add(s); | |
1567 } | |
1568 return csym; | |
1569 } | |
1570 | |
1571 // Put out instance of ModuleInfo for this Module | |
1572 void genmoduleinfo() | |
1573 { | |
1574 //printf("Module.genmoduleinfo() %s\n", toChars()); | |
1575 | |
1576 Symbol* msym = toSymbol(); | |
1577 | |
1578 //dumpSymbol(msym); | |
174 | 1579 |
0 | 1580 uint offset; |
1581 version (DMDV2) { | |
179 | 1582 uint sizeof_ModuleInfo = 16 * PTRSIZE; |
0 | 1583 } else { |
1584 uint sizeof_ModuleInfo = 14 * PTRSIZE; | |
1585 } | |
179 | 1586 |
1587 version (MODULEINFO_IS_STRUCT) {} else { | |
1588 sizeof_ModuleInfo -= 2 * PTRSIZE; | |
1589 } | |
1590 //printf("moduleinfo size = x%x\n", sizeof_ModuleInfo); | |
0 | 1591 |
1592 ////////////////////////////////////////////// | |
1593 | |
1594 csym.Sclass = SC.SCglobal; | |
1595 | |
1596 csym.Sfl = FL.FLdata; | |
1597 | |
1598 /* The layout is: | |
1599 { | |
1600 void **vptr; | |
1601 monitor_t monitor; | |
1602 char[] name; // class name | |
1603 ModuleInfo importedModules[]; | |
1604 ClassInfo localClasses[]; | |
1605 uint flags; // initialization state | |
1606 void *ctor; | |
1607 void *dtor; | |
1608 void *unitTest; | |
1609 const(MemberInfo[]) function(string) xgetMembers; // module getMembers() function | |
1610 void *ictor; | |
179 | 1611 void *sharedctor; |
1612 void *shareddtor; | |
1613 uint index; | |
1614 void*[1] reserved; | |
0 | 1615 } |
1616 */ | |
1617 dt_t* dt = null; | |
179 | 1618 version (MODULEINFO_IS_STRUCT) {} else { |
169 | 1619 if (global.moduleinfo) |
1620 dtxoff(&dt, global.moduleinfo.toVtblSymbol(), 0, TYM.TYnptr); // vtbl for ModuleInfo | |
0 | 1621 else |
174 | 1622 { |
0 | 1623 //printf("moduleinfo is null\n"); |
1624 dtdword(&dt, 0); // BUG: should be an assert() | |
1625 } | |
1626 dtdword(&dt, 0); // monitor | |
179 | 1627 } |
0 | 1628 // name[] |
1629 string name = toPrettyChars(); | |
1630 size_t namelen = name.length; | |
1631 dtdword(&dt, namelen); | |
1632 dtabytes(&dt, TYM.TYnptr, 0, namelen + 1, toStringz(name)); | |
1633 | |
1634 ClassDeclarations aclasses = new ClassDeclarations(); | |
1635 | |
1636 //printf("members.dim = %d\n", members.dim); | |
77
ad4792a1cfd6
more D-ification container accessing
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
74
diff
changeset
|
1637 foreach(Dsymbol member; members) |
174 | 1638 { |
0 | 1639 //printf("\tmember '%s'\n", member.toChars()); |
1640 member.addLocalClass(aclasses); | |
1641 } | |
1642 | |
1643 // importedModules[] | |
1644 int aimports_dim = aimports.dim; | |
1645 for (int i = 0; i < aimports.dim; i++) | |
174 | 1646 { |
0 | 1647 Module m = cast(Module)aimports.data[i]; |
1648 if (!m.needModuleInfo()) | |
1649 aimports_dim--; | |
1650 } | |
1651 | |
1652 dtdword(&dt, aimports_dim); | |
1653 if (aimports_dim) | |
1654 dtxoff(&dt, csym, sizeof_ModuleInfo, TYM.TYnptr); | |
1655 else | |
1656 dtdword(&dt, 0); | |
1657 | |
1658 // localClasses[] | |
1659 dtdword(&dt, aclasses.dim); | |
1660 if (aclasses.dim) | |
1661 dtxoff(&dt, csym, sizeof_ModuleInfo + aimports_dim * PTRSIZE, TYM.TYnptr); | |
1662 else | |
1663 dtdword(&dt, 0); | |
1664 | |
1665 if (needmoduleinfo) | |
1666 dtdword(&dt, 8|0); // flags (4 means MIstandalone) | |
1667 else | |
1668 dtdword(&dt, 8|4); // flags (4 means MIstandalone) | |
1669 | |
179 | 1670 if (ssharedctor) |
1671 dtxoff(&dt, ssharedctor, 0, TYnptr); | |
0 | 1672 else |
1673 dtdword(&dt, 0); | |
1674 | |
179 | 1675 if (sshareddtor) |
1676 dtxoff(&dt, sshareddtor, 0, TYnptr); | |
0 | 1677 else |
1678 dtdword(&dt, 0); | |
1679 | |
1680 if (stest) | |
1681 dtxoff(&dt, stest, 0, TYM.TYnptr); | |
1682 else | |
1683 dtdword(&dt, 0); | |
1684 | |
1685 /// version (DMDV2) { | |
1686 FuncDeclaration sgetmembers = findGetMembers(); | |
1687 if (sgetmembers) | |
1688 dtxoff(&dt, sgetmembers.toSymbol(), 0, TYM.TYnptr); | |
1689 else | |
1690 /// } | |
1691 dtdword(&dt, 0); // xgetMembers | |
1692 | |
1693 if (sictor) | |
1694 dtxoff(&dt, sictor, 0, TYM.TYnptr); | |
1695 else | |
1696 dtdword(&dt, 0); | |
1697 | |
1698 version (DMDV2) { | |
179 | 1699 if (sctor) |
1700 dtxoff(&dt, sctor, 0, TYnptr); | |
1701 else | |
1702 dtdword(&dt, 0); | |
1703 | |
1704 if (sdtor) | |
1705 dtxoff(&dt, sdtor, 0, TYnptr); | |
1706 else | |
1707 dtdword(&dt, 0); | |
1708 | |
1709 dtdword(&dt, 0); // index | |
1710 | |
1711 // void*[1] reserved; | |
0 | 1712 dtdword(&dt, 0); |
1713 } | |
1714 ////////////////////////////////////////////// | |
1715 | |
1716 for (int i = 0; i < aimports.dim; i++) | |
174 | 1717 { |
0 | 1718 Module m = cast(Module)aimports.data[i]; |
1719 | |
1720 if (m.needModuleInfo()) | |
174 | 1721 { |
0 | 1722 Symbol* s = m.toSymbol(); |
1723 | |
1724 /* Weak references don't pull objects in from the library, | |
1725 * they resolve to 0 if not pulled in by something else. | |
1726 * Don't pull in a module just because it was imported. | |
1727 */ | |
1728 version (OMFOBJ) {// Optlink crashes with weak symbols at EIP 41AFE7, 402000 | |
1729 } else { | |
1730 s.Sflags |= SFL.SFLweak; | |
1731 } | |
1732 dtxoff(&dt, s, 0, TYM.TYnptr); | |
1733 } | |
1734 } | |
1735 | |
126
1765f3ef917d
ClassDeclarations, Arguments -> Vector
Eldar Insafutdinov <e.insafutdinov@gmail.com>
parents:
114
diff
changeset
|
1736 foreach (cd; aclasses) |
0 | 1737 { |
1738 dtxoff(&dt, cd.toSymbol(), 0, TYM.TYnptr); | |
1739 } | |
1740 | |
1741 csym.Sdt = dt; | |
1742 version (ELFOBJ_OR_MACHOBJ) { | |
1743 // Cannot be CONST because the startup code sets flag bits in it | |
1744 csym.Sseg = Segment.DATA; | |
1745 } | |
1746 | |
1747 outdata(csym); | |
1748 | |
1749 ////////////////////////////////////////////// | |
1750 | |
1751 obj_moduleinfo(msym); | |
1752 } | |
1753 | |
72 | 1754 override Module isModule() { return this; } |
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:
5
diff
changeset
|
1755 } |