Changeset 902

Show
Ignore:
Timestamp:
06/29/08 18:49:05 (3 months ago)
Author:
Gregor
Message:

MERGE: DMD 2.015

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmdfe-2.0/attrib.c

    r900 r902  
    5151int AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) 
    5252{ 
    53     unsigned i; 
    5453    int m = 0; 
    5554    Array *d = include(sc, sd); 
     
    5756    if (d) 
    5857    { 
    59     for (i = 0; i < d->dim; i++) 
    60     {   Dsymbol *s; 
    61  
    62         s = (Dsymbol *)d->data[i]; 
     58    for (unsigned i = 0; i < d->dim; i++) 
     59    {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    6360        m |= s->addMember(sc, sd, m | memnum); 
    6461    } 
     
    7168    Array *d = include(sc, NULL); 
    7269 
    73     //printf("\tAttribDeclaration::semantic '%s'\n",toChars()); 
     70    //printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d); 
    7471    if (d) 
    7572    { 
     
    8582void AttribDeclaration::semantic2(Scope *sc) 
    8683{ 
    87     unsigned i; 
    8884    Array *d = include(sc, NULL); 
    8985 
    9086    if (d) 
    9187    { 
    92     for (i = 0; i < d->dim; i++) 
    93     {   Dsymbol *s; 
    94  
    95         s = (Dsymbol *)d->data[i]; 
     88    for (unsigned i = 0; i < d->dim; i++) 
     89    {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    9690        s->semantic2(sc); 
    9791    } 
     
    10195void AttribDeclaration::semantic3(Scope *sc) 
    10296{ 
    103     unsigned i; 
    10497    Array *d = include(sc, NULL); 
    10598 
    10699    if (d) 
    107100    { 
    108     for (i = 0; i < d->dim; i++) 
    109     {   Dsymbol *s; 
    110  
    111         s = (Dsymbol *)d->data[i]; 
     101    for (unsigned i = 0; i < d->dim; i++) 
     102    {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    112103        s->semantic3(sc); 
    113104    } 
     
    117108void AttribDeclaration::inlineScan() 
    118109{ 
    119     unsigned i; 
    120110    Array *d = include(NULL, NULL); 
    121111 
    122112    if (d) 
    123113    { 
    124     for (i = 0; i < d->dim; i++) 
    125     {   Dsymbol *s; 
    126  
    127         s = (Dsymbol *)d->data[i]; 
     114    for (unsigned i = 0; i < d->dim; i++) 
     115    {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    128116        //printf("AttribDeclaration::inlineScan %s\n", s->toChars()); 
    129117        s->inlineScan(); 
     
    136124    if (comment) 
    137125    { 
    138     unsigned i; 
    139126    Array *d = include(NULL, NULL); 
    140127 
    141128    if (d) 
    142129    { 
    143         for (i = 0; i < d->dim; i++) 
    144         {   Dsymbol *s; 
    145  
    146         s = (Dsymbol *)d->data[i]; 
     130        for (unsigned i = 0; i < d->dim; i++) 
     131        {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    147132        //printf("AttribDeclaration::addComment %s\n", s->toChars()); 
    148133        s->addComment(comment); 
     
    162147//  return; 
    163148 
    164     unsigned i; 
    165149    Array *d = include(NULL, NULL); 
    166150 
    167151    if (d) 
    168152    { 
    169     for (i = 0; i < d->dim; i++) 
    170     {   Dsymbol *s; 
    171  
    172         s = (Dsymbol *)d->data[i]; 
     153    for (unsigned i = 0; i < d->dim; i++) 
     154    {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    173155        //printf("AttribDeclaration::emitComment %s\n", s->toChars()); 
    174156        s->emitComment(sc); 
     
    207189void AttribDeclaration::checkCtorConstInit() 
    208190{ 
    209     unsigned i; 
    210191    Array *d = include(NULL, NULL); 
    211192 
    212193    if (d) 
    213194    { 
    214     for (i = 0; i < d->dim; i++) 
    215     {   Dsymbol *s; 
    216  
    217         s = (Dsymbol *)d->data[i]; 
     195    for (unsigned i = 0; i < d->dim; i++) 
     196    {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    218197        s->checkCtorConstInit(); 
    219198    } 
     
    225204 
    226205void AttribDeclaration::addLocalClass(ClassDeclarations *aclasses) 
    227 {   unsigned i; 
     206{ 
    228207    Array *d = include(NULL, NULL); 
    229208 
    230209    if (d) 
    231210    { 
    232     for (i = 0; i < d->dim; i++) 
    233     {   Dsymbol *s; 
    234  
    235         s = (Dsymbol *)d->data[i]; 
     211    for (unsigned i = 0; i < d->dim; i++) 
     212    {   Dsymbol *s = (Dsymbol *)d->data[i]; 
    236213        s->addLocalClass(aclasses); 
    237214    } 
     
    10421019int StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) 
    10431020{ 
     1021    //printf("StaticIfDeclaration::addMember() '%s'\n",toChars()); 
    10441022    /* This is deferred until semantic(), so that 
    10451023     * expressions in the condition can refer to declarations 
     
    10681046    Array *d = include(sc, sd); 
    10691047 
    1070     //printf("\tStaticIfDeclaration::semantic '%s'\n",toChars()); 
     1048    //printf("\tStaticIfDeclaration::semantic '%s', d = %p\n",toChars(), d); 
    10711049    if (d) 
    10721050    { 
     
    10981076    this->exp = exp; 
    10991077    this->sd = NULL; 
     1078    this->compiled = 0; 
    11001079} 
    11011080 
     
    11091088int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) 
    11101089{ 
     1090    //printf("CompileDeclaration::addMember(sc = %p)\n", sc); 
    11111091    this->sd = sd; 
     1092    if (memnum == 0) 
     1093    {   /* No members yet, so parse the mixin now 
     1094     */ 
     1095    compileIt(sc); 
     1096    memnum |= AttribDeclaration::addMember(sc, sd, memnum); 
     1097    compiled = 1; 
     1098    } 
    11121099    return memnum; 
    11131100} 
    11141101 
    1115 void CompileDeclaration::semantic(Scope *sc) 
    1116 { 
    1117     //printf("CompileDeclaration::semantic()\n"); 
     1102void CompileDeclaration::compileIt(Scope *sc) 
     1103{ 
     1104    //printf("CompileDeclaration::compileIt()\n"); 
    11181105    exp = exp->semantic(sc); 
    11191106    exp = resolveProperties(sc, exp); 
     
    11211108    if (exp->op != TOKstring) 
    11221109    {   error("argument to mixin must be a string, not (%s)", exp->toChars()); 
    1123     return; 
    1124     } 
    1125     StringExp *se = (StringExp *)exp; 
    1126     se = se->toUTF8(sc); 
    1127     Parser p(sc->module, (unsigned char *)se->string, se->len, 0); 
    1128     p.loc = loc; 
    1129     p.nextToken(); 
    1130     decl = p.parseDeclDefs(0); 
    1131     if (p.token.value != TOKeof) 
    1132     { 
    1133     error("incomplete mixin declaration (%s)", se->toChars()); 
    1134     } 
    1135  
    1136     AttribDeclaration::addMember(sc, sd, 0); 
     1110    } 
     1111    else 
     1112    { 
     1113    StringExp *se = (StringExp *)exp; 
     1114    se = se->toUTF8(sc); 
     1115    Parser p(sc->module, (unsigned char *)se->string, se->len, 0); 
     1116    p.loc = loc; 
     1117    p.nextToken(); 
     1118    decl = p.parseDeclDefs(0); 
     1119    if (p.token.value != TOKeof) 
     1120        error("incomplete mixin declaration (%s)", se->toChars()); 
     1121    } 
     1122
     1123 
     1124void CompileDeclaration::semantic(Scope *sc) 
     1125
     1126    //printf("CompileDeclaration::semantic()\n"); 
     1127 
     1128    if (!compiled) 
     1129    { 
     1130    compileIt(sc); 
     1131    AttribDeclaration::addMember(sc, sd, 0); 
     1132    compiled = 1; 
     1133    } 
    11371134    AttribDeclaration::semantic(sc); 
    11381135} 
  • branches/dmdfe-2.0/attrib.h

    r458 r902  
    152152 
    153153    ScopeDsymbol *sd; 
     154    int compiled; 
    154155 
    155156    CompileDeclaration(Loc loc, Expression *exp); 
    156157    Dsymbol *syntaxCopy(Dsymbol *s); 
    157158    int addMember(Scope *sc, ScopeDsymbol *sd, int memnum); 
     159    void compileIt(Scope *sc); 
    158160    void semantic(Scope *sc); 
    159161    void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 
  • branches/dmdfe-2.0/cast.c

    r901 r902  
    13181318} 
    13191319 
    1320 /************************************ 
    1321  * Bring leaves to common type. 
     1320/************************************** 
     1321 * Combine types. 
     1322 * Output: 
     1323 *  *pt merged type, if *pt is not NULL 
     1324 *  *pe1    rewritten e1 
     1325 *  *pe2    rewritten e2 
     1326 * Returns: 
     1327 *  !=0 success 
     1328 *  0   failed 
    13221329 */ 
    13231330 
    1324 Expression *BinExp::typeCombine(Scope *sc) 
    1325 
    1326     Type *t1; 
    1327     Type *t2; 
    1328     Type *t; 
    1329     TY ty; 
    1330  
    1331     //printf("BinExp::typeCombine() %s\n", toChars()); 
     1331int typeMerge(Scope *sc, Type **pt, Expression **pe1, Expression **pe2) 
     1332
     1333    //printf("typeMerge() %s\n", toChars()); 
    13321334    //dump(0); 
    13331335 
    1334     e1 = e1->integralPromotions(sc); 
    1335     e2 = e2->integralPromotions(sc); 
    1336  
    1337     // BUG: do toBasetype() 
    1338     t1 = e1->type; 
    1339     t2 = e2->type; 
     1336    Expression *e1 = (*pe1)->integralPromotions(sc); 
     1337    Expression *e2 = (*pe2)->integralPromotions(sc); 
     1338 
     1339    Type *t1 = e1->type; 
     1340    Type *t2 = e2->type; 
    13401341    assert(t1); 
    1341     t = t1; 
     1342    Type *t = t1; 
    13421343 
    13431344    //if (t1) printf("\tt1 = %s\n", t1->toChars()); 
     
    13511352    Type *t2b = t2->toBasetype(); 
    13521353 
    1353     ty = (TY)Type::impcnvResult[t1b->ty][t2b->ty]; 
     1354    TY ty = (TY)Type::impcnvResult[t1b->ty][t2b->ty]; 
    13541355    if (ty != Terror) 
    13551356    {   TY ty1; 
     
    13631364        if (t1 == t2) 
    13641365        { 
    1365         if (!type) 
    1366             type = t1; 
    1367         return this; 
     1366        t = t1; 
     1367        goto Lret; 
    13681368        } 
    13691369 
    13701370        if (t1b == t2b) 
    13711371        { 
    1372         if (!type) 
    1373             type = t1b; 
    1374         return this; 
    1375         } 
    1376     } 
    1377  
    1378     if (!type) 
    1379         type = Type::basic[ty]; 
     1372        t = t1b; 
     1373        goto Lret; 
     1374        } 
     1375    } 
     1376 
     1377    t = Type::basic[ty]; 
    13801378 
    13811379    t1 = Type::basic[ty1]; 
     
    13831381    e1 = e1->castTo(sc, t1); 
    13841382    e2 = e2->castTo(sc, t2); 
    1385 #if 0 
    1386     if (type != Type::basic[ty]) 
    1387     {   t = type; 
    1388         type = Type::basic[ty]; 
    1389         return castTo(sc, t); 
    1390     } 
    1391 #endif 
    13921383    //printf("after typeCombine():\n"); 
    13931384    //dump(0); 
    13941385    //printf("ty = %d, ty1 = %d, ty2 = %d\n", ty, ty1, ty2); 
    1395     return this
     1386    goto Lret
    13961387    } 
    13971388 
    13981389    t1 = t1b; 
    13991390    t2 = t2b; 
     1391 
     1392Lagain: 
     1393    if (t1 == t2) 
     1394    { 
     1395    } 
     1396    else if (t1->ty == Tpointer && t2->ty == Tpointer) 
     1397    { 
     1398    // Bring pointers to compatible type 
     1399    Type *t1n = t1->nextOf(); 
     1400    Type *t2n = t2->nextOf(); 
     1401 
     1402    if (t1n == t2n) 
     1403        ; 
     1404    else if (t1n->ty == Tvoid)  // pointers to void are always compatible 
     1405        t = t2; 
     1406    else if (t2n->ty == Tvoid) 
     1407        ; 
     1408    else if (t1n->mod != t2n->mod) 
     1409    { 
     1410        t1 = t1n->mutableOf()->constOf()->pointerTo(); 
     1411        t2 = t2n->mutableOf()->constOf()->pointerTo(); 
     1412        t = t1; 
     1413        goto Lagain; 
     1414    } 
     1415    else if (t1n->ty == Tclass && t2n->ty == Tclass) 
     1416    {   ClassDeclaration *cd1 = t1n->isClassHandle(); 
     1417        ClassDeclaration *cd2 = t2n->isClassHandle(); 
     1418        int offset; 
     1419 
     1420        if (cd1->isBaseOf(cd2, &offset)) 
     1421        { 
     1422        if (offset) 
     1423            e2 = e2->castTo(sc, t); 
     1424        } 
     1425        else if (cd2->isBaseOf(cd1, &offset)) 
     1426        { 
     1427        t = t2; 
     1428        if (offset) 
     1429            e1 = e1->castTo(sc, t); 
     1430        } 
     1431        else 
     1432        goto Lincompatible; 
     1433    } 
     1434    else 
     1435        goto Lincompatible; 
     1436    } 
     1437    else if ((t1->ty == Tsarray || t1->ty == Tarray) && 
     1438         e2->op == TOKnull && t2->ty == Tpointer && t2->nextOf()->ty == Tvoid) 
     1439    {   /*  (T[n] op void*) 
     1440     *  (T[] op void*) 
     1441     */ 
     1442    goto Lx1; 
     1443    } 
     1444    else if ((t2->ty == Tsarray || t2->ty == Tarray) && 
     1445         e1->op == TOKnull && t1->ty == Tpointer && t1->nextOf()->ty == Tvoid) 
     1446    {   /*  (void* op T[n]) 
     1447     *  (void* op T[]) 
     1448     */ 
     1449    goto Lx2; 
     1450    } 
     1451    else if ((t1->ty == Tsarray || t1->ty == Tarray) && t1->implicitConvTo(t2)) 
     1452    { 
     1453    goto Lt2; 
     1454    } 
     1455    else if ((t2->ty == Tsarray || t2->ty == Tarray) && t2->implicitConvTo(t1)) 
     1456    { 
     1457    goto Lt1; 
     1458    } 
     1459    /* If one is mutable and the other invariant, then retry 
     1460     * with both of them as const 
     1461     */ 
     1462    else if ((t1->ty == Tsarray || t1->ty == Tarray || t1->ty == Tpointer) && 
     1463         (t2->ty == Tsarray || t2->ty == Tarray || t2->ty == Tpointer) && 
     1464         t1->nextOf()->mod != t2->nextOf()->mod 
     1465        ) 
     1466    { 
     1467    if (t1->ty == Tpointer) 
     1468        t1 = t1->nextOf()->mutableOf()->constOf()->pointerTo(); 
     1469    else 
     1470        t1 = t1->nextOf()->mutableOf()->constOf()->arrayOf(); 
     1471 
     1472    if (t2->ty == Tpointer) 
     1473        t2 = t2->nextOf()->mutableOf()->constOf()->pointerTo(); 
     1474    else 
     1475        t2 = t2->nextOf()->mutableOf()->constOf()->arrayOf(); 
     1476    t = t1; 
     1477    goto Lagain; 
     1478    } 
     1479    else if (t1->ty == Tclass || t2->ty == Tclass) 
     1480    { 
     1481    while (1) 
     1482    { 
     1483        int i1 = e2->implicitConvTo(t1); 
     1484        int i2 = e1->implicitConvTo(t2); 
     1485 
     1486        if (i1 && i2) 
     1487        { 
     1488        // We have the case of class vs. void*, so pick class 
     1489        if (t1->ty == Tpointer) 
     1490            i1 = 0; 
     1491        else if (t2->ty == Tpointer) 
     1492            i2 = 0; 
     1493        } 
     1494 
     1495        if (i2) 
     1496        { 
     1497        goto Lt2; 
     1498        } 
     1499        else if (i1) 
     1500        { 
     1501        goto Lt1; 
     1502        } 
     1503        else if (t1->ty == Tclass && t2->ty == Tclass) 
     1504        {   TypeClass *tc1 = (TypeClass *)t1; 
     1505        TypeClass *tc2 = (TypeClass *)t2; 
     1506 
     1507        /* Pick 'tightest' type 
     1508         */ 
     1509        ClassDeclaration *cd1 = tc1->sym->baseClass; 
     1510        ClassDeclaration *cd2 = tc2->sym->baseClass; 
     1511 
     1512        if (cd1 && cd2) 
     1513        {   t1 = cd1->type; 
     1514            t2 = cd2->type; 
     1515        } 
     1516        else if (cd1) 
     1517            t1 = cd1->type; 
     1518        else if (cd2) 
     1519            t2 = cd2->type; 
     1520        else 
     1521            goto Lincompatible; 
     1522        } 
     1523        else 
     1524        goto Lincompatible; 
     1525    } 
     1526    } 
     1527    else if (t1->ty == Tstruct && t2->ty == Tstruct) 
     1528    { 
     1529    if (((TypeStruct *)t1)->sym != ((TypeStruct *)t2)->sym) 
     1530        goto Lincompatible; 
     1531    } 
     1532    else if ((e1->op == TOKstring || e1->op == TOKnull) && e1->implicitConvTo(t2)) 
     1533    { 
     1534    goto Lt2; 
     1535    } 
     1536    else if ((e2->op == TOKstring || e2->op == TOKnull) && e2->implicitConvTo(t1)) 
     1537    { 
     1538    goto Lt1; 
     1539    } 
     1540    else if (t1->ty == Tsarray && t2->ty == Tsarray && 
     1541         e2->implicitConvTo(t1->nextOf()->arrayOf())) 
     1542    { 
     1543     Lx1: 
     1544    t = t1->nextOf()->arrayOf(); 
     1545    e1 = e1->castTo(sc, t); 
     1546    e2 = e2->castTo(sc, t); 
     1547    } 
     1548    else if (t1->ty == Tsarray && t2->ty == Tsarray && 
     1549         e1->implicitConvTo(t2->nextOf()->arrayOf())) 
     1550    { 
     1551     Lx2: 
     1552    t = t2->nextOf()->arrayOf(); 
     1553    e1 = e1->castTo(sc, t); 
     1554    e2 = e2->castTo(sc, t); 
     1555    } 
     1556    else if (t1->isintegral() && t2->isintegral()) 
     1557    { 
     1558    assert(0); 
     1559    } 
     1560    else 
     1561    { 
     1562     Lincompatible: 
     1563    return 0; 
     1564    } 
     1565Lret: 
     1566    if (!*pt) 
     1567    *pt = t; 
     1568    *pe1 = e1; 
     1569    *pe2 = e2; 
     1570#if 0 
     1571    printf("-typeMerge() %s\n", toChars()); 
     1572    if (e1->type) printf("\tt1 = %s\n", e1->type->toChars()); 
     1573    if (e2->type) printf("\tt2 = %s\n", e2->type->toChars()); 
     1574    printf("\ttype = %s\n", type->toChars()); 
     1575#endif 
     1576    //dump(0); 
     1577    return 1; 
     1578 
     1579 
     1580Lt1: 
     1581    e2 = e2->castTo(sc, t1); 
     1582    t = t1; 
     1583    goto Lret; 
     1584 
     1585Lt2: 
     1586    e1 = e1->castTo(sc, t2); 
     1587    t = t2; 
     1588    goto Lret; 
     1589} 
     1590 
     1591/************************************ 
     1592 * Bring leaves to common type. 
     1593 */ 
     1594 
     1595Expression *BinExp::typeCombine(Scope *sc) 
     1596{ 
     1597    Type *t1 = e1->type->toBasetype(); 
     1598    Type *t2 = e2->type->toBasetype(); 
    14001599 
    14011600    if (op == TOKcat) 
     
    14191618        else 
    14201619        e2 = e2->castTo(sc, t2); 
    1421         t = t1; 
    1422         goto Lagain; 
    1423     } 
    1424     } 
    1425  
    1426 Lagain: 
    1427     if (t1 == t2) 
    1428     { 
    1429     if ((t1->ty == Tstruct || t1->ty == Tclass) && 
    1430         (op == TOKmin || op == TOKadd)) 
    1431         goto Lincompatible; 
    1432     } 
    1433     else if (t1->ty == Tpointer && t2->ty == Tpointer) 
    1434     { 
    1435     // Bring pointers to compatible type 
    1436     Type *t1n = t1->nextOf(); 
    1437     Type *t2n = t2->nextOf(); 
    1438  
    1439     if (t1n == t2n) 
    1440         ; 
    1441     else if (t1n->ty == Tvoid)  // pointers to void are always compatible 
    1442         t = t2; 
    1443     else if (t2n->ty == Tvoid) 
    1444         ; 
    1445     else if (t1n->mod != t2n->mod) 
    1446     { 
    1447         t1 = t1n->mutableOf()->constOf()->pointerTo(); 
    1448         t2 = t2n->mutableOf()->constOf()->pointerTo(); 
    1449         t = t1; 
    1450         goto Lagain; 
    1451     } 
    1452     else if (t1n->ty == Tclass && t2n->ty == Tclass) 
    1453     {   ClassDeclaration *cd1 = t1n->isClassHandle(); 
    1454         ClassDeclaration *cd2 = t2n->isClassHandle(); 
    1455         int offset; 
    1456  
    1457         if (cd1->isBaseOf(cd2, &offset)) 
    1458         { 
    1459         if (offset) 
    1460             e2 = e2->castTo(sc, t); 
    1461         } 
    1462         else if (cd2->isBaseOf(cd1, &offset)) 
    1463         { 
    1464         t = t2; 
    1465         if (offset) 
    1466             e1 = e1->castTo(sc, t); 
    1467         } 
    1468         else 
    1469         goto Lincompatible; 
    1470     } 
    1471     else 
    1472         goto Lincompatible; 
    1473     } 
    1474     else if ((t1->ty == Tsarray || t1->ty == Tarray) && 
    1475          e2->op == TOKnull && t2->ty == Tpointer && t2->nextOf()->ty == Tvoid) 
    1476     {   /*  (T[n] op void*) 
    1477      *  (T[] op void*) 
    1478      */ 
    1479     goto Lx1; 
    1480     } 
    1481     else if ((t2->ty == Tsarray || t2->ty == Tarray) && 
    1482          e1->op == TOKnull && t1->ty == Tpointer && t1->nextOf()->ty == Tvoid) 
    1483     {   /*  (void* op T[n]) 
    1484      *  (void* op T[]) 
    1485      */ 
    1486     goto Lx2; 
    1487     } 
    1488     else if ((t1->ty == Tsarray || t1->ty == Tarray) && t1->implicitConvTo(t2)) 
    1489     { 
    1490     goto Lt2; 
    1491     } 
    1492     else if ((t2->ty == Tsarray || t2->ty == Tarray) && t2->implicitConvTo(t1)) 
    1493     { 
    1494     goto Lt1; 
    1495     } 
    1496     /* If one is mutable and the other invariant, then retry 
    1497      * with both of them as const 
    1498      */ 
    1499     else if ((t1->ty == Tsarray || t1->ty == Tarray || t1->ty == Tpointer) && 
    1500          (t2->ty == Tsarray || t2->ty == Tarray || t2->ty == Tpointer) && 
    1501          t1->nextOf()->mod != t2->nextOf()->mod 
    1502         ) 
    1503     { 
    1504     if (t1->ty == Tpointer) 
    1505         t1 = t1->nextOf()->mutableOf()->constOf()->pointerTo(); 
    1506     else 
    1507         t1 = t1->nextOf()->mutableOf()->constOf()->arrayOf(); 
    1508  
    1509     if (t2->ty == Tpointer) 
    1510         t2 = t2->nextOf()->mutableOf()->constOf()->pointerTo(); 
    1511     else 
    1512         t2 = t2->nextOf()->mutableOf()->constOf()->arrayOf(); 
    1513     t = t1; 
    1514     goto Lagain; 
    1515     } 
    1516     else if (t1->ty == Tclass || t2->ty == Tclass) 
    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     } 
    1563     } 
    1564     else if (t1->ty == Tstruct && t2->ty == Tstruct) 
    1565     { 
    1566     if (((TypeStruct *)t1)->sym != ((TypeStruct *)t2)->sym) 
    1567         goto Lincompatible; 
    1568     } 
    1569     else if ((e1->op == TOKstring || e1->op == TOKnull) && e1->implicitConvTo(t2)) 
    1570     { 
    1571     goto Lt2; 
    1572     } 
    1573     else if ((e2->op == TOKstring || e2->op == TOKnull) && e2->implicitConvTo(t1)) 
    1574     { 
    1575     goto Lt1; 
    1576     } 
    1577     else if (t1->ty == Tsarray && t2->ty == Tsarray && 
    1578          e2->implicitConvTo(t1->nextOf()->arrayOf())) 
    1579     { 
    1580      Lx1: 
    1581     t = t1->nextOf()->arrayOf(); 
    1582     e1 = e1->castTo(sc, t); 
    1583     e2 = e2->castTo(sc, t); 
    1584     } 
    1585     else if (t1->ty == Tsarray && t2->ty == Tsarray && 
    1586          e1->implicitConvTo(t2->nextOf()->arrayOf())) 
    1587     { 
    1588      Lx2: 
    1589     t = t2->nextOf()->arrayOf(); 
    1590     e1 = e1->castTo(sc, t); 
    1591     e2 = e2->castTo(sc, t); 
    1592     } 
    1593     else if (t1->isintegral() && t2->isintegral()) 
    1594     { 
    1595     assert(0); 
    1596     } 
    1597     else 
    1598     { 
    1599      Lincompatible: 
    1600     incompatibleTypes(); 
    1601     } 
    1602 Lret: 
    1603     if (!type) 
    1604     type = t; 
    1605 #if 0 
    1606     printf("-BinExp::typeCombine() %s\n", toChars()); 
    1607     if (e1->type) printf("\tt1 = %s\n", e1->type->toChars()); 
    1608     if (e2->type) printf("\tt2 = %s\n", e2->type->toChars()); 
    1609     printf("\ttype = %s\n", type->toChars()); 
    1610 #endif 
    1611     //dump(0); 
     1620    } 
     1621    } 
     1622    else if (op == TOKmin || op == TOKadd) 
     1623    { 
     1624    if (t1 == t2 && (t1->ty == Tstruct || t1->ty == Tclass)) 
     1625        goto Lerror; 
     1626    } 
     1627 
     1628    if (!typeMerge(sc, &type, &e1, &e2)) 
     1629    goto Lerror; 
    16121630    return this; 
    16131631 
    1614  
    1615 Lt1: 
    1616     e2 = e2->castTo(sc, t1); 
    1617     t = t1; 
    1618     goto Lret; 
    1619  
    1620 Lt2: 
    1621     e1 = e1->castTo(sc, t2); 
    1622     t = t2; 
    1623     goto Lret; 
     1632Lerror: 
     1633    incompatibleTypes(); 
     1634    type = Type::terror; 
     1635    return this; 
    16241636} 
    16251637 
  • branches/dmdfe-2.0/class.c

    r900 r902  
    816816int ClassDeclaration::isFuncHidden(FuncDeclaration *fd) 
    817817{ 
    818     //printf("ClassDeclaration::isFuncHidden(%s)\n", fd->toChars()); 
     818    //printf("ClassDeclaration::isFuncHidden(class = %s, fd = %s)\n", toChars(), fd->toChars()); 
    819819    Dsymbol *s = search(0, fd->ident, 4|2); 
    820820    if (!s) 
  • branches/dmdfe-2.0/constfold.c

    r880 r902  
    10791079    return expType(to, e1); 
    10801080 
     1081    Type *tb = to->toBasetype(); 
     1082    Type *typeb = type->toBasetype(); 
     1083 
     1084    if (e1->op == TOKstring) 
     1085    { 
     1086    if (tb->ty == Tarray && typeb->ty == Tarray && 
     1087        tb->nextOf()->size() == typeb->nextOf()->size()) 
     1088    { 
     1089        return expType(to, e1); 
     1090    } 
     1091    } 
     1092 
    10811093    if (e1->isConst() != 1) 
    10821094    return EXP_CANT_INTERPRET; 
    10831095 
    1084     Type *tb = to->toBasetype(); 
    10851096    if (tb->ty == Tbool) 
    10861097    e = new IntegerExp(loc, e1->toInteger() != 0, type); 
     
    10911102        real_t r = e1->toReal(); 
    10921103 
    1093         switch (type->toBasetype()->ty) 
     1104        switch (typeb->ty) 
    10941105        { 
    10951106        case Tint8: result = (d_int8)r; break; 
     
    14681479        e->type = type; 
    14691480    } 
    1470     else if (e1->op == TOKarrayliteral && 
     1481    else if ((e1->op == TOKarrayliteral || e1->op == TOKnull) && 
    14711482    e1->type->toBasetype()->nextOf()->equals(e2->type)) 
    14721483    { 
    1473     ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1; 
    1474  
    1475     es1 = new ArrayLiteralExp(es1->loc, (Expressions *)es1->elements->copy()); 
    1476     es1->elements->push(e2); 
     1484    ArrayLiteralExp *es1; 
     1485    if (e1->op == TOKarrayliteral) 
     1486    {   es1 = (ArrayLiteralExp *)e1; 
     1487        es1 = new ArrayLiteralExp(es1->loc, (Expressions *)es1->elements->copy()); 
     1488        es1->elements->push(e2); 
     1489    } 
     1490    else 
     1491    { 
     1492        es1 = new ArrayLiteralExp(e1->loc, e2); 
     1493    } 
    14771494    e = es1; 
    14781495 
  • branches/dmdfe-2.0/declaration.c

    r901 r902  
    8787 */ 
    8888 
     89#if V2 
    8990void Declaration::checkModify(Loc loc, Scope *sc, Type *t) 
    9091{ 
     
    148149    } 
    149150} 
     151#endif 
    150152 
    151153 
     
    660662void VarDeclaration::semantic(Scope *sc) 
    661663{ 
    662     //printf("VarDeclaration::semantic('%s', parent = '%s')\n", toChars(), sc->parent->toChars()); 
    663     //printf(" type = %s\n", type ? type->toChars() : "null"); 
    664     //printf(" stc = x%x\n", sc->stc); 
    665     //printf(" storage_class = x%x\n", storage_class); 
    666     //printf("linkage = %d\n", sc->linkage); 
     664#if 0 
     665    printf("VarDeclaration::semantic('%s', parent = '%s')\n", toChars(), sc->parent->toChars()); 
     666    printf(" type = %s\n", type ? type->toChars() : "null"); 
     667    printf(" stc = x%x\n", sc->stc); 
     668    printf(" storage_class = x%x\n", storage_class); 
     669    printf("linkage = %d\n", sc->linkage); 
    667670    //if (strcmp(toChars(), "mul") == 0) halt(); 
     671#endif 
    668672 
    669673    storage_class |= sc->stc; 
     
    11091113void VarDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 
    11101114{ 
     1115    if (storage_class & STCconst) 
     1116    buf->writestring("const "); 
     1117    if (storage_class & STCstatic) 
     1118    buf->writestring("static "); 
     1119    if (storage_class & STCauto) 
     1120    buf->writestring("auto "); 
     1121#if V2 
    11111122    if (storage_class & STCmanifest) 
    11121123    buf->writestring("manifest "); 
    1113     if (storage_class & STCstatic) 
    1114     buf->writestring("static "); 
    1115     if (storage_class & STCtls) 
    1116     buf->writestring("__tls "); 
    1117     if (storage_class & STCconst) 
    1118     buf->writestring("const "); 
    11191124    if (storage_class & STCinvariant) 
    11201125    buf->writestring("invariant "); 
     1126    if (storage_class & STCtls) 
     1127    buf->writestring("__thread "); 
     1128#endif 
    11211129 
    11221130    if (type) 
  • branches/dmdfe-2.0/declaration.h

    r901 r902  
    7070    STCpure     = 0x4000000,    // pure function 
    7171    STCtls      = 0x8000000,    // thread local 
     72    STCalias        = 0x10000000,   // alias parameter 
    7273}; 
    7374 
     
    257258    VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; } 
    258259}; 
    259  
    260260 
    261261/**************************************************************/ 
     
    567567}; 
    568568 
     569#if V2 
    569570struct PostBlitDeclaration : FuncDeclaration 
    570571{ 
     
    582583    PostBlitDeclaration *isPostBlitDeclaration() { return this; } 
    583584}; 
     585#endif 
    584586 
    585587struct DtorDeclaration : FuncDeclaration 
     
    616618 
    617619struct StaticDtorDeclaration : FuncDeclaration 
    618 
     620{   VarDeclaration *vgate;  // 'gate' variable 
     621 
    619622    StaticDtorDeclaration(Loc loc, Loc endloc); 
    620623    Dsymbol *syntaxCopy(Dsymbol *); 
  • branches/dmdfe-2.0/doc.c

    r882 r902  
    401401void ScopeDsymbol::emitMemberComments(Scope *sc) 
    402402{ 
    403     //printf("ScopeDsymbol::emitMemberComments()\n"); 
     403    //printf("ScopeDsymbol::emitMemberComments() %s\n", toChars()); 
    404404    OutBuffer *buf = sc->docbuf; 
    405405 
     
    744744        (td = parent->isTemplateDeclaration()) != NULL && 
    745745        td->onemember == this) 
    746     {   HdrGenState hgs; 
     746    {   /* It's a function template 
     747         */ 
     748        HdrGenState hgs; 
    747749        unsigned o = buf->offset; 
    748750        TypeFunction *tf = (TypeFunction *)type; 
     
    15821584    if (f && f->type) 
    15831585    { 
    1584     TypeFunction *tf = (TypeFunction *)f->type; 
     1586    TypeFunction *tf; 
     1587    if (f->originalType) 
     1588    { 
     1589        tf = (TypeFunction *)f->originalType; 
     1590    } 
     1591    else 
     1592        tf = (TypeFunction *)f->type; 
    15851593 
    15861594    if (tf->parameters) 
  • branches/dmdfe-2.0/dsymbol.c

    r883 r902  
    236236} 
    237237 
     238TemplateInstance *Dsymbol::inTemplateInstance() 
     239{ 
     240    for (Dsymbol *parent = this->parent; parent; parent = parent->parent) 
     241    { 
     242    TemplateInstance *ti = parent->isTemplateInstance(); 
     243    if (ti) 
     244        return ti; 
     245    } 
     246    return NULL; 
     247} 
    238248 
    239249int Dsymbol::isAnonymous() 
  • branches/dmdfe-2.0/dsymbol.h

    r883 r902  
    5656struct WithStatement; 
    5757struct LabelDsymbol; 
    58 struct ScopeDsymbol; 
    5958struct TemplateDeclaration; 
    6059struct TemplateInstance; 
     
    116115    Dsymbol *toParent(); 
    117116    Dsymbol *toParent2(); 
     117    TemplateInstance *inTemplateInstance(); 
    118118 
    119119    int dyncast() { return DYNCAST_DSYMBOL; }   // kludge for template.isSymbol() 
  • branches/dmdfe-2.0/expression.c

    r901 r902  
    112112    precedence[TOKfunction] = PREC_primary; 
    113113    precedence[TOKvar] = PREC_primary; 
     114#if V2 
    114115    precedence[TOKdefault] = PREC_primary; 
     116#endif 
    115117 
    116118    // post 
     
    241243 
    242244        e1 = new DotVarExp(loc, e1, tcd->vthis); 
    243         e1 = e1->semantic(sc); 
     245        e1->type = tcd->vthis->type; 
     246        // Do not call checkNestedRef() 
     247        //e1 = e1->semantic(sc); 
    244248 
    245249        // Skip up over nested functions, and get the enclosing 
    246250        // class type. 
     251        int n = 0; 
    247252        Dsymbol *s; 
    248253        for (s = tcd->toParent(); 
     
    251256        {   FuncDeclaration *f = s->isFuncDeclaration(); 
    252257            if (f->vthis) 
    253             { 
     258  &