comparison dmd2/module.c @ 1526:54b3c1394d62

Merged dmdfe 2.031.
author Robert Clipsham <robert@octarineparrot.com>
date Tue, 07 Jul 2009 02:26:11 +0100
parents 638d16625da2
children
comparison
equal deleted inserted replaced
1525:d28cd7c45267 1526:54b3c1394d62
97 insearch = 0; 97 insearch = 0;
98 searchCacheIdent = NULL; 98 searchCacheIdent = NULL;
99 searchCacheSymbol = NULL; 99 searchCacheSymbol = NULL;
100 searchCacheFlags = 0; 100 searchCacheFlags = 0;
101 semanticstarted = 0; 101 semanticstarted = 0;
102 semanticdone = 0; 102 semanticRun = 0;
103 decldefs = NULL; 103 decldefs = NULL;
104 vmoduleinfo = NULL; 104 vmoduleinfo = NULL;
105 #if IN_DMD 105 #if IN_DMD
106 massert = NULL; 106 massert = NULL;
107 marray = NULL; 107 marray = NULL;
768 } 768 }
769 769
770 // Add all symbols into module's symbol table 770 // Add all symbols into module's symbol table
771 symtab = new DsymbolTable(); 771 symtab = new DsymbolTable();
772 for (i = 0; i < members->dim; i++) 772 for (i = 0; i < members->dim; i++)
773 { Dsymbol *s; 773 { Dsymbol *s = (Dsymbol *)members->data[i];
774
775 s = (Dsymbol *)members->data[i];
776 s->addMember(NULL, sc->scopesym, 1); 774 s->addMember(NULL, sc->scopesym, 1);
775 }
776
777 /* Set scope for the symbols so that if we forward reference
778 * a symbol, it can possibly be resolved on the spot.
779 * If this works out well, it can be extended to all modules
780 * before any semantic() on any of them.
781 */
782 for (i = 0; i < members->dim; i++)
783 { Dsymbol *s = (Dsymbol *)members->data[i];
784 s->setScope(sc);
777 } 785 }
778 786
779 // Pass 1 semantic routines: do public side of the definition 787 // Pass 1 semantic routines: do public side of the definition
780 for (i = 0; i < members->dim; i++) 788 for (i = 0; i < members->dim; i++)
781 { Dsymbol *s; 789 { Dsymbol *s = (Dsymbol *)members->data[i];
782 790
783 s = (Dsymbol *)members->data[i];
784 //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars()); 791 //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars());
785 s->semantic(sc); 792 s->semantic(sc);
786 runDeferredSemantic(); 793 runDeferredSemantic();
787 } 794 }
788 795
789 sc = sc->pop(); 796 sc = sc->pop();
790 sc->pop(); 797 sc->pop(); // 2 pops because Scope::createGlobal() created 2
791 semanticdone = semanticstarted; 798 semanticRun = semanticstarted;
792 //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent); 799 //printf("-Module::semantic(this = %p, '%s'): parent = %p\n", this, toChars(), parent);
793 } 800 }
794 801
795 void Module::semantic2(Scope* unused_sc) 802 void Module::semantic2(Scope* unused_sc)
796 { int i; 803 { int i;
825 s->semantic2(sc); 832 s->semantic2(sc);
826 } 833 }
827 834
828 sc = sc->pop(); 835 sc = sc->pop();
829 sc->pop(); 836 sc->pop();
830 semanticdone = semanticstarted; 837 semanticRun = semanticstarted;
831 //printf("-Module::semantic2('%s'): parent = %p\n", toChars(), parent); 838 //printf("-Module::semantic2('%s'): parent = %p\n", toChars(), parent);
832 } 839 }
833 840
834 void Module::semantic3(Scope* unused_sc) 841 void Module::semantic3(Scope* unused_sc)
835 { int i; 842 { int i;
855 s->semantic3(sc); 862 s->semantic3(sc);
856 } 863 }
857 864
858 sc = sc->pop(); 865 sc = sc->pop();
859 sc->pop(); 866 sc->pop();
860 semanticdone = semanticstarted; 867 semanticRun = semanticstarted;
861 } 868 }
862 869
863 void Module::inlineScan() 870 void Module::inlineScan()
864 { int i; 871 { int i;
865 872
880 //if (global.params.verbose) 887 //if (global.params.verbose)
881 //printf("inline scan symbol %s\n", s->toChars()); 888 //printf("inline scan symbol %s\n", s->toChars());
882 889
883 s->inlineScan(); 890 s->inlineScan();
884 } 891 }
885 semanticdone = semanticstarted; 892 semanticRun = semanticstarted;
886 } 893 }
887 894
888 /**************************************************** 895 /****************************************************
889 */ 896 */
890 897
1141 ((ScopeDsymbol *)p)->symtab = new DsymbolTable(); 1148 ((ScopeDsymbol *)p)->symtab = new DsymbolTable();
1142 } 1149 }
1143 else 1150 else
1144 { 1151 {
1145 assert(p->isPackage()); 1152 assert(p->isPackage());
1153 #if TARGET_NET //dot net needs modules and packages with same name
1154 #else
1146 if (p->isModule()) 1155 if (p->isModule())
1147 { p->error("module and package have the same name"); 1156 { p->error("module and package have the same name");
1148 fatal(); 1157 fatal();
1149 break; 1158 break;
1150 } 1159 }
1160 #endif
1151 } 1161 }
1152 parent = p; 1162 parent = p;
1153 dst = ((Package *)p)->symtab; 1163 dst = ((Package *)p)->symtab;
1154 if (ppkg && !*ppkg) 1164 if (ppkg && !*ppkg)
1155 *ppkg = (Package *)p; 1165 *ppkg = (Package *)p;