72
|
1 module dmd.FileInitExp;
|
|
2
|
114
|
3 import dmd.common;
|
72
|
4 import dmd.Expression;
|
|
5 import dmd.Loc;
|
|
6 import dmd.Scope;
|
|
7 import dmd.DefaultInitExp;
|
|
8 import dmd.StringExp;
|
|
9 import dmd.TOK;
|
|
10 import dmd.Util;
|
|
11 import dmd.Type;
|
|
12
|
|
13 class FileInitExp : DefaultInitExp
|
|
14 {
|
|
15 this(Loc loc)
|
|
16 {
|
|
17 super(loc, TOK.TOKfile, this.sizeof);
|
|
18 }
|
|
19
|
|
20 override Expression semantic(Scope sc)
|
|
21 {
|
|
22 type = Type.tchar.invariantOf().arrayOf();
|
|
23 return this;
|
|
24 }
|
|
25
|
|
26 override Expression resolve(Loc loc, Scope sc)
|
|
27 {
|
|
28 //printf("FileInitExp::resolve() %.*s\n", toChars());
|
|
29 string s = loc.filename ? loc.filename : sc.module_.ident.toChars();
|
|
30 Expression e = new StringExp(loc, s);
|
|
31 e = e.semantic(sc);
|
|
32 e = e.castTo(sc, type);
|
|
33 return e;
|
|
34 }
|
|
35 }
|