72
|
1 module dmd.TypeExp;
|
|
2
|
|
3 import dmd.Expression;
|
104
|
4 import dmd.backend.TYM;
|
|
5 import dmd.backend.Util;
|
72
|
6 import dmd.backend.elem;
|
|
7 import dmd.Type;
|
|
8 import dmd.OutBuffer;
|
|
9 import dmd.Loc;
|
|
10 import dmd.Scope;
|
|
11 import dmd.IRState;
|
|
12 import dmd.HdrGenState;
|
|
13 import dmd.TOK;
|
|
14
|
0
|
15 class TypeExp : Expression
|
|
16 {
|
|
17 this(Loc loc, Type type)
|
|
18 {
|
72
|
19 super(loc, TOK.TOKtype, TypeExp.sizeof);
|
|
20 //printf("TypeExp::TypeExp(%s)\n", type->toChars());
|
0
|
21 this.type = type;
|
|
22 }
|
72
|
23
|
|
24 version (DumbClone) {
|
|
25 } else {
|
|
26 Type clone()
|
|
27 {
|
|
28 assert(false);
|
|
29 }
|
0
|
30 }
|
72
|
31 override Expression syntaxCopy()
|
0
|
32 {
|
|
33 //printf("TypeExp.syntaxCopy()\n");
|
|
34 return new TypeExp(loc, type.syntaxCopy());
|
|
35 }
|
|
36
|
72
|
37 override Expression semantic(Scope sc)
|
0
|
38 {
|
72
|
39 //printf("TypeExp::semantic(%s)\n", type->toChars());
|
|
40 type = type.semantic(loc, sc);
|
0
|
41 return this;
|
|
42 }
|
|
43
|
72
|
44 override void rvalue()
|
0
|
45 {
|
104
|
46 error("type %s has no value", toChars());
|
0
|
47 }
|
|
48
|
72
|
49 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
0
|
50 {
|
72
|
51 type.toCBuffer(buf, null, hgs);
|
0
|
52 }
|
|
53
|
72
|
54 override Expression optimize(int result)
|
0
|
55 {
|
|
56 return this;
|
|
57 }
|
|
58
|
72
|
59 override elem* toElem(IRState* irs)
|
0
|
60 {
|
104
|
61 debug
|
|
62 writef("TypeExp.toElem()\n");
|
|
63
|
|
64 error("type %s is not an expression", toChars());
|
|
65 return el_long(TYint, 0);
|
0
|
66 }
|
|
67 }
|
|
68
|