comparison dmd/TemplateInstance.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
477 477
478 // Add members of template instance to template instance symbol table 478 // Add members of template instance to template instance symbol table
479 // parent = scope.scopesym; 479 // parent = scope.scopesym;
480 symtab = new DsymbolTable(); 480 symtab = new DsymbolTable();
481 bool memnum = false; 481 bool memnum = false;
482 for (int i = 0; i < members.dim; i++) 482 foreach(Dsymbol s; members)
483 { 483 {
484 Dsymbol s = cast(Dsymbol)members.data[i];
485 version (LOG) { 484 version (LOG) {
486 printf("\t[%d] adding member '%s' %p kind %s to '%s', memnum = %d\n", i, s.toChars(), s, s.kind(), this.toChars(), memnum); 485 printf("\t[%d] adding member '%s' %p kind %s to '%s', memnum = %d\n", i, s.toChars(), s, s.kind(), this.toChars(), memnum);
487 } 486 }
488 memnum |= s.addMember(scope_, this, memnum); 487 memnum |= s.addMember(scope_, this, memnum);
489 } 488 }
531 { 530 {
532 global.gag = 0; // ensure error message gets printed 531 global.gag = 0; // ensure error message gets printed
533 error("recursive expansion"); 532 error("recursive expansion");
534 fatal(); 533 fatal();
535 } 534 }
536 for (int i = 0; i < members.dim; i++) 535 foreach(Dsymbol s; members)
537 { 536 {
538 Dsymbol s = cast(Dsymbol)members.data[i];
539 //printf("\t[%d] semantic on '%s' %p kind %s in '%s'\n", i, s.toChars(), s, s.kind(), this.toChars()); 537 //printf("\t[%d] semantic on '%s' %p kind %s in '%s'\n", i, s.toChars(), s, s.kind(), this.toChars());
540 //printf("test: isnested = %d, sc2.parent = %s\n", isnested, sc2.parent.toChars()); 538 //printf("test: isnested = %d, sc2.parent = %s\n", isnested, sc2.parent.toChars());
541 // if (isnested) 539 // if (isnested)
542 // s.parent = sc.parent; 540 // s.parent = sc.parent;
543 //printf("test3: isnested = %d, s.parent = %s\n", isnested, s.parent.toChars()); 541 //printf("test3: isnested = %d, s.parent = %s\n", isnested, s.parent.toChars());
625 assert(sc); 623 assert(sc);
626 sc = sc.push(argsym); 624 sc = sc.push(argsym);
627 sc = sc.push(this); 625 sc = sc.push(this);
628 sc.tinst = this; 626 sc.tinst = this;
629 627
630 for (i = 0; i < members.dim; i++) 628 foreach(Dsymbol s; members)
631 { 629 {
632 Dsymbol s = cast(Dsymbol)members.data[i];
633 version (LOG) { 630 version (LOG) {
634 printf("\tmember '%s', kind = '%s'\n", s.toChars(), s.kind()); 631 printf("\tmember '%s', kind = '%s'\n", s.toChars(), s.kind());
635 } 632 }
636 s.semantic2(sc); 633 s.semantic2(sc);
637 } 634 }
658 { 655 {
659 sc = tempdecl.scope_; 656 sc = tempdecl.scope_;
660 sc = sc.push(argsym); 657 sc = sc.push(argsym);
661 sc = sc.push(this); 658 sc = sc.push(this);
662 sc.tinst = this; 659 sc.tinst = this;
663 for (int i = 0; i < members.dim; i++) 660 foreach(Dsymbol s; members)
664 {
665 Dsymbol s = cast(Dsymbol)members.data[i];
666 s.semantic3(sc); 661 s.semantic3(sc);
667 }
668 sc = sc.pop(); 662 sc = sc.pop();
669 sc.pop(); 663 sc.pop();
670 } 664 }
671 } 665 }
672 666
675 version (LOG) { 669 version (LOG) {
676 printf("TemplateInstance.inlineScan('%s')\n", toChars()); 670 printf("TemplateInstance.inlineScan('%s')\n", toChars());
677 } 671 }
678 if (!errors && members) 672 if (!errors && members)
679 { 673 {
680 for (int i = 0; i < members.dim; i++) 674 foreach(Dsymbol s; members)
681 {
682 Dsymbol s = cast(Dsymbol)members.data[i];
683 s.inlineScan(); 675 s.inlineScan();
684 }
685 } 676 }
686 } 677 }
687 678
688 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) 679 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
689 { 680 {
796 if (multiobj) 787 if (multiobj)
797 // Append to list of object files to be written later 788 // Append to list of object files to be written later
798 obj_append(this); 789 obj_append(this);
799 else 790 else
800 { 791 {
801 for (int i = 0; i < members.dim; i++) 792 foreach(Dsymbol s; members)
802 {
803 Dsymbol s = cast(Dsymbol)members.data[i];
804 s.toObjFile(multiobj); 793 s.toObjFile(multiobj);
805 }
806 } 794 }
807 } 795 }
808 } 796 }
809 797
810 // Internal 798 // Internal