Changeset 901
- Timestamp:
- 06/29/08 18:40:28 (4 months ago)
- Files:
-
- branches/dmdfe-2.0/aggregate.h (modified) (2 diffs)
- branches/dmdfe-2.0/cast.c (modified) (1 diff)
- branches/dmdfe-2.0/declaration.c (modified) (4 diffs)
- branches/dmdfe-2.0/declaration.h (modified) (3 diffs)
- branches/dmdfe-2.0/e2ir.c (modified) (3 diffs)
- branches/dmdfe-2.0/expression.c (modified) (5 diffs)
- branches/dmdfe-2.0/init.c (modified) (1 diff)
- branches/dmdfe-2.0/lib.h (added)
- branches/dmdfe-2.0/libelf.c (added)
- branches/dmdfe-2.0/link.c (modified) (1 diff)
- branches/dmdfe-2.0/man.c (added)
- branches/dmdfe-2.0/mars.c (modified) (22 diffs)
- branches/dmdfe-2.0/mars.h (modified) (6 diffs)
- branches/dmdfe-2.0/module.c (modified) (3 diffs)
- branches/dmdfe-2.0/module.h (modified) (4 diffs)
- branches/dmdfe-2.0/mtype.c (modified) (5 diffs)
- branches/dmdfe-2.0/mtype.h (modified) (1 diff)
- branches/dmdfe-2.0/root.c (modified) (3 diffs)
- branches/dmdfe-2.0/root.h (modified) (1 diff)
- branches/dmdfe-2.0/stringtable.c (modified) (1 diff)
- branches/dmdfe-2.0/stringtable.h (modified) (1 diff)
- branches/dmdfe-2.0/template.c (modified) (10 diffs)
- branches/dmdfe-2.0/template.h (modified) (2 diffs)
- branches/dmdfe-2.0/toobj.c (modified) (17 diffs)
- branches/dmdfe-2.0/total.h (modified) (1 diff)
- branches/dmdfe-2.0/typinf.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmdfe-2.0/aggregate.h
r900 r901 107 107 { 108 108 int zeroInit; // !=0 if initialize with 0 fill 109 #if V2 109 110 int hasIdentityAssign; // !=0 if has identity opAssign 110 111 FuncDeclaration *cpctor; // generated copy-constructor, if any … … 112 113 FuncDeclarations postblits; // Array of postblit functions 113 114 FuncDeclaration *postblit; // aggregate postblit 115 #endif 114 116 115 117 StructDeclaration(Loc loc, Identifier *id); branches/dmdfe-2.0/cast.c
r900 r901 1515 1515 } 1516 1516 else if (t1->ty == Tclass || t2->ty == Tclass) 1517 { int i1; 1518 int i2; 1519 1520 i1 = e2->implicitConvTo(t1); 1521 i2 = e1->implicitConvTo(t2); 1522 1523 if (i1 && i2) 1524 { 1525 // We have the case of class vs. void*, so pick class 1526 if (t1->ty == Tpointer) 1527 i1 = 0; 1528 else if (t2->ty == Tpointer) 1529 i2 = 0; 1530 } 1531 1532 if (i2) 1533 { 1534 goto Lt2; 1535 } 1536 else if (i1) 1537 { 1538 goto Lt1; 1539 } 1540 else 1541 goto Lincompatible; 1517 { 1518 while (1) 1519 { 1520 int i1 = e2->implicitConvTo(t1); 1521 int i2 = e1->implicitConvTo(t2); 1522 1523 if (i1 && i2) 1524 { 1525 // We have the case of class vs. void*, so pick class 1526 if (t1->ty == Tpointer) 1527 i1 = 0; 1528 else if (t2->ty == Tpointer) 1529 i2 = 0; 1530 } 1531 1532 if (i2) 1533 { 1534 goto Lt2; 1535 } 1536 else if (i1) 1537 { 1538 goto Lt1; 1539 } 1540 else if (t1->ty == Tclass && t2->ty == Tclass) 1541 { TypeClass *tc1 = (TypeClass *)t1; 1542 TypeClass *tc2 = (TypeClass *)t2; 1543 1544 /* Pick 'tightest' type 1545 */ 1546 ClassDeclaration *cd1 = tc1->sym->baseClass; 1547 ClassDeclaration *cd2 = tc1->sym->baseClass; 1548 1549 if (cd1 && cd2) 1550 { t1 = cd1->type; 1551 t2 = cd2->type; 1552 } 1553 else if (cd1) 1554 t1 = cd1->type; 1555 else if (cd2) 1556 t2 = cd2->type; 1557 else 1558 goto Lincompatible; 1559 } 1560 else 1561 goto Lincompatible; 1562 } 1542 1563 } 1543 1564 else if (t1->ty == Tstruct && t2->ty == Tstruct) branches/dmdfe-2.0/declaration.c
r900 r901 949 949 !init->isVoidInitializer()) 950 950 { 951 Expression *e1;952 Type *t;953 int dim;954 955 951 //printf("fd = '%s', var = '%s'\n", fd->toChars(), toChars()); 956 952 if (!ei) … … 970 966 } 971 967 972 e1 = new VarExp(loc, this);973 974 t = type->toBasetype();968 Expression *e1 = new VarExp(loc, this); 969 970 Type *t = type->toBasetype(); 975 971 if (t->ty == Tsarray) 976 972 { … … 978 974 if (!ei->exp->implicitConvTo(type)) 979 975 { 980 dim = ((TypeSArray *)t)->dim->toInteger();976 int dim = ((TypeSArray *)t)->dim->toInteger(); 981 977 // If multidimensional static array, treat as one large array 982 978 while (1) … … 995 991 ei->exp = ei->exp->semantic(sc); 996 992 if (!ei->exp->implicitConvTo(type)) 997 ei->exp = new CastExp(loc, ei->exp, type); 993 { Type *ti = ei->exp->type->toBasetype(); 994 // Don't cast away invariant or mutability in initializer 995 if (!(ti->ty == Tstruct && t->toDsymbol(sc) == ti->toDsymbol(sc))) 996 ei->exp = new CastExp(loc, ei->exp, type); 997 } 998 998 } 999 999 ei->exp = new AssignExp(loc, e1, ei->exp); branches/dmdfe-2.0/declaration.h
r900 r901 371 371 { 372 372 TypeInfoConstDeclaration(Type *tinfo); 373 374 void toDt(dt_t **pdt);375 373 }; 376 374 … … 378 376 { 379 377 TypeInfoInvariantDeclaration(Type *tinfo); 380 381 void toDt(dt_t **pdt);382 378 }; 383 379 #endif … … 537 533 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } 538 534 char *kind(); 539 Symbol *toSymbol();540 535 }; 541 536 branches/dmdfe-2.0/e2ir.c
r900 r901 1055 1055 return Dsymbol_toElem(s, irs); 1056 1056 if (vd->isStatic() || vd->storage_class & STCextern) 1057 vd->toObjFile( );1057 vd->toObjFile(0); 1058 1058 else 1059 1059 { … … 1074 1074 { 1075 1075 irs->deferToObj->push(s); 1076 //sd->toObjFile();1077 1076 } 1078 1077 else if ((sd = s->isStructDeclaration()) != NULL) 1079 1078 { 1080 1079 irs->deferToObj->push(sd); 1081 //sd->toObjFile();1082 1080 } 1083 1081 else if ((fd = s->isFuncDeclaration()) != NULL) … … 1085 1083 //printf("function %s\n", fd->toChars()); 1086 1084 irs->deferToObj->push(fd); 1087 //fd->toObjFile();1088 1085 } 1089 1086 else if ((tm = s->isTemplateMixin()) != NULL) branches/dmdfe-2.0/expression.c
r900 r901 195 195 196 196 precedence[TOKcomma] = PREC_expr; 197 } 198 199 /************************************************************* 200 * Given var, we need to get the 201 * right 'this' pointer if var is in an outer class, but our 202 * existing 'this' pointer is in an inner class. 203 * Input: 204 * e1 existing 'this' 205 * ad struct or class we need the correct 'this' for 206 * var the specific member of ad we're accessing 207 */ 208 209 Expression *getRightThis(Loc loc, Scope *sc, AggregateDeclaration *ad, 210 Expression *e1, Declaration *var) 211 { 212 L1: 213 Type *t = e1->type->toBasetype(); 214 215 /* If e1 is not the 'this' pointer for ad 216 */ 217 if (ad && 218 !(t->ty == Tpointer && t->nextOf()->ty == Tstruct && 219 ((TypeStruct *)t->nextOf())->sym == ad) 220 && 221 !(t->ty == Tstruct && 222 ((TypeStruct *)t)->sym == ad) 223 ) 224 { 225 ClassDeclaration *cd = ad->isClassDeclaration(); 226 ClassDeclaration *tcd = t->isClassHandle(); 227 228 /* e1 is the right this if ad is a base class of e1 229 */ 230 if (!cd || !tcd || 231 !(tcd == cd || cd->isBaseOf(tcd, NULL)) 232 ) 233 { 234 /* Only classes can be inner classes with an 'outer' 235 * member pointing to the enclosing class instance 236 */ 237 if (tcd && tcd->isNested()) 238 { /* e1 is the 'this' pointer for an inner class. 239 * Rewrite it as the 'this' pointer for the outer class. 240 */ 241 242 e1 = new DotVarExp(loc, e1, tcd->vthis); 243 e1 = e1->semantic(sc); 244 245 // Skip up over nested functions, and get the enclosing 246 // class type. 247 Dsymbol *s; 248 for (s = tcd->toParent(); 249 s && s->isFuncDeclaration(); 250 s = s->toParent()) 251 { FuncDeclaration *f = s->isFuncDeclaration(); 252 if (f->vthis) 253 { 254 e1 = new VarExp(loc, f->vthis); 255 } 256 } 257 if (s && s->isClassDeclaration()) 258 e1->type = s->isClassDeclaration()->type; 259 e1 = e1->semantic(sc); 260 goto L1; 261 } 262 263 /* Can't find a path from e1 to ad 264 */ 265 error("this for %s needs to be type %s not type %s", 266 var->toChars(), ad->toChars(), t->toChars()); 267 } 268 } 269 return e1; 197 270 } 198 271 … … 5052 5125 } 5053 5126 5127 TupleDeclaration *tup = s->isTupleDeclaration(); 5128 if (tup) 5129 { 5130 if (eleft) 5131 error("cannot have e.tuple"); 5132 e = new TupleExp(loc, tup); 5133 e = e->semantic(sc); 5134 return e; 5135 } 5136 5054 5137 ScopeDsymbol *sds = s->isScopeDsymbol(); 5055 5138 if (sds) … … 5205 5288 5206 5289 AggregateDeclaration *ad = var->toParent()->isAggregateDeclaration(); 5207 L1: 5208 Type *t = e1->type->toBasetype(); 5209 5210 if (ad && 5211 !(t->ty == Tpointer && 5212 ((TypePointer *)t)->next->ty == Tstruct && 5213 ((TypeStruct *)((TypePointer *)t)->next)->sym == ad) 5214 && 5215 !(t->ty == Tstruct && ((TypeStruct *)t)->sym == ad) 5216 ) 5217 { 5218 ClassDeclaration *cd = ad->isClassDeclaration(); 5219 ClassDeclaration *tcd = t->isClassHandle(); 5220 5221 if (!cd || !tcd || 5222 !(tcd == cd || cd->isBaseOf(tcd, NULL)) 5223 ) 5224 { 5225 if (tcd && tcd->isNested()) 5226 { // Try again with outer scope 5227 5228 e1 = new DotVarExp(loc, e1, tcd->vthis); 5229 e1 = e1->semantic(sc); 5230 5231 // Skip over nested functions, and get the enclosing 5232 // class type. 5233 Dsymbol *s = tcd->toParent(); 5234 while (s && s->isFuncDeclaration()) 5235 { FuncDeclaration *f = s->isFuncDeclaration(); 5236 if (f->vthis) 5237 { 5238 e1 = new VarExp(loc, f->vthis); 5239 } 5240 s = s->toParent(); 5241 } 5242 if (s && s->isClassDeclaration()) 5243 e1->type = s->isClassDeclaration()->type; 5244 5245 e1 = e1->semantic(sc); // get corrected nested refs 5246 goto L1; 5247 } 5248 #ifdef DEBUG 5249 printf("2: "); 5250 #endif 5251 error("%s for %s needs to be type %s not type %s", 5252 e1->toChars(), var->toChars(), ad->toChars(), t->toChars()); 5253 } 5254 } 5290 e1 = getRightThis(loc, sc, ad, e1, var); 5255 5291 if (!sc->noaccesscheck) 5256 5292 accessCheck(loc, sc, e1, var); … … 5495 5531 type = new TypeDelegate(func->type); 5496 5532 type = type->semantic(loc, sc); 5497 //-----------------5498 /* For func, we need to get the5499 * right 'this' pointer if func is in an outer class, but our5500 * existing 'this' pointer is in an inner class.5501 * This code is analogous to that used for variables5502 * in DotVarExp::semantic().5503 */5504 5533 AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration(); 5505 L10: 5506 Type *t = e1->type; 5507 if (func->needThis() && ad && 5508 !(t->ty == Tpointer && ((TypePointer *)t)->next->ty == Tstruct && 5509 ((TypeStruct *)((TypePointer *)t)->next)->sym == ad) && 5510 !(t->ty == Tstruct && ((TypeStruct *)t)->sym == ad) 5511 ) 5512 { 5513 ClassDeclaration *cd = ad->isClassDeclaration(); 5514 ClassDeclaration *tcd = t->isClassHandle(); 5515 5516 if (!cd || !tcd || 5517 !(tcd == cd || cd->isBaseOf(tcd, NULL)) 5518 ) 5519 { 5520 if (tcd && tcd->isNested()) 5521 { // Try again with outer scope 5522 5523 e1 = new DotVarExp(loc, e1, tcd->vthis); 5524 e1 = e1->semantic(sc); 5525 goto L10; 5526 } 5527 #ifdef DEBUG 5528 printf("3: "); 5529 #endif 5530 error("this for %s needs to be type %s not type %s", 5531 func->toChars(), ad->toChars(), t->toChars()); 5532 } 5533 } 5534 //----------------- 5534 if (func->needThis()) 5535 e1 = getRightThis(loc, sc, ad, e1, func); 5535 5536 } 5536 5537 return this; … … 5869 5870 ad = td->toParent()->isAggregateDeclaration(); 5870 5871 } 5871 /* Now that we have the right function f, we need to get the 5872 * right 'this' pointer if f is in an outer class, but our 5873 * existing 'this' pointer is in an inner class. 5874 * This code is analogous to that used for variables 5875 * in DotVarExp::semantic(). 5876 */ 5877 L10: 5878 Type *t = ue->e1->type->toBasetype(); 5879 if (f->needThis() && ad && 5880 !(t->ty == Tpointer && ((TypePointer *)t)->next->ty == Tstruct && 5881 ((TypeStruct *)((TypePointer *)t)->next)->sym == ad) && 5882 !(t->ty == Tstruct && ((TypeStruct *)t)->sym == ad) 5883 ) 5884 { 5885 ClassDeclaration *cd = ad->isClassDeclaration(); 5886 ClassDeclaration *tcd = t->isClassHandle(); 5887 5888 if (!cd || !tcd || 5889 !(tcd == cd || cd->isBaseOf(tcd, NULL)) 5890 ) 5891 { 5892 if (tcd && tcd->isNested()) 5893 { // Try again with outer scope 5894 5895 ue->e1 = new DotVarExp(loc, ue->e1, tcd->vthis); 5896 ue->e1 = ue->e1->semantic(sc); 5897 goto L10; 5898 } 5899 #ifdef DEBUG 5900 printf("1: "); 5901 #endif 5902 error("this for %s needs to be type %s not type %s", 5903 f->toChars(), ad->toChars(), t->toChars()); 5904 } 5905 } 5872 if (f->needThis()) 5873 ue->e1 = getRightThis(loc, sc, ad, ue->e1, f); 5906 5874 5907 5875 checkDeprecated(sc, f); branches/dmdfe-2.0/init.c
r880 r901 167 167 if (fieldi >= ad->fields.dim) 168 168 { error(loc, "too many initializers for %s", ad->toChars()); 169 field.remove(i); 170 i--; 169 171 continue; 170 172 } branches/dmdfe-2.0/link.c
r882 r901 72 72 { // Generate exe file name from first obj name 73 73 char *n = (char *)global.params.objfiles->data[0]; 74 char *ex;75 76 74 n = FileName::name(n); 77 75 FileName *fn = FileName::forceExt(n, "exe"); branches/dmdfe-2.0/mars.c
r900 r901 39 39 #include "expression.h" 40 40 #include "lexer.h" 41 41 #include "lib.h" 42 43 void browse(const char *url); 42 44 void getenv_setargv(const char *envvar, int *pargc, char** *pargv); 45 46 void obj_start(char *srcfile); 47 void obj_end(Library *library, File *objfile); 43 48 44 49 Global global; … … 54 59 obj_ext = "o"; 55 60 61 #if _WIN32 62 lib_ext = "lib"; 63 #elif linux 64 lib_ext = "a"; 65 #else 66 #error "fix this" 67 #endif 68 56 69 copyright = "Copyright (c) 1999-2008 by Digital Mars"; 57 70 written = "written by Walter Bright"; 58 version = "v2.01 3";71 version = "v2.014"; 59 72 global.structalign = 8; 60 73 … … 147 160 global.version, global.copyright, global.written); 148 161 printf("\ 149 Documentation: http://www.digitalmars.com/d/ index.html\n\162 Documentation: http://www.digitalmars.com/d/2.0/index.html\n\ 150 163 Usage:\n\ 151 164 dmd files.d ... { -switch }\n\ … … 174 187 -Jpath where to look for string imports\n\ 175 188 -Llinkerflag pass linkerflag to link\n\ 189 -lib generate library rather than object files\n\ 190 -man open web browser on manual page\n\ 176 191 -nofloat do not emit reference to floating point\n\ 177 192 -O optimize\n\ 178 193 -o- do not write object file\n\ 179 -odobjdir write object files to directory objdir\n\194 -odobjdir write object & library files to directory objdir\n\ 180 195 -offilename name output file to filename\n\ 181 196 -op do not strip paths from source file\n\ … … 202 217 int i; 203 218 Array files; 219 Array libmodules; 204 220 char *p; 205 221 Module *m; … … 269 285 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm"); 270 286 VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86"); 287 #if V2 271 288 VersionCondition::addPredefinedGlobalIdent("D_Version2"); 289 #endif 272 290 VersionCondition::addPredefinedGlobalIdent("all"); 273 291 … … 299 317 else if (strcmp(p + 1, "fPIC") == 0) 300 318 global.params.pic = 1; 319 else if (strcmp(p + 1, "multiobj") == 0) 320 global.params.multiobj = 1; 301 321 else if (strcmp(p + 1, "g") == 0) 302 322 global.params.symdebug = 1; … … 313 333 else if (strcmp(p + 1, "v1") == 0) 314 334 { 335 #if V1 336 global.params.Dversion = 1; 337 #else 315 338 error("use DMD 1.0 series compilers for -v1 switch"); 316 339 break; 317 } 340 #endif 341 } 318 342 else if (strcmp(p + 1, "w") == 0) 319 343 global.params.warnings = 1; … … 405 429 else if (strcmp(p + 1, "inline") == 0) 406 430 global.params.useInline = 1; 431 else if (strcmp(p + 1, "lib") == 0) 432 global.params.lib = 1; 407 433 else if (strcmp(p + 1, "nofloat") == 0) 408 434 global.params.nofloat = 1; … … 531 557 } 532 558 else 559 { 533 560 files.push(p); 561 } 534 562 } 535 563 if (global.errors) … … 557 585 global.params.useAssert = 1; 558 586 559 if (!global.params.obj )587 if (!global.params.obj || global.params.lib) 560 588 global.params.link = 0; 561 589 … … 563 591 { 564 592 global.params.exefile = global.params.objname; 593 global.params.oneobj = 1; 594 if (global.params.objname) 595 { 596 /* Use this to name the one object file with the same 597 * name as the exe file. 598 */ 599 global.params.objname = FileName::forceExt(global.params.objname, global.obj_ext)->toChars(); 600 601 /* If output directory is given, use that path rather than 602 * the exe file path. 603 */ 604 if (global.params.objdir) 605 { char *name = FileName::name(global.params.objname); 606 global.params.objname = FileName::combine(global.params.objdir, name); 607 } 608 } 609 } 610 else if (global.params.lib) 611 { 612 global.params.libname = global.params.objname; 565 613 global.params.objname = NULL; 614 615 // Haven't investigated handling these options with multiobj 616 if (!global.params.cov && !global.params.trace) 617 global.params.multiobj = 1; 566 618 } 567 619 else if (global.params.run) … … 574 626 if (global.params.objname && files.dim > 1) 575 627 { 576 error("multiple source files, but only one .obj name"); 577 fatal(); 628 global.params.oneobj = 1; 629 //error("multiple source files, but only one .obj name"); 630 //fatal(); 578 631 } 579 632 } 580 633 if (global.params.cov) 581 634 VersionCondition::addPredefinedGlobalIdent("D_Coverage"); 635 #if V2 582 636 if (global.params.useUnitTests) 583 637 VersionCondition::addPredefinedGlobalIdent("unittest"); 638 #endif 584 639 585 640 // Initialization … … 630 685 Array modules; 631 686 modules.reserve(files.dim); 687 int firstmodule = 1; 632 688 for (i = 0; i < files.dim; i++) 633 { Identifier *id;689 { 634 690 char *ext; 635 691 char *name; … … 649 705 ext = FileName::ext(p); 650 706 if (ext) 651 { 707 { /* Deduce what to do with a file based on its extension 708 */ 652 709 if (strcmp(ext, global.obj_ext) == 0) 653 710 { 654 711 global.params.objfiles->push(files.data[i]); 712 libmodules.push(files.data[i]); 655 713 continue; 656 714 } 657 715 658 if (strcmp(ext, "a") == 0)716 if (strcmp(ext, global.lib_ext) == 0) 659 717 { 660 718 global.params.libfiles->push(files.data[i]); 719 libmodules.push(files.data[i]); 661 720 continue; 662 721 } … … 668 727 } 669 728 729 /* Examine extension to see if it is a valid 730 * D source file extension 731 */ 670 732 if (stricmp(ext, global.mars_ext) == 0 || 671 733 stricmp(ext, "dd") == 0 || … … 700 762 } 701 763 702 id = new Identifier(name, 0); 764 /* At this point, name is the D source file name stripped of 765 * its path and extension. 766 */ 767 768 Identifier *id = new Identifier(name, 0); 703 769 m = new Module((char *) files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration); 704 770 modules.push(m); 705 771 706 global.params.objfiles->push(m->objfile->name->str); 772 if (firstmodule) 773 { global.params.objfiles->push(m->objfile->name->str); 774 firstmodule = 0; 775 } 707 776 } 708 777 … … 712 781 #endif 713 782 // Read files, parse them 783 int anydocfiles = 0; 714 784 for (i = 0; i < modules.dim; i++) 715 785 { … … 720 790 Module::rootModule = m; 721 791 m->importedFrom = m; 722 m->deleteObjFile(); 792 if (!global.params.oneobj || i == 0 || m->isDocFile) 793 m->deleteObjFile(); 723 794 m->read(0); 724 795 m->parse(); 725 796 if (m->isDocFile) 726 797 { 798 anydocfiles = 1; 727 799 m->gendocfile(); 728 800 … … 744 816 global.params.link = 0; 745 817 } 818 } 819 if (anydocfiles && modules.dim && 820 (global.params.oneobj || global.params.objname)) 821 { 822 error("conflicting Ddoc and obj generation options"); 823 fatal(); 746 824 } 747 825 if (global.errors) … … 834 912 fatal(); 835 913 914 /*Library *library = NULL; 915 if (global.params.lib) 916 { 917 library = new Library(); 918 library->setFilename(global.params.objdir, global.params.libname); 919 920 // Add input object and input library files to output library 921 for (int i = 0; i < libmodules.dim; i++) 922 { 923 char *p = (char *)libmodules.data[i]; 924 library->addObject(p, NULL, 0); 925 } 926 }*/ 927 836 928 // Generate output files 837 for (i = 0; i < modules.dim; i++) 838 { 839 m = (Module *)modules.data[i]; 840 if (global.params.verbose) 841 printf("code %s\n", m->toChars()); 842 /*if (global.params.obj) 843 m->genobjfile();*/ 844 if (global.errors) 845 m->deleteObjFile(); 846 else 847 { 848 if (global.params.doDocComments) 929 if (global.params.oneobj) 930 { 931 for (i = 0; i < modules.dim; i++) 932 { 933 m = (Module *)modules.data[i]; 934 if (global.params.verbose) 935 printf("code %s\n", m->toChars()); 936 /*if (i == 0) 937 obj_start(m->srcfile->toChars()); 938 m->genobjfile(0);*/ 939 if (!global.errors && global.params.doDocComments) 849 940 m->gendocfile(); 850 941 } 851 } 942 /*if (!global.errors && modules.dim) 943 { 944 obj_end(library, ((Module *)modules.data[0])->objfile); 945 }*/ 946 } 947 else 948 { 949 for (i = 0; i < modules.dim; i++) 950 { 951 m = (Module *)modules.data[i]; 952 if (global.params.verbose) 953 printf("code %s\n", m->toChars()); 954 /*if (global.params.obj) 955 { obj_start(m->srcfile->toChars()); 956 m->genobjfile(global.params.multiobj); 957 obj_end(library, m->objfile); 958 obj_write_deferred(library); 959 }*/ 960 if (global.errors) 961 { 962 if (!global.params.lib) 963 m->deleteObjFile(); 964 } 965 else 966 { 967 if (global.params.doDocComments) 968 m->gendocfile(); 969 } 970 } 971 } 972 973 /*if (global.params.lib && !global.errors) 974 library->write();*/ 975 852 976 #if _WIN32 && __DMC__ 853 977 } … … 882 1006 for (i = 0; i < modules.dim; i++) 883 1007 { 884 m = (Module *)modules.data[i];1008 Module *m = (Module *)modules.data[i]; 885 1009 m->deleteObjFile(); 1010 if (global.params.oneobj) 1011 break; 886 1012 } 887 1013 deleteExeFile(); branches/dmdfe-2.0/mars.h
r900 r901 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 30 30 #endif 31 31 32 #define V1 0 32 33 #define V2 1 // Version 2.0 features 33 34 #define BREAKABI 1 // 0 if not ready to break the ABI just yet … … 40 41 char obj; // write object file 41 42 char link; // perform link 43 char lib; // write library file instead of object file(s) 44 char multiobj; // break one object file into multiple ones 45 char oneobj; // write one object file instead of multiple ones 42 46 char trace; // insert profiling hooks 43 47 char quiet; // suppress non-error messages … … 71 75 Array *imppath; // array of char*'s of where to look for import modules 72 76 Array *fileImppath; // array of char*'s of where to look for file import modules 73 char *objdir; // .obj file output directory77 char *objdir; // .obj/.lib file output directory 74 78 char *objname; // .obj file output name 79 char *libname; // .lib file output name 75 80 76 81 char doDocComments; // process embedded documentation comments … … 124 129 char *sym_ext; 125 130 char *obj_ext; 131 char *lib_ext; 126 132 char *doc_ext; // for Ddoc generated files 127 133 char *ddoc_ext; // for Ddoc macro include files … … 285 291 #endif 286 292 293 struct Dsymbol; 294 struct Library; 295 struct File; 296 void obj_start(char *srcfile); 297 void obj_end(Library *library, File *objfile); 298 void obj_append(Dsymbol *s); 299 void obj_write_deferred(Library *library); 300 287 301 #endif /* DMD_MARS_H */ branches/dmdfe-2.0/module.c
r900 r901 105 105 macrotable = NULL; 106 106 escapetable = NULL; 107 doppelganger = 0; 107 108 cov = NULL; 108 109 covb = NULL; … … 766 767 OutBuffer buf; 767 768 HdrGenState hgs; 768 int i;769 769 770 770 //printf("Module::gensymfile()\n"); … … 773 773 buf.writenl(); 774 774 775 for (i = 0; i < members->dim; i++) 776 { 777 Dsymbol *s; 778 779 s = (Dsymbol *)members->data[i]; 775 for (int i = 0; i < members->dim; i++) 776 { Dsymbol *s = (Dsymbol *)members->data[i]; 777 780 778 s->toCBuffer(&buf, &hgs); 781 779 } branches/dmdfe-2.0/module.h
r846 r901 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 5by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 25 25 struct Escape; 26 26 struct VarDeclaration; 27 struct Library; 27 28 28 29 // Back end … … 126 127 void genhdrfile(); // generate D import file 127 128 #endif 128 void genobjfile( );129 void genobjfile(int multiobj); 129 130 void gensymfile(); 130 131 void gendocfile(); … … 137 138 // Back end 138 139 140 int doppelganger; // sub-module 139 141 Symbol *cov; // private uint[] __coverage; 140 142 unsigned *covb; // bit array of valid code line numbers branches/dmdfe-2.0/mtype.c
r900 r901 898 898 void Type::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 899 899 { 900 Type *t; 901 902 t = semantic(loc, sc); 900 //printf("Type::resolve() %s, %d\n", toChars(), ty); 901 Type *t = semantic(loc, sc); 903 902 *pt = t; 904 903 *pe = NULL; … … 1911 1910 if (*pe) 1912 1911 { // It's really an index expression 1913 Expression *e; 1914 e = new IndexExp(loc, *pe, dim); 1912 Expression *e = new IndexExp(loc, *pe, dim); 1915 1913 *pe = e; 1916 1914 } … … 2371 2369 return MATCHnomatch; // not const-compatible 2372 2370 2373 /* Allo cconversion to void[]2371 /* Allow conversion to void[] 2374 2372 */ 2375 2373 if (next->ty != Tvoid && ta->next->ty == Tvoid) … … 2384 2382 m = MATCHconst; 2385 2383 return m; 2384 } 2385 2386 /* Allow conversions of T[][] to const(T)[][] 2387 */ 2388 if (mod == ta->mod && next->ty == Tarray && ta->next->ty == Tarray) 2389 { 2390 m = next->implicitConvTo(ta->next); 2391 if (m == MATCHconst) 2392 return m; 2386 2393 } 2387 2394 … … 2508 2515 return merge(); 2509 2516 } 2517 2518 void TypeAArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 2519 { 2520 //printf("TypeAArray::resolve() %s\n", toChars()); 2521 2522 // Deal with the case where we thought the index was a type, but 2523 // in reality it was an expression. 2524 if (index->ty == Tident || index->ty == Tinstance || index->ty == Tsarray) 2525 { 2526 Expression *e; 2527 Type *t; 2528 Dsymbol *s; 2529 2530 index->resolve(loc, sc, &e, &t, &s); 2531 if (e) 2532 { // It was an expression - 2533 // Rewrite as a static array 2534 2535 TypeSArray *tsa = new TypeSArray(next, e); 2536 return tsa->resolve(loc, sc, pe, pt, ps); 2537 } 2538 else if (t) 2539 index = t; 2540 else 2541 index->error(loc, "index is not a type or an expression"); 2542 } 2543 Type::resolve(loc, sc, pe, pt, ps); 2544 } 2545 2510 2546 2511 2547 Expression *TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident) branches/dmdfe-2.0/mtype.h
r900 r901 374 374 d_uns64 size(Loc loc); 375 375 Type *semantic(Loc loc, Scope *sc);
