annotate dmd/TypeNext.d @ 72:2e2a5c3f943a

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