Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 578

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

add attributes to delegate printing

Files:

Legend:

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

    r569 r578  
    47264726    if (next) 
    47274727        next->toCBuffer2(buf, hgs, 0); 
    47284728    if (hgs->ddoc != 1) 
    47294729    { 
    47304730        switch (linkage) 
    47314731        { 
    47324732            case LINKd:         p = NULL;       break; 
    47334733            case LINKc:         p = " C";       break; 
    47344734            case LINKwindows:   p = " Windows"; break; 
    47354735            case LINKpascal:    p = " Pascal";  break; 
    47364736            case LINKcpp:       p = " C++";     break; 
    47374737            default: 
    47384738                assert(0); 
    47394739        } 
    47404740    } 
    47414741 
    47424742    if (!hgs->hdrgen && p) 
    47434743        buf->writestring(p); 
    47444744    buf->writestring(" function"); 
    47454745    Parameter::argsToCBuffer(buf, hgs, parameters, varargs); 
    4746  
     4746    attributesToCBuffer(buf, mod); 
     4747    inuse--; 
     4748
     4749 
     4750void TypeFunction::attributesToCBuffer(OutBuffer *buf, int mod) 
     4751
    47474752    /* Use postfix style for attributes 
    47484753     */ 
    47494754    if (mod != this->mod) 
    47504755    { 
    47514756        modToBuffer(buf); 
    47524757    } 
    47534758    if (ispure) 
    47544759        buf->writestring(" pure"); 
    47554760    if (isnothrow) 
    47564761        buf->writestring(" nothrow"); 
    47574762    if (isproperty) 
    47584763        buf->writestring(" @property"); 
    47594764    if (isref) 
    47604765        buf->writestring(" ref"); 
    47614766 
    47624767    switch (trust) 
    47634768    { 
    47644769        case TRUSTsystem: 
    4765             buf->writestring("@system "); 
     4770            buf->writestring(" @system"); 
    47664771            break; 
    47674772 
    47684773        case TRUSTtrusted: 
    47694774            buf->writestring(" @trusted"); 
    47704775            break; 
    47714776 
    47724777        case TRUSTsafe: 
    47734778            buf->writestring(" @safe"); 
    47744779            break; 
    47754780    } 
    4776     inuse--; 
    47774781} 
    47784782 
    47794783Type *TypeFunction::semantic(Loc loc, Scope *sc) 
    47804784{ 
    47814785    if (deco)                   // if semantic() already run 
    47824786    { 
    47834787        //printf("already done\n"); 
    47844788        return this; 
    47854789    } 
    47864790    //printf("TypeFunction::semantic() this = %p\n", this); 
    47874791    //printf("TypeFunction::semantic() %s, sc->stc = %llx, fargs = %p\n", toChars(), sc->stc, fargs); 
    47884792 
    47894793    /* Copy in order to not mess up original. 
    47904794     * This can produce redundant copies if inferring return type, 
    47914795     * as semantic() will get called again on this. 
    47924796     */ 
    47934797    TypeFunction *tf = (TypeFunction *)mem.malloc(sizeof(TypeFunction)); 
    47944798    memcpy(tf, this, sizeof(TypeFunction)); 
    47954799    if (parameters) 
    47964800    {   tf->parameters = (Parameters *)parameters->copy(); 
     
    52625266    if (this == to) 
    52635267        return MATCHexact; 
    52645268#if 0 // not allowing covariant conversions because it interferes with overriding 
    52655269    if (to->ty == Tdelegate && this->nextOf()->covariant(to->nextOf()) == 1) 
    52665270        return MATCHconvert; 
    52675271#endif 
    52685272    return MATCHnomatch; 
    52695273} 
    52705274 
    52715275void TypeDelegate::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod) 
    52725276{ 
    52735277    if (mod != this->mod) 
    52745278    {   toCBuffer3(buf, hgs, mod); 
    52755279        return; 
    52765280    } 
    52775281    TypeFunction *tf = (TypeFunction *)next; 
    52785282 
    52795283    tf->next->toCBuffer2(buf, hgs, 0); 
    52805284    buf->writestring(" delegate"); 
    52815285    Parameter::argsToCBuffer(buf, hgs, tf->parameters, tf->varargs); 
     5286    tf->attributesToCBuffer(buf, mod); 
    52825287} 
    52835288 
    52845289Expression *TypeDelegate::defaultInit(Loc loc) 
    52855290{ 
    52865291#if LOGDEFAULTINIT 
    52875292    printf("TypeDelegate::defaultInit() '%s'\n", toChars()); 
    52885293#endif 
    52895294    return new NullExp(loc, this); 
    52905295} 
    52915296 
    52925297int TypeDelegate::isZeroInit(Loc loc) 
    52935298{ 
    52945299    return 1; 
    52955300} 
    52965301 
    52975302int TypeDelegate::checkBoolean() 
    52985303{ 
    52995304    return TRUE; 
    53005305} 
    53015306 
  • trunk/src/mtype.h

    r523 r578  
    551551 
    552552    Parameters *parameters;     // function parameters 
    553553    int varargs;        // 1: T t, ...) style for variable number of arguments 
    554554                        // 2: T t ...) style for variable number of arguments 
    555555    bool isnothrow;     // true: nothrow 
    556556    bool ispure;        // true: pure 
    557557    bool isproperty;    // can be called without parentheses 
    558558    bool isref;         // true: returns a reference 
    559559    enum LINK linkage;  // calling convention 
    560560    enum TRUST trust;   // level of trust 
    561561    Expressions *fargs; // function arguments 
    562562 
    563563    int inuse; 
    564564 
    565565    TypeFunction(Parameters *parameters, Type *treturn, int varargs, enum LINK linkage, StorageClass stc = 0); 
    566566    Type *syntaxCopy(); 
    567567    Type *semantic(Loc loc, Scope *sc); 
    568568    void toDecoBuffer(OutBuffer *buf, int flag); 
    569569    void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 
    570570    void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 
     571    void attributesToCBuffer(OutBuffer *buf, int mod); 
    571572    MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 
    572573    TypeInfoDeclaration *getTypeInfoDeclaration(); 
    573574    Type *reliesOnTident(); 
    574575#if CPP_MANGLE 
    575576    void toCppMangle(OutBuffer *buf, CppMangleState *cms); 
    576577#endif 
    577578    bool parameterEscapes(Parameter *p); 
    578579 
    579580    int callMatch(Expression *ethis, Expressions *toargs, int flag = 0); 
    580581    type *toCtype(); 
    581582    enum RET retStyle(); 
    582583 
    583584    unsigned totym(); 
    584585}; 
    585586 
    586587struct TypeDelegate : TypeNext 
    587588{ 
    588589    // .next is a TypeFunction 
    589590 
    590591    TypeDelegate(Type *t);