Mercurial > projects > ddmd
comparison dmd/TypeNext.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | 51605de93870 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:10317f0c89a5 |
---|---|
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 } | |
34 void toDecoBuffer(OutBuffer buf, int flag) | |
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 | |
42 void checkDeprecated(Loc loc, Scope sc) | |
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 | |
49 Type reliesOnTident() | |
50 { | |
51 return next.reliesOnTident(); | |
52 } | |
53 | |
54 Type nextOf() | |
55 { | |
56 return next; | |
57 } | |
58 | |
59 Type makeConst() | |
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 | |
82 Type makeInvariant() | |
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 | |
98 Type makeShared() | |
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 | |
121 Type makeSharedConst() | |
122 { | |
123 assert(false); | |
124 } | |
125 | |
126 MATCH constConv(Type to) | |
127 { | |
128 assert(false); | |
129 } | |
130 | |
131 void transitive() | |
132 { | |
133 /* Invoke transitivity of type attributes | |
134 */ | |
135 next = next.addMod(mod); | |
136 } | |
137 } |