comparison dmd/AggregateDeclaration.d @ 77:ad4792a1cfd6

more D-ification container accessing
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Sun, 29 Aug 2010 14:36:55 +0100
parents 7e0d548de9e6
children 43073c7c7769
comparison
equal deleted inserted replaced
74:7e0d548de9e6 77:ad4792a1cfd6
196 return; 196 return;
197 } 197 }
198 if (members) 198 if (members)
199 { 199 {
200 sc = sc.push(this); 200 sc = sc.push(this);
201 for (size_t i = 0; i < members.dim; i++) 201 foreach(Dsymbol s; members)
202 {
203 Dsymbol s = cast(Dsymbol)members.data[i];
204 s.semantic2(sc); 202 s.semantic2(sc);
205 }
206 sc.pop(); 203 sc.pop();
207 } 204 }
208 } 205 }
209 206
210 override void semantic3(Scope sc) 207 override void semantic3(Scope sc)
213 210
214 //printf("AggregateDeclaration.semantic3(%s)\n", toChars()); 211 //printf("AggregateDeclaration.semantic3(%s)\n", toChars());
215 if (members) 212 if (members)
216 { 213 {
217 sc = sc.push(this); 214 sc = sc.push(this);
218 for (i = 0; i < members.dim; i++) 215 foreach(Dsymbol s; members)
219 {
220 Dsymbol s = cast(Dsymbol)members.data[i];
221 s.semantic3(sc); 216 s.semantic3(sc);
222 }
223 sc.pop(); 217 sc.pop();
224 } 218 }
225 } 219 }
226 220
227 override void inlineScan() 221 override void inlineScan()
229 int i; 223 int i;
230 224
231 //printf("AggregateDeclaration.inlineScan(%s)\n", toChars()); 225 //printf("AggregateDeclaration.inlineScan(%s)\n", toChars());
232 if (members) 226 if (members)
233 { 227 {
234 for (i = 0; i < members.dim; i++) 228 foreach(Dsymbol s; members)
235 { 229 {
236 Dsymbol s = cast(Dsymbol)members.data[i];
237 //printf("inline scan aggregate symbol '%s'\n", s.toChars()); 230 //printf("inline scan aggregate symbol '%s'\n", s.toChars());
238 s.inlineScan(); 231 s.inlineScan();
239 } 232 }
240 } 233 }
241 } 234 }
415 { 408 {
416 case 0: 409 case 0:
417 return null; 410 return null;
418 411
419 case 1: 412 case 1:
420 return cast(FuncDeclaration)dtors.data[0]; 413 return cast(FuncDeclaration)dtors[0];
421 414
422 default: 415 default:
423 e = null; 416 e = null;
424 for (size_t i = 0; i < dtors.dim; i++) 417 foreach(FuncDeclaration fd; dtors)
425 { 418 {
426 FuncDeclaration fd = cast(FuncDeclaration)dtors.data[i];
427 Expression ex = new ThisExp(Loc(0)); 419 Expression ex = new ThisExp(Loc(0));
428 ex = new DotVarExp(Loc(0), ex, fd, 0); 420 ex = new DotVarExp(Loc(0), ex, fd, 0);
429 ex = new CallExp(Loc(0), ex); 421 ex = new CallExp(Loc(0), ex);
430 e = Expression.combine(ex, e); 422 e = Expression.combine(ex, e);
431 } 423 }
432 DtorDeclaration dd = new DtorDeclaration(Loc(0), Loc(0), Lexer.idPool("__aggrDtor")); 424 auto dd = new DtorDeclaration(Loc(0), Loc(0), Lexer.idPool("__aggrDtor"));
433 dd.fbody = new ExpStatement(Loc(0), e); 425 dd.fbody = new ExpStatement(Loc(0), e);
434 members.push(dd); 426 members.push(dd);
435 dd.semantic(sc); 427 dd.semantic(sc);
436 return dd; 428 return dd;
437 } 429 }