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