0
|
1 module dmd.TypeNext;
|
|
2
|
|
3 import dmd.Type;
|
|
4 import dmd.TY;
|
|
5 import dmd.OutBuffer;
|
|
6 import dmd.Loc;
|
|
7 import dmd.Scope;
|
|
8 import dmd.MATCH;
|
|
9 import dmd.MOD;
|
|
10
|
|
11 class TypeNext : Type
|
|
12 {
|
|
13 Type next;
|
|
14
|
|
15 this(TY ty, Type next)
|
|
16 {
|
|
17 super(ty);
|
|
18 this.next = next;
|
|
19 }
|
|
20 version (DumbClone) {
|
|
21 } else {
|
|
22 final TypeNext cloneTo(TypeNext t)
|
|
23 {
|
|
24 super.cloneTo(t);
|
|
25 return t;
|
|
26 }
|
|
27
|
|
28 TypeNext clone()
|
|
29 {
|
|
30 assert(this.classinfo == TypeNext.classinfo);
|
|
31 return cloneTo(new TypeNext(ty, next));
|
|
32 }
|
|
33 }
|
72
|
34 override void toDecoBuffer(OutBuffer buf, int flag)
|
0
|
35 {
|
|
36 super.toDecoBuffer(buf, flag);
|
|
37 assert(next !is this);
|
|
38 //printf("this = %p, ty = %d, next = %p, ty = %d\n", this, this.ty, next, next.ty);
|
|
39 next.toDecoBuffer(buf, (flag & 0x100) ? 0 : mod);
|
|
40 }
|
|
41
|
72
|
42 override void checkDeprecated(Loc loc, Scope sc)
|
0
|
43 {
|
|
44 Type.checkDeprecated(loc, sc);
|
|
45 if (next) // next can be null if TypeFunction and auto return type
|
|
46 next.checkDeprecated(loc, sc);
|
|
47 }
|
|
48
|
72
|
49 override Type reliesOnTident()
|
0
|
50 {
|
|
51 return next.reliesOnTident();
|
|
52 }
|
|
53
|
72
|
54 override Type nextOf()
|
0
|
55 {
|
|
56 return next;
|
|
57 }
|
|
58
|
72
|
59 override Type makeConst()
|
0
|
60 {
|
|
61 //printf("TypeNext::makeConst() %p, %s\n", this, toChars());
|
|
62 if (cto)
|
|
63 {
|
|
64 assert(cto.mod == MOD.MODconst);
|
|
65 return cto;
|
|
66 }
|
|
67
|
|
68 TypeNext t = cast(TypeNext)super.makeConst();
|
|
69 if (ty != TY.Tfunction && ty != TY.Tdelegate &&
|
|
70 (next.deco || next.ty == TY.Tfunction) &&
|
|
71 !next.isInvariant() && !next.isConst())
|
|
72 {
|
|
73 if (next.isShared())
|
|
74 t.next = next.sharedConstOf();
|
|
75 else
|
|
76 t.next = next.constOf();
|
|
77 }
|
|
78 //printf("TypeNext::makeConst() returns %p, %s\n", t, t.toChars());
|
|
79 return t;
|
|
80 }
|
|
81
|
72
|
82 override Type makeInvariant()
|
0
|
83 {
|
|
84 //printf("TypeNext::makeInvariant() %s\n", toChars());
|
|
85 if (ito)
|
|
86 {
|
|
87 assert(ito.isInvariant());
|
|
88 return ito;
|
|
89 }
|
|
90 TypeNext t = cast(TypeNext)Type.makeInvariant();
|
|
91 if (ty != TY.Tfunction && ty != TY.Tdelegate && (next.deco || next.ty == TY.Tfunction) && !next.isInvariant())
|
|
92 {
|
|
93 t.next = next.invariantOf();
|
|
94 }
|
|
95 return t;
|
|
96 }
|
|
97
|
72
|
98 override Type makeShared()
|
0
|
99 {
|
|
100 //printf("TypeNext::makeShared() %s\n", toChars());
|
|
101 if (sto)
|
|
102 {
|
|
103 assert(sto.mod == MODshared);
|
|
104 return sto;
|
|
105 }
|
|
106 TypeNext t = cast(TypeNext)Type.makeShared();
|
|
107 if (ty != Tfunction && ty != Tdelegate &&
|
|
108 (next.deco || next.ty == Tfunction) &&
|
|
109 !next.isInvariant() && !next.isShared())
|
|
110 {
|
|
111 if (next.isConst())
|
|
112 t.next = next.sharedConstOf();
|
|
113 else
|
|
114 t.next = next.sharedOf();
|
|
115 }
|
|
116
|
|
117 //printf("TypeNext::makeShared() returns %p, %s\n", t, t.toChars());
|
|
118 return t;
|
|
119 }
|
|
120
|
72
|
121 override Type makeSharedConst()
|
0
|
122 {
|
|
123 assert(false);
|
|
124 }
|
|
125
|
72
|
126 override MATCH constConv(Type to)
|
0
|
127 {
|
56
|
128 MATCH m = Type.constConv(to);
|
|
129
|
|
130 if (m == MATCHconst && next.constConv((cast(TypeNext)to).next) == MATCHnomatch)
|
|
131 m = MATCHnomatch;
|
|
132 return m;
|
0
|
133 }
|
|
134
|
|
135 void transitive()
|
|
136 {
|
|
137 /* Invoke transitivity of type attributes
|
|
138 */
|
|
139 next = next.addMod(mod);
|
|
140 }
|
72
|
141 }
|