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