Changeset 213

Show
Ignore:
Timestamp:
10/14/09 17:09:50 (2 years ago)
Author:
walter
Message:

1.050 and 2.035

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/mtype.c

    r202 r213  
    68486848    } 
    68496849    else 
    68506850    { 
    68516851     Ldefault: 
    68526852    Type::resolve(loc, sc, pe, pt, ps); 
    68536853    } 
    68546854} 
    68556855 
    68566856void TypeSlice::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod) 
    68576857{ 
    68586858    if (mod != this->mod) 
    68596859    {   toCBuffer3(buf, hgs, mod); 
    68606860    return; 
    68616861    } 
    68626862    next->toCBuffer2(buf, hgs, this->mod); 
    68636863 
    68646864    buf->printf("[%s .. ", lwr->toChars()); 
    68656865    buf->printf("%s]", upr->toChars()); 
    68666866} 
    68676867 
     6868/***************************** TypeNewArray *****************************/ 
     6869 
     6870/* T[new] 
     6871 */ 
     6872 
     6873TypeNewArray::TypeNewArray(Type *next) 
     6874    : TypeNext(Tnarray, next) 
     6875{ 
     6876    //printf("TypeNewArray\n"); 
     6877} 
     6878 
     6879void TypeNewArray::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod) 
     6880{ 
     6881    if (mod != this->mod) 
     6882    {   toCBuffer3(buf, hgs, mod); 
     6883    return; 
     6884    } 
     6885    next->toCBuffer2(buf, hgs, this->mod); 
     6886    buf->writestring("[new]"); 
     6887} 
     6888 
    68686889/***************************** Argument *****************************/ 
    68696890 
    68706891Argument::Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg) 
    68716892{ 
    68726893    this->type = type; 
    68736894    this->ident = ident; 
    68746895    this->storageClass = storageClass; 
    68756896    this->defaultArg = defaultArg; 
    68766897} 
    68776898 
    68786899Argument *Argument::syntaxCopy() 
    68796900{ 
    68806901    Argument *a = new Argument(storageClass, 
    68816902        type ? type->syntaxCopy() : NULL, 
    68826903        ident, 
    68836904        defaultArg ? defaultArg->syntaxCopy() : NULL); 
    68846905    return a; 
    68856906} 
    68866907 
    68876908Arguments *Argument::arraySyntaxCopy(Arguments *args) 
  • trunk/src/mtype.h

    r199 r213  
    781781    int equals(Object *o); 
    782782    Type *reliesOnTident(); 
    783783    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
    784784    void toDecoBuffer(OutBuffer *buf, int flag); 
    785785    Expression *getProperty(Loc loc, Identifier *ident); 
    786786    TypeInfoDeclaration *getTypeInfoDeclaration(); 
    787787}; 
    788788 
    789789struct TypeSlice : TypeNext 
    790790{ 
    791791    Expression *lwr; 
    792792    Expression *upr; 
    793793 
    794794    TypeSlice(Type *next, Expression *lwr, Expression *upr); 
    795795    Type *syntaxCopy(); 
    796796    Type *semantic(Loc loc, Scope *sc); 
    797797    void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 
    798798    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
    799799}; 
    800800 
     801struct TypeNewArray : TypeNext 
     802{ 
     803    TypeNewArray(Type *next); 
     804    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
     805}; 
     806 
    801807/**************************************************************/ 
    802808 
    803809//enum InOut { None, In, Out, InOut, Lazy }; 
    804810 
    805811struct Argument : Object 
    806812{ 
    807813    //enum InOut inout; 
    808814    unsigned storageClass; 
    809815    Type *type; 
    810816    Identifier *ident; 
    811817    Expression *defaultArg; 
    812818 
    813819    Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg); 
    814820    Argument *syntaxCopy(); 
    815821    Type *isLazyArray(); 
    816822    void toDecoBuffer(OutBuffer *buf); 
    817823    static Arguments *arraySyntaxCopy(Arguments *args); 
    818824    static char *argsTypesToChars(Arguments *args, int varargs); 
    819825    static void argsCppMangle(OutBuffer *buf, CppMangleState *cms, Arguments *arguments, int varargs); 
    820826    static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs); 
  • trunk/src/parse.c

    r208 r213  
    22062206    //printf("parseBasicType2()\n"); 
    22072207    while (1) 
    22082208    { 
    22092209    switch (token.value) 
    22102210    { 
    22112211        case TOKmul: 
    22122212        t = new TypePointer(t); 
    22132213        nextToken(); 
    22142214        continue; 
    22152215 
    22162216        case TOKlbracket: 
    22172217        // Handle []. Make sure things like 
    22182218        //     int[3][1] a; 
    22192219        // is (array[1] of array[3] of int) 
    22202220        nextToken(); 
    22212221        if (token.value == TOKrbracket) 
    22222222        { 
    22232223            t = new TypeDArray(t);          // [] 
    22242224            nextToken(); 
    22252225        } 
     2226        else if (token.value == TOKnew && peekNext() == TOKrbracket) 
     2227        { 
     2228            t = new TypeNewArray(t);            // [new] 
     2229            nextToken(); 
     2230            nextToken(); 
     2231        } 
    22262232        else if (isDeclaration(&token, 0, TOKrbracket, NULL)) 
    22272233        {   // It's an associative array declaration 
    22282234 
    22292235            //printf("it's an associative array\n"); 
    22302236            Type *index = parseType();      // [ type ] 
    22312237            t = new TypeAArray(t, index); 
    22322238            check(TOKrbracket); 
    22332239        } 
    22342240        else 
    22352241        { 
    22362242            //printf("it's type[expression]\n"); 
    22372243            inBrackets++; 
    22382244            Expression *e = parseExpression();      // [ expression ] 
    22392245            if (token.value == TOKslice) 
    22402246            { 
    22412247            nextToken(); 
    22422248            Expression *e2 = parseExpression(); // [ exp .. exp ] 
    22432249            t = new TypeSlice(t, e, e2); 
    22442250            } 
    22452251            else 
     
    23262332    } 
    23272333 
    23282334    // parse DeclaratorSuffixes 
    23292335    while (1) 
    23302336    { 
    23312337    switch (token.value) 
    23322338    { 
    23332339#if CARRAYDECL 
    23342340        /* Support C style array syntax: 
    23352341         *   int ident[] 
    23362342         * as opposed to D-style: 
    23372343         *   int[] ident 
    23382344         */ 
    23392345        case TOKlbracket: 
    23402346        {   // This is the old C-style post [] syntax. 
    23412347        TypeNext *ta; 
    23422348        nextToken(); 
    23432349        if (token.value == TOKrbracket) 
    23442350        {   // It's a dynamic array 
    23452351            ta = new TypeDArray(t);     // [] 
     2352            nextToken(); 
     2353        } 
     2354        else if (token.value == TOKnew && peekNext() == TOKrbracket) 
     2355        { 
     2356            t = new TypeNewArray(t);        // [new] 
     2357            nextToken(); 
    23462358            nextToken(); 
    23472359        } 
    23482360        else if (isDeclaration(&token, 0, TOKrbracket, NULL)) 
    23492361        {   // It's an associative array 
    23502362 
    23512363            //printf("it's an associative array\n"); 
    23522364            Type *index = parseType();      // [ type ] 
    23532365            check(TOKrbracket); 
    23542366            ta = new TypeAArray(t, index); 
    23552367        } 
    23562368        else 
    23572369        { 
    23582370            //printf("It's a static array\n"); 
    23592371            Expression *e = parseExpression();  // [ expression ] 
    23602372            ta = new TypeSArray(t, e); 
    23612373            check(TOKrbracket); 
    23622374        } 
    23632375 
    23642376        /* Insert ta into 
    23652377         *   ts -> ... -> t 
     
    42484260 
    42494261    //printf("Parser::isDeclarator()\n"); 
    42504262    //t->print(); 
    42514263    if (t->value == TOKassign) 
    42524264    return FALSE; 
    42534265 
    42544266    while (1) 
    42554267    { 
    42564268    parens = FALSE; 
    42574269    switch (t->value) 
    42584270    { 
    42594271        case TOKmul: 
    42604272        //case TOKand: 
    42614273        t = peek(t); 
    42624274        continue; 
    42634275 
    42644276        case TOKlbracket: 
    42654277        t = peek(t); 
    42664278        if (t->value == TOKrbracket) 
    42674279        { 
     4280            t = peek(t); 
     4281        } 
     4282        else if (t->value == TOKnew && peek(t)->value == TOKrbracket) 
     4283        { 
     4284            t = peek(t); 
    42684285            t = peek(t); 
    42694286        } 
    42704287        else if (isDeclaration(t, 0, TOKrbracket, &t)) 
    42714288        {   // It's an associative array declaration 
    42724289            t = peek(t); 
    42734290        } 
    42744291        else 
    42754292        { 
    42764293            // [ expression ] 
    42774294            // [ expression .. expression ] 
    42784295            if (!isExpression(&t)) 
    42794296            return FALSE; 
    42804297            if (t->value == TOKslice) 
    42814298            {   t = peek(t); 
    42824299            if (!isExpression(&t)) 
    42834300                return FALSE; 
    42844301            } 
    42854302            if (t->value != TOKrbracket) 
    42864303            return FALSE; 
    42874304            t = peek(t);