Mercurial > projects > ldc
comparison dmd/arrayop.c @ 1607:207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
---
dmd/arrayop.c | 30 ++++----
dmd/arraytypes.h | 2 +-
dmd/class.c | 8 +-
dmd/declaration.c | 10 ++--
dmd/declaration.h | 16 ++--
dmd/doc.c | 12 ++--
dmd/dsymbol.c | 4 +-
dmd/expression.c | 48 +++++++-------
dmd/expression.h | 32 +++++-----
dmd/func.c | 78 +++++++++++-----------
dmd/init.c | 2 +-
dmd/interpret.c | 8 +-
dmd/mtype.c | 190 ++++++++++++++++++++++++++--------------------------
dmd/mtype.h | 32 +++++-----
dmd/opover.c | 34 +++++-----
dmd/parse.c | 40 ++++++------
dmd/parse.h | 2 +-
dmd/statement.c | 90 +++++++++++++-------------
dmd/statement.h | 14 ++--
dmd/struct.c | 8 +-
dmd/template.c | 30 ++++----
gen/functions.cpp | 10 ++--
gen/functions.h | 2 +-
gen/tocall.cpp | 10 ++--
gen/typinf.cpp | 6 +-
25 files changed, 359 insertions(+), 359 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:20 -0300 |
parents | def7a1d494fd |
children | 44b145be2ef5 |
comparison
equal
deleted
inserted
replaced
1606:1b24e9c7cc26 | 1607:207a8a438dea |
---|---|
251 * foreach (i; 0 .. p.length) for (size_t i = 0; i < p.length; i++) | 251 * foreach (i; 0 .. p.length) for (size_t i = 0; i < p.length; i++) |
252 * loopbody; | 252 * loopbody; |
253 * return p; | 253 * return p; |
254 */ | 254 */ |
255 | 255 |
256 Arguments *fparams = new Arguments(); | 256 Parameters *fparams = new Parameters(); |
257 Expression *loopbody = buildArrayLoop(fparams); | 257 Expression *loopbody = buildArrayLoop(fparams); |
258 Argument *p = (Argument *)fparams->data[0 /*fparams->dim - 1*/]; | 258 Parameter *p = (Parameter *)fparams->data[0 /*fparams->dim - 1*/]; |
259 #if DMDV1 | 259 #if DMDV1 |
260 // for (size_t i = 0; i < p.length; i++) | 260 // for (size_t i = 0; i < p.length; i++) |
261 Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t)); | 261 Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t)); |
262 Dsymbol *d = new VarDeclaration(0, Type::tsize_t, Id::p, init); | 262 Dsymbol *d = new VarDeclaration(0, Type::tsize_t, Id::p, init); |
263 Statement *s1 = new ForStatement(0, | 263 Statement *s1 = new ForStatement(0, |
266 new PostExp(TOKplusplus, 0, new IdentifierExp(0, Id::p)), | 266 new PostExp(TOKplusplus, 0, new IdentifierExp(0, Id::p)), |
267 new ExpStatement(0, loopbody)); | 267 new ExpStatement(0, loopbody)); |
268 #else | 268 #else |
269 // foreach (i; 0 .. p.length) | 269 // foreach (i; 0 .. p.length) |
270 Statement *s1 = new ForeachRangeStatement(0, TOKforeach, | 270 Statement *s1 = new ForeachRangeStatement(0, TOKforeach, |
271 new Argument(0, NULL, Id::p, NULL), | 271 new Parameter(0, NULL, Id::p, NULL), |
272 new IntegerExp(0, 0, Type::tint32), | 272 new IntegerExp(0, 0, Type::tint32), |
273 new ArrayLengthExp(0, new IdentifierExp(0, p->ident)), | 273 new ArrayLengthExp(0, new IdentifierExp(0, p->ident)), |
274 new ExpStatement(0, loopbody)); | 274 new ExpStatement(0, loopbody)); |
275 #endif | 275 #endif |
276 Statement *s2 = new ReturnStatement(0, new IdentifierExp(0, p->ident)); | 276 Statement *s2 = new ReturnStatement(0, new IdentifierExp(0, p->ident)); |
412 /****************************************** | 412 /****************************************** |
413 * Construct the inner loop for the array operation function, | 413 * Construct the inner loop for the array operation function, |
414 * and build the parameter list. | 414 * and build the parameter list. |
415 */ | 415 */ |
416 | 416 |
417 Expression *Expression::buildArrayLoop(Arguments *fparams) | 417 Expression *Expression::buildArrayLoop(Parameters *fparams) |
418 { | 418 { |
419 Identifier *id = Identifier::generateId("c", fparams->dim); | 419 Identifier *id = Identifier::generateId("c", fparams->dim); |
420 Argument *param = new Argument(0, type, id, NULL); | 420 Parameter *param = new Parameter(0, type, id, NULL); |
421 fparams->shift(param); | 421 fparams->shift(param); |
422 Expression *e = new IdentifierExp(0, id); | 422 Expression *e = new IdentifierExp(0, id); |
423 return e; | 423 return e; |
424 } | 424 } |
425 | 425 |
426 Expression *CastExp::buildArrayLoop(Arguments *fparams) | 426 Expression *CastExp::buildArrayLoop(Parameters *fparams) |
427 { | 427 { |
428 Type *tb = type->toBasetype(); | 428 Type *tb = type->toBasetype(); |
429 if (tb->ty == Tarray || tb->ty == Tsarray) | 429 if (tb->ty == Tarray || tb->ty == Tsarray) |
430 { | 430 { |
431 return e1->buildArrayLoop(fparams); | 431 return e1->buildArrayLoop(fparams); |
432 } | 432 } |
433 else | 433 else |
434 return Expression::buildArrayLoop(fparams); | 434 return Expression::buildArrayLoop(fparams); |
435 } | 435 } |
436 | 436 |
437 Expression *SliceExp::buildArrayLoop(Arguments *fparams) | 437 Expression *SliceExp::buildArrayLoop(Parameters *fparams) |
438 { | 438 { |
439 Identifier *id = Identifier::generateId("p", fparams->dim); | 439 Identifier *id = Identifier::generateId("p", fparams->dim); |
440 Argument *param = new Argument(STCconst, type, id, NULL); | 440 Parameter *param = new Parameter(STCconst, type, id, NULL); |
441 fparams->shift(param); | 441 fparams->shift(param); |
442 Expression *e = new IdentifierExp(0, id); | 442 Expression *e = new IdentifierExp(0, id); |
443 Expressions *arguments = new Expressions(); | 443 Expressions *arguments = new Expressions(); |
444 Expression *index = new IdentifierExp(0, Id::p); | 444 Expression *index = new IdentifierExp(0, Id::p); |
445 arguments->push(index); | 445 arguments->push(index); |
446 e = new ArrayExp(0, e, arguments); | 446 e = new ArrayExp(0, e, arguments); |
447 return e; | 447 return e; |
448 } | 448 } |
449 | 449 |
450 Expression *AssignExp::buildArrayLoop(Arguments *fparams) | 450 Expression *AssignExp::buildArrayLoop(Parameters *fparams) |
451 { | 451 { |
452 /* Evaluate assign expressions right to left | 452 /* Evaluate assign expressions right to left |
453 */ | 453 */ |
454 Expression *ex2 = e2->buildArrayLoop(fparams); | 454 Expression *ex2 = e2->buildArrayLoop(fparams); |
455 #if DMDV2 | 455 #if DMDV2 |
459 * which cannot be implicitly cast to byte. | 459 * which cannot be implicitly cast to byte. |
460 */ | 460 */ |
461 ex2 = new CastExp(0, ex2, e1->type->nextOf()); | 461 ex2 = new CastExp(0, ex2, e1->type->nextOf()); |
462 #endif | 462 #endif |
463 Expression *ex1 = e1->buildArrayLoop(fparams); | 463 Expression *ex1 = e1->buildArrayLoop(fparams); |
464 Argument *param = (Argument *)fparams->data[0]; | 464 Parameter *param = (Parameter *)fparams->data[0]; |
465 param->storageClass = 0; | 465 param->storageClass = 0; |
466 Expression *e = new AssignExp(0, ex1, ex2); | 466 Expression *e = new AssignExp(0, ex1, ex2); |
467 return e; | 467 return e; |
468 } | 468 } |
469 | 469 |
470 #define X(Str) \ | 470 #define X(Str) \ |
471 Expression *Str##AssignExp::buildArrayLoop(Arguments *fparams) \ | 471 Expression *Str##AssignExp::buildArrayLoop(Parameters *fparams) \ |
472 { \ | 472 { \ |
473 /* Evaluate assign expressions right to left \ | 473 /* Evaluate assign expressions right to left \ |
474 */ \ | 474 */ \ |
475 Expression *ex2 = e2->buildArrayLoop(fparams); \ | 475 Expression *ex2 = e2->buildArrayLoop(fparams); \ |
476 Expression *ex1 = e1->buildArrayLoop(fparams); \ | 476 Expression *ex1 = e1->buildArrayLoop(fparams); \ |
477 Argument *param = (Argument *)fparams->data[0]; \ | 477 Parameter *param = (Parameter *)fparams->data[0]; \ |
478 param->storageClass = 0; \ | 478 param->storageClass = 0; \ |
479 Expression *e = new Str##AssignExp(0, ex1, ex2); \ | 479 Expression *e = new Str##AssignExp(0, ex1, ex2); \ |
480 return e; \ | 480 return e; \ |
481 } | 481 } |
482 | 482 |
489 X(And) | 489 X(And) |
490 X(Or) | 490 X(Or) |
491 | 491 |
492 #undef X | 492 #undef X |
493 | 493 |
494 Expression *NegExp::buildArrayLoop(Arguments *fparams) | 494 Expression *NegExp::buildArrayLoop(Parameters *fparams) |
495 { | 495 { |
496 Expression *ex1 = e1->buildArrayLoop(fparams); | 496 Expression *ex1 = e1->buildArrayLoop(fparams); |
497 Expression *e = new NegExp(0, ex1); | 497 Expression *e = new NegExp(0, ex1); |
498 return e; | 498 return e; |
499 } | 499 } |
500 | 500 |
501 Expression *ComExp::buildArrayLoop(Arguments *fparams) | 501 Expression *ComExp::buildArrayLoop(Parameters *fparams) |
502 { | 502 { |
503 Expression *ex1 = e1->buildArrayLoop(fparams); | 503 Expression *ex1 = e1->buildArrayLoop(fparams); |
504 Expression *e = new ComExp(0, ex1); | 504 Expression *e = new ComExp(0, ex1); |
505 return e; | 505 return e; |
506 } | 506 } |
507 | 507 |
508 #define X(Str) \ | 508 #define X(Str) \ |
509 Expression *Str##Exp::buildArrayLoop(Arguments *fparams) \ | 509 Expression *Str##Exp::buildArrayLoop(Parameters *fparams) \ |
510 { \ | 510 { \ |
511 /* Evaluate assign expressions left to right \ | 511 /* Evaluate assign expressions left to right \ |
512 */ \ | 512 */ \ |
513 Expression *ex1 = e1->buildArrayLoop(fparams); \ | 513 Expression *ex1 = e1->buildArrayLoop(fparams); \ |
514 Expression *ex2 = e2->buildArrayLoop(fparams); \ | 514 Expression *ex2 = e2->buildArrayLoop(fparams); \ |