annotate dmd/TypeSArray.d @ 41:f23312cb6f2e

TypeSArray.syntaxCopy & TypeSArray.resolve implemented
author korDen
date Sat, 21 Aug 2010 07:17:13 +0400
parents 832f71e6f96c
children b7d29f613539
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TypeSArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.TypeArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Argument;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TypeStruct;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.TypeTuple;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.TupleDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.TOK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.TypeDArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.TypePointer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.WANT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 import dmd.TypeInfoDeclaration;
41
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
27 import dmd.ScopeDsymbol;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
28 import dmd.ArrayScopeSymbol;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.Id;
41
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
32 import dmd.IndexExp;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import dmd.type.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 import dmd.backend.dt_t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 import dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 import dmd.backend.DT;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 // Static array, one with a fixed dimension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 class TypeSArray : TypeArray
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 Expression dim;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 this(Type t, Expression dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 super(TY.Tsarray, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 //printf("TypeSArray(%s)\n", dim.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 this.dim = dim;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 Type syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
41
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
64 Type t = next.syntaxCopy();
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
65 Expression e = dim.syntaxCopy();
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
66 t = new TypeSArray(t, e);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
67 t.mod = mod;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
68 return t;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 ulong size(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 if (!dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 return Type.size(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 long sz = dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 long n, n2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 n = next.size();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 n2 = n * sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 if (n && (n2 / n) != sz)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 goto Loverflow;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 sz = n2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 return sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 Loverflow:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 error(loc, "index %jd overflow for static array", sz);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 uint alignsize()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 return next.alignsize();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 Type semantic(Loc loc, Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 //printf("TypeSArray.semantic() %s\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 Dsymbol s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 next.resolve(loc, sc, &e, &t, &s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 if (dim && s && s.isTupleDeclaration())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 TupleDeclaration sd = s.isTupleDeclaration();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 dim = semanticLength(sc, sd, dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 dim = dim.optimize(WANT.WANTvalue | WANT.WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 ulong d = dim.toUInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 if (d >= sd.objects.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 { error(loc, "tuple index %ju exceeds %u", d, sd.objects.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 return Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 ///Object o = cast(Object)sd.objects.data[(size_t)d];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 ///if (o.dyncast() != DYNCAST_TYPE)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 ///{
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 /// error(loc, "%s is not a type", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 /// return Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 ///t = cast(Type)o;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 t = cast(Type)sd.objects.data[cast(size_t)d];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 if (t is null) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 error(loc, "%s is not a type", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 return Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 return t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 next = next.semantic(loc,sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 transitive();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 Type tbn = next.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 if (dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 long n, n2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 dim = semanticLength(sc, tbn, dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 dim = dim.optimize(WANT.WANTvalue | WANT.WANTinterpret);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 if (sc && sc.parameterSpecialization && dim.op == TOK.TOKvar &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 (cast(VarExp)dim).var.storage_class & STC.STCtemplateparameter)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 /* It could be a template parameter N which has no value yet:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 * template Foo(T : T[N], size_t N);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 return this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 long d1 = dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 dim = dim.castTo(sc, tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 dim = dim.optimize(WANT.WANTvalue);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 long d2 = dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 if (d1 != d2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 goto Loverflow;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 if (tbn.isintegral() ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 tbn.isfloating() ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 tbn.ty == TY.Tpointer ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 tbn.ty == TY.Tarray ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 tbn.ty == TY.Tsarray ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 tbn.ty == TY.Taarray ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 tbn.ty == TY.Tclass)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 /* Only do this for types that don't need to have semantic()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 * run on them for the size, since they may be forward referenced.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 n = tbn.size(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 n2 = n * d2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 if (cast(int)n2 < 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 goto Loverflow;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 if (n2 >= 0x1000000) // put a 'reasonable' limit on it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 goto Loverflow;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 if (n && n2 / n != d2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 Loverflow:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 error(loc, "index %jd overflow for static array", d1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 dim = new IntegerExp(Loc(0), 1, tsize_t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 switch (tbn.ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 case TY.Ttuple:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 { // Index the tuple to get the type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 assert(dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 TypeTuple tt = cast(TypeTuple)tbn;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 ulong d = dim.toUInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 if (d >= tt.arguments.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 error(loc, "tuple index %ju exceeds %u", d, tt.arguments.dim);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 return Type.terror;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 Argument arg = cast(Argument)tt.arguments.data[cast(size_t)d];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 return arg.type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 case TY.Tstruct:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 { TypeStruct ts = cast(TypeStruct)tbn;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 if (ts.sym.isnested)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 error(loc, "cannot have array of inner structs %s", ts.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 case TY.Tfunction:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 case TY.Tnone:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 error(loc, "can't have array of %s", tbn.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 tbn = next = tint32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 default: ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 if (tbn.isauto())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 error(loc, "cannot have array of auto %s", tbn.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 return merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 {
41
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
225 //printf("TypeSArray.resolve() %s\n", toChars());
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
226 next.resolve(loc, sc, pe, pt, ps);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
227 //printf("s = %p, e = %p, t = %p\n", *ps, *pe, *pt);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
228 if (*pe)
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
229 {
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
230 // It's really an index expression
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
231 Expression e = new IndexExp(loc, *pe, dim);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
232 *pe = e;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
233 }
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
234 else if (*ps)
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
235 {
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
236 Dsymbol s = *ps;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
237 TupleDeclaration td = s.isTupleDeclaration();
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
238 if (td)
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
239 {
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
240 ScopeDsymbol sym = new ArrayScopeSymbol(sc, td);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
241 sym.parent = sc.scopesym;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
242 sc = sc.push(sym);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
243
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
244 dim = dim.semantic(sc);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
245 dim = dim.optimize(WANTvalue | WANTinterpret);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
246 ulong d = dim.toUInteger();
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
247
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
248 sc = sc.pop();
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
249
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
250 if (d >= td.objects.dim)
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
251 {
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
252 error(loc, "tuple index %ju exceeds %u", d, td.objects.dim);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
253 goto Ldefault;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
254 }
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
255 Object o = cast(Object)td.objects.data[cast(size_t)d];
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
256 if ((*ps = isDsymbol(o)) !is null) /// !
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
257 {
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
258 return;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
259 }
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
260 if ((*pe = isExpression(o)) !is null) /// !
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
261 {
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
262 return;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
263 }
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
264
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
265 /* Create a new TupleDeclaration which
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
266 * is a slice [d..d+1] out of the old one.
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
267 * Do it this way because TemplateInstance.semanticTiargs()
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
268 * can handle unresolved Objects this way.
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
269 */
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
270 Objects objects = new Objects;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
271 objects.setDim(1);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
272 objects.data[0] = cast(void*)o;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
273
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
274 TupleDeclaration tds = new TupleDeclaration(loc, td.ident, objects);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
275 *ps = tds;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
276 }
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
277 else
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
278 goto Ldefault;
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
279 }
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
280 else
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
281 {
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
282 Ldefault:
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
283 Type.resolve(loc, sc, pe, pt, ps);
f23312cb6f2e TypeSArray.syntaxCopy & TypeSArray.resolve implemented
korDen
parents: 12
diff changeset
284 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 void toDecoBuffer(OutBuffer buf, int flag)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 Type.toDecoBuffer(buf, flag);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 if (dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 //buf.printf("%ju", dim.toInteger()); ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 buf.printf("%s", dim.toInteger());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 if (next)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 /* Note that static arrays are value types, so
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 * for a parameter, propagate the 0x100 to the next
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 * level, since for T[4][3], any const should apply to the T,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 * not the [4].
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 next.toDecoBuffer(buf, (flag & 0x100) ? flag : mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 Expression dotExp(Scope sc, Expression e, Identifier ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 printf("TypeSArray.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 if (ident == Id.length)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 e = dim;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 else if (ident == Id.ptr)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 e = e.castTo(sc, next.pointerTo());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 e = TypeArray.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
327 bool isString()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 bool isZeroInit(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 return next.isZeroInit(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 uint memalign(uint salign)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 return next.memalign(salign);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 MATCH constConv(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 MATCH implicitConvTo(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 //printf("TypeSArray.implicitConvTo(to = %s) this = %s\n", to.toChars(), toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 // Allow implicit conversion of static array to pointer or dynamic array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 if (IMPLICIT_ARRAY_TO_PTR && to.ty == Tpointer)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 TypePointer tp = cast(TypePointer)to;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 if (next.mod != tp.next.mod && tp.next.mod != MODconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 return MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 if (tp.next.ty == Tvoid || next.constConv(tp.next) != MATCHnomatch)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 return MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 return MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 if (to.ty == Tarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 int offset = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 TypeDArray ta = cast(TypeDArray)to;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 if (next.mod != ta.next.mod && ta.next.mod != MODconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 return MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 if (next.equals(ta.next) ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 next.implicitConvTo(ta.next) >= MATCHconst ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 (ta.next.isBaseOf(next, &offset) && offset == 0) ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 ta.next.ty == Tvoid
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 return MATCHconvert;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 return MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 if (to.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 if (this == to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 return MATCHexact;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 TypeSArray tsa = cast(TypeSArray)to;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 if (dim.equals(tsa.dim))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 /* Since static arrays are value types, allow
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 * conversions from const elements to non-const
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 * ones, just like we allow conversion from const int
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 * to int.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 MATCH m = next.implicitConvTo(tsa.next);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 if (m >= MATCHconst)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 if (mod != to.mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 m = MATCHconst;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401 return m;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 return MATCHnomatch;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 Expression defaultInit(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 version (LOGDEFAULTINIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 printf("TypeSArray.defaultInit() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 return next.defaultInit(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 dt_t** toDt(dt_t** pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 return toDtElem(pdt, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 dt_t** toDtElem(dt_t** pdt, Expression e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 int i;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 //printf("TypeSArray::toDtElem()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 uint len = cast(uint)dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 if (len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 while (*pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 pdt = &((*pdt).DTnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 Type tnext = next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 Type tbn = tnext.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 while (tbn.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 TypeSArray tsa = cast(TypeSArray)tbn;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 len *= tsa.dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 tnext = tbn.nextOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 tbn = tnext.toBasetype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 if (!e) // if not already supplied
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 e = tnext.defaultInit(Loc(0)); // use default initializer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 if (tbn.ty == Tstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 tnext.toDt(pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 e.toDt(pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447 dt_optimize(*pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 if ((*pdt).dt == DT_azeros && !(*pdt).DTnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 (*pdt).DTazeros *= len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451 pdt = &((*pdt).DTnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 else if ((*pdt).dt == DT_1byte && (*pdt).DTonebyte == 0 && !(*pdt).DTnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 (*pdt).dt = DT_azeros;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 (*pdt).DTazeros = len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 pdt = &((*pdt).DTnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 else if (e.op != TOKstring)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 for (i = 1; i < len; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 if (tbn.ty == Tstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 pdt = tnext.toDt(pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 while (*pdt)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 pdt = &((*pdt).DTnext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 pdt = e.toDt(pdt);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 return pdt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 TypeInfoDeclaration getTypeInfoDeclaration()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 Expression toExpression()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 bool hasPointers()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 return next.hasPointers();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 void toCppMangle(OutBuffer buf, CppMangleState* cms)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 type* toCtype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 if (!ctype)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 type* tn = next.toCtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 ctype = type_allocn(TYarray, tn);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 ctype.Tdim = cast(uint)dim.toInteger();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 return ctype;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 type* toCParamtype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 // arrays are passed as pointers
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 return next.pointerTo().toCtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 }