Changeset 901

Show
Ignore:
Timestamp:
06/29/08 18:40:28 (4 months ago)
Author:
Gregor
Message:

MERGE: DMD 2.014

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmdfe-2.0/aggregate.h

    r900 r901  
    107107{ 
    108108    int zeroInit;       // !=0 if initialize with 0 fill 
     109#if V2 
    109110    int hasIdentityAssign;  // !=0 if has identity opAssign 
    110111    FuncDeclaration *cpctor;    // generated copy-constructor, if any 
     
    112113    FuncDeclarations postblits; // Array of postblit functions 
    113114    FuncDeclaration *postblit;  // aggregate postblit 
     115#endif 
    114116 
    115117    StructDeclaration(Loc loc, Identifier *id); 
  • branches/dmdfe-2.0/cast.c

    r900 r901  
    15151515    } 
    15161516    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    } 
    15421563    } 
    15431564    else if (t1->ty == Tstruct && t2->ty == Tstruct) 
  • branches/dmdfe-2.0/declaration.c

    r900 r901  
    949949        !init->isVoidInitializer()) 
    950950        { 
    951         Expression *e1; 
    952         Type *t; 
    953         int dim; 
    954  
    955951        //printf("fd = '%s', var = '%s'\n", fd->toChars(), toChars()); 
    956952        if (!ei) 
     
    970966        } 
    971967 
    972         e1 = new VarExp(loc, this); 
    973  
    974         t = type->toBasetype(); 
     968        Expression *e1 = new VarExp(loc, this); 
     969 
     970        Type *t = type->toBasetype(); 
    975971        if (t->ty == Tsarray) 
    976972        { 
     
    978974            if (!ei->exp->implicitConvTo(type)) 
    979975            { 
    980             dim = ((TypeSArray *)t)->dim->toInteger(); 
     976            int dim = ((TypeSArray *)t)->dim->toInteger(); 
    981977            // If multidimensional static array, treat as one large array 
    982978            while (1) 
     
    995991            ei->exp = ei->exp->semantic(sc); 
    996992            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            } 
    998998        } 
    999999        ei->exp = new AssignExp(loc, e1, ei->exp); 
  • branches/dmdfe-2.0/declaration.h

    r900 r901  
    371371{ 
    372372    TypeInfoConstDeclaration(Type *tinfo); 
    373  
    374     void toDt(dt_t **pdt); 
    375373}; 
    376374 
     
    378376{ 
    379377    TypeInfoInvariantDeclaration(Type *tinfo); 
    380  
    381     void toDt(dt_t **pdt); 
    382378}; 
    383379#endif 
     
    537533    FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } 
    538534    char *kind(); 
    539     Symbol *toSymbol(); 
    540535}; 
    541536 
  • branches/dmdfe-2.0/e2ir.c

    r900 r901  
    10551055        return Dsymbol_toElem(s, irs); 
    10561056    if (vd->isStatic() || vd->storage_class & STCextern) 
    1057         vd->toObjFile(); 
     1057        vd->toObjFile(0); 
    10581058    else 
    10591059    { 
     
    10741074    { 
    10751075    irs->deferToObj->push(s); 
    1076     //sd->toObjFile(); 
    10771076    } 
    10781077    else if ((sd = s->isStructDeclaration()) != NULL) 
    10791078    { 
    10801079    irs->deferToObj->push(sd); 
    1081     //sd->toObjFile(); 
    10821080    } 
    10831081    else if ((fd = s->isFuncDeclaration()) != NULL) 
     
    10851083    //printf("function %s\n", fd->toChars()); 
    10861084    irs->deferToObj->push(fd); 
    1087     //fd->toObjFile(); 
    10881085    } 
    10891086    else if ((tm = s->isTemplateMixin()) != NULL) 
  • branches/dmdfe-2.0/expression.c

    r900 r901  
    195195 
    196196    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 
     209Expression *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; 
    197270} 
    198271 
     
    50525125        } 
    50535126 
     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 
    50545137        ScopeDsymbol *sds = s->isScopeDsymbol(); 
    50555138        if (sds) 
     
    52055288 
    52065289        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); 
    52555291        if (!sc->noaccesscheck) 
    52565292        accessCheck(loc, sc, e1, var); 
     
    54955531    type = new TypeDelegate(func->type); 
    54965532    type = type->semantic(loc, sc); 
    5497 //----------------- 
    5498     /* For func, we need to get the 
    5499      * right 'this' pointer if func is in an outer class, but our 
    5500      * existing 'this' pointer is in an inner class. 
    5501      * This code is analogous to that used for variables 
    5502      * in DotVarExp::semantic(). 
    5503      */ 
    55045533    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); 
    55355536    } 
    55365537    return this; 
     
    58695870        ad = td->toParent()->isAggregateDeclaration(); 
    58705871    }    
    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); 
    59065874 
    59075875    checkDeprecated(sc, f); 
  • branches/dmdfe-2.0/init.c

    r880 r901  
    167167        if (fieldi >= ad->fields.dim) 
    168168        {   error(loc, "too many initializers for %s", ad->toChars()); 
     169            field.remove(i); 
     170            i--; 
    169171            continue; 
    170172        } 
  • branches/dmdfe-2.0/link.c

    r882 r901  
    7272    {   // Generate exe file name from first obj name 
    7373    char *n = (char *)global.params.objfiles->data[0]; 
    74     char *ex; 
    75  
    7674    n = FileName::name(n); 
    7775    FileName *fn = FileName::forceExt(n, "exe"); 
  • branches/dmdfe-2.0/mars.c

    r900 r901  
    3939#include "expression.h" 
    4040#include "lexer.h" 
    41  
     41#include "lib.h" 
     42 
     43void browse(const char *url); 
    4244void getenv_setargv(const char *envvar, int *pargc, char** *pargv); 
     45 
     46void obj_start(char *srcfile); 
     47void obj_end(Library *library, File *objfile); 
    4348 
    4449Global global; 
     
    5459    obj_ext  = "o"; 
    5560 
     61#if _WIN32 
     62    lib_ext  = "lib"; 
     63#elif linux 
     64    lib_ext  = "a"; 
     65#else 
     66#error "fix this" 
     67#endif 
     68 
    5669    copyright = "Copyright (c) 1999-2008 by Digital Mars"; 
    5770    written = "written by Walter Bright"; 
    58     version = "v2.013"; 
     71    version = "v2.014"; 
    5972    global.structalign = 8; 
    6073 
     
    147160    global.version, global.copyright, global.written); 
    148161    printf("\ 
    149 Documentation: http://www.digitalmars.com/d/index.html\n\ 
     162Documentation: http://www.digitalmars.com/d/2.0/index.html\n\ 
    150163Usage:\n\ 
    151164  dmd files.d ... { -switch }\n\ 
     
    174187  -Jpath         where to look for string imports\n\ 
    175188  -Llinkerflag   pass linkerflag to link\n\ 
     189  -lib           generate library rather than object files\n\ 
     190  -man           open web browser on manual page\n\ 
    176191  -nofloat       do not emit reference to floating point\n\ 
    177192  -O             optimize\n\ 
    178193  -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\ 
    180195  -offilename    name output file to filename\n\ 
    181196  -op            do not strip paths from source file\n\ 
     
    202217    int i; 
    203218    Array files; 
     219    Array libmodules; 
    204220    char *p; 
    205221    Module *m; 
     
    269285    VersionCondition::addPredefinedGlobalIdent("D_InlineAsm"); 
    270286    VersionCondition::addPredefinedGlobalIdent("D_InlineAsm_X86"); 
     287#if V2 
    271288    VersionCondition::addPredefinedGlobalIdent("D_Version2"); 
     289#endif 
    272290    VersionCondition::addPredefinedGlobalIdent("all"); 
    273291 
     
    299317        else if (strcmp(p + 1, "fPIC") == 0) 
    300318        global.params.pic = 1; 
     319        else if (strcmp(p + 1, "multiobj") == 0) 
     320        global.params.multiobj = 1; 
    301321        else if (strcmp(p + 1, "g") == 0) 
    302322        global.params.symdebug = 1; 
     
    313333        else if (strcmp(p + 1, "v1") == 0) 
    314334        { 
     335#if V1 
     336        global.params.Dversion = 1; 
     337#else 
    315338        error("use DMD 1.0 series compilers for -v1 switch"); 
    316339        break; 
    317         } 
     340#endif 
     341            } 
    318342        else if (strcmp(p + 1, "w") == 0) 
    319343        global.params.warnings = 1; 
     
    405429        else if (strcmp(p + 1, "inline") == 0) 
    406430        global.params.useInline = 1; 
     431        else if (strcmp(p + 1, "lib") == 0) 
     432        global.params.lib = 1; 
    407433        else if (strcmp(p + 1, "nofloat") == 0) 
    408434        global.params.nofloat = 1; 
     
    531557    } 
    532558    else 
     559    { 
    533560        files.push(p); 
     561    } 
    534562    } 
    535563    if (global.errors) 
     
    557585    global.params.useAssert = 1; 
    558586 
    559     if (!global.params.obj
     587    if (!global.params.obj || global.params.lib
    560588    global.params.link = 0; 
    561589 
     
    563591    { 
    564592    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; 
    565613    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; 
    566618    } 
    567619    else if (global.params.run) 
     
    574626    if (global.params.objname && files.dim > 1) 
    575627    { 
    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(); 
    578631    } 
    579632    } 
    580633    if (global.params.cov) 
    581634    VersionCondition::addPredefinedGlobalIdent("D_Coverage"); 
     635#if V2 
    582636    if (global.params.useUnitTests) 
    583637    VersionCondition::addPredefinedGlobalIdent("unittest"); 
     638#endif 
    584639 
    585640    // Initialization 
     
    630685    Array modules; 
    631686    modules.reserve(files.dim); 
     687    int firstmodule = 1; 
    632688    for (i = 0; i < files.dim; i++) 
    633     {  Identifier *id; 
     689    { 
    634690    char *ext; 
    635691    char *name; 
     
    649705    ext = FileName::ext(p); 
    650706    if (ext) 
    651     { 
     707    {   /* Deduce what to do with a file based on its extension 
     708         */ 
    652709        if (strcmp(ext, global.obj_ext) == 0) 
    653710        { 
    654711        global.params.objfiles->push(files.data[i]); 
     712        libmodules.push(files.data[i]); 
    655713        continue; 
    656714        } 
    657715 
    658         if (strcmp(ext, "a") == 0) 
     716        if (strcmp(ext, global.lib_ext) == 0) 
    659717        { 
    660718        global.params.libfiles->push(files.data[i]); 
     719        libmodules.push(files.data[i]); 
    661720        continue; 
    662721        } 
     
    668727        } 
    669728 
     729        /* Examine extension to see if it is a valid 
     730         * D source file extension 
     731         */ 
    670732        if (stricmp(ext, global.mars_ext) == 0 || 
    671733        stricmp(ext, "dd") == 0 || 
     
    700762    } 
    701763 
    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); 
    703769    m = new Module((char *) files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration); 
    704770    modules.push(m); 
    705771 
    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    } 
    707776    } 
    708777 
     
    712781#endif 
    713782    // Read files, parse them 
     783    int anydocfiles = 0; 
    714784    for (i = 0; i < modules.dim; i++) 
    715785    { 
     
    720790        Module::rootModule = m; 
    721791    m->importedFrom = m; 
    722     m->deleteObjFile(); 
     792    if (!global.params.oneobj || i == 0 || m->isDocFile) 
     793        m->deleteObjFile(); 
    723794    m->read(0); 
    724795    m->parse(); 
    725796    if (m->isDocFile) 
    726797    { 
     798        anydocfiles = 1; 
    727799        m->gendocfile(); 
    728800 
     
    744816        global.params.link = 0; 
    745817    } 
     818    } 
     819    if (anydocfiles && modules.dim && 
     820    (global.params.oneobj || global.params.objname)) 
     821    { 
     822    error("conflicting Ddoc and obj generation options"); 
     823    fatal(); 
    746824    } 
    747825    if (global.errors) 
     
    834912    fatal(); 
    835913 
     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 
    836928    // 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) 
    849940        m->gendocfile(); 
    850941    } 
    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 
    852976#if _WIN32 && __DMC__ 
    853977  } 
     
    8821006        for (i = 0; i < modules.dim; i++) 
    8831007        { 
    884             m = (Module *)modules.data[i]; 
     1008            Module *m = (Module *)modules.data[i]; 
    8851009            m->deleteObjFile(); 
     1010            if (global.params.oneobj) 
     1011            break; 
    8861012        } 
    8871013        deleteExeFile(); 
  • branches/dmdfe-2.0/mars.h

    r900 r901  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2007 by Digital Mars 
     3// Copyright (c) 1999-2008 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    3030#endif 
    3131 
     32#define V1  0 
    3233#define V2  1   // Version 2.0 features 
    3334#define BREAKABI 1  // 0 if not ready to break the ABI just yet 
     
    4041    char obj;       // write object file 
    4142    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 
    4246    char trace;     // insert profiling hooks 
    4347    char quiet;     // suppress non-error messages 
     
    7175    Array *imppath; // array of char*'s of where to look for import modules 
    7276    Array *fileImppath; // array of char*'s of where to look for file import modules 
    73     char *objdir;   // .obj file output directory 
     77    char *objdir;   // .obj/.lib file output directory 
    7478    char *objname;  // .obj file output name 
     79    char *libname;  // .lib file output name 
    7580 
    7681    char doDocComments; // process embedded documentation comments 
     
    124129    char *sym_ext; 
    125130    char *obj_ext; 
     131    char *lib_ext; 
    126132    char *doc_ext;  // for Ddoc generated files 
    127133    char *ddoc_ext; // for Ddoc macro include files 
     
    285291#endif 
    286292 
     293struct Dsymbol; 
     294struct Library; 
     295struct File; 
     296void obj_start(char *srcfile); 
     297void obj_end(Library *library, File *objfile); 
     298void obj_append(Dsymbol *s); 
     299void obj_write_deferred(Library *library); 
     300 
    287301#endif /* DMD_MARS_H */ 
  • branches/dmdfe-2.0/module.c

    r900 r901  
    105105    macrotable = NULL; 
    106106    escapetable = NULL; 
     107    doppelganger = 0; 
    107108    cov = NULL; 
    108109    covb = NULL; 
     
    766767    OutBuffer buf; 
    767768    HdrGenState hgs; 
    768     int i; 
    769769 
    770770    //printf("Module::gensymfile()\n"); 
     
    773773    buf.writenl(); 
    774774 
    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 
    780778    s->toCBuffer(&buf, &hgs); 
    781779    } 
  • branches/dmdfe-2.0/module.h

    r846 r901  
    11 
    22// Compiler implementation of the D programming language 
    3 // Copyright (c) 1999-2005 by Digital Mars 
     3// Copyright (c) 1999-2008 by Digital Mars 
    44// All Rights Reserved 
    55// written by Walter Bright 
     
    2525struct Escape; 
    2626struct VarDeclaration; 
     27struct Library; 
    2728 
    2829// Back end 
     
    126127    void genhdrfile();  // generate D import file 
    127128#endif 
    128     void genobjfile(); 
     129    void genobjfile(int multiobj); 
    129130    void gensymfile(); 
    130131    void gendocfile(); 
     
    137138    // Back end 
    138139 
     140    int doppelganger;       // sub-module 
    139141    Symbol *cov;        // private uint[] __coverage; 
    140142    unsigned *covb;     // bit array of valid code line numbers 
  • branches/dmdfe-2.0/mtype.c

    r900 r901  
    898898void Type::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 
    899899{ 
    900     Type *t; 
    901  
    902     t = semantic(loc, sc); 
     900    //printf("Type::resolve() %s, %d\n", toChars(), ty); 
     901    Type *t = semantic(loc, sc); 
    903902    *pt = t; 
    904903    *pe = NULL; 
     
    19111910    if (*pe) 
    19121911    {   // It's really an index expression 
    1913     Expression *e; 
    1914     e = new IndexExp(loc, *pe, dim); 
     1912    Expression *e = new IndexExp(loc, *pe, dim); 
    19151913    *pe = e; 
    19161914    } 
     
    23712369        return MATCHnomatch;    // not const-compatible 
    23722370 
    2373     /* Alloc conversion to void[] 
     2371    /* Allow conversion to void[] 
    23742372     */ 
    23752373    if (next->ty != Tvoid && ta->next->ty == Tvoid) 
     
    23842382        m = MATCHconst; 
    23852383        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; 
    23862393    } 
    23872394 
     
    25082515    return merge(); 
    25092516} 
     2517 
     2518void 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 
    25102546 
    25112547Expression *TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident) 
  • branches/dmdfe-2.0/mtype.h

    r900 r901  
    374374    d_uns64 size(Loc loc); 
    375375    Type *semantic(Loc loc, Scope *sc);