0
|
1 module dmd.Loc;
|
|
2
|
114
|
3 import dmd.common;
|
0
|
4 import dmd.Module;
|
|
5 import dmd.OutBuffer;
|
|
6
|
|
7 struct Loc
|
|
8 {
|
|
9 string filename;
|
|
10 uint linnum;
|
|
11
|
|
12 this(int x)
|
|
13 {
|
|
14 linnum = x;
|
|
15 filename = null;
|
|
16 }
|
|
17
|
|
18 this(Module mod, uint linnum)
|
|
19 {
|
|
20 this.linnum = linnum;
|
|
21 this.filename = mod ? mod.srcfile.toChars() : null;
|
|
22 }
|
|
23
|
|
24 string toChars()
|
|
25 {
|
|
26 scope OutBuffer buf = new OutBuffer();
|
|
27
|
|
28 if (filename !is null) {
|
|
29 buf.printf("%s", filename);
|
|
30 }
|
|
31
|
|
32 if (linnum) {
|
|
33 buf.printf("(%d)", linnum);
|
|
34 buf.writeByte(0);
|
|
35 }
|
|
36
|
|
37 return buf.extractString();
|
|
38 }
|
|
39
|
|
40 bool equals(ref const(Loc) loc)
|
|
41 {
|
|
42 assert(false);
|
|
43 }
|
178
|
44 }
|