Changeset 640

Show
Ignore:
Timestamp:
08/28/10 15:24:44 (1 year ago)
Author:
walter
Message:

Issue 4278 - allow inlining of super calls (undo limitations of bug3500's fix)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dmd-1.x/src/e2ir.c

    r621 r640  
    30693069            switch (ex->op) 
    30703070            { 
    3071                 case TOKsuper:          // super.member() calls directly 
     3071                case TOKsuper:          // super(args) ctor calls 
    30723072                case TOKdottype:        // type.member() calls directly 
    30733073                    directcall = 1; 
  • branches/dmd-1.x/src/expression.c

    r639 r640  
    61856185     *  array.id(args) into id(array,args) 
    61866186     *  aa.remove(arg) into delete aa[arg] 
     6187     *  super.id(args) into parent.id(args) 
    61876188     */ 
    61886189    if (e1->op == TOKdot) 
     
    62236224                e1 = new IdentifierExp(dotid->loc, dotid->ident); 
    62246225#endif 
     6226            } 
     6227            else if (e1ty == Tclass && dotid->e1->op == TOKsuper) 
     6228            { 
     6229                // rewrite super.id into this.baseclass.id 
     6230 
     6231                FuncDeclaration *fd = hasThis(sc); 
     6232 
     6233                Dsymbol *s = fd->toParent(); 
     6234                while (s && s->isTemplateInstance()) 
     6235                    s = s->toParent(); 
     6236 
     6237                ClassDeclaration *cd = s->isClassDeclaration(); 
     6238                Expression *dte = new DotTypeExp(dotid->loc, new ThisExp(dotid->loc), cd->baseClass); 
     6239                e1 = new DotIdExp(dotid->loc, dte, dotid->ident); 
    62256240            } 
    62266241        } 
     
    64966511    else if (e1->op == TOKsuper) 
    64976512    { 
     6513        // TODO: rewrite this to lower super(...) to baseclass(...) ? 
    64986514        // Base class constructor call 
    64996515        ClassDeclaration *cd = NULL; 
  • branches/dmd-1.x/src/inline.c

    r505 r640  
    282282int CallExp::inlineCost(InlineCostState *ics) 
    283283{ 
    284     // Bugzilla 3500: super.func() calls must be devirtualized, and the inliner 
    285     // can't handle that at present. 
    286     if (e1->op == TOKdotvar && ((DotVarExp *)e1)->e1->op == TOKsuper) 
    287         return COST_MAX; 
    288  
    289284    return 1 + e1->inlineCost(ics) + arrayInlineCost(ics, arguments); 
    290285} 
  • trunk/src/e2ir.c

    r621 r640  
    33633363            switch (ex->op) 
    33643364            { 
    3365                 case TOKsuper:          // super.member() calls directly 
     3365                case TOKsuper:          // super(args) ctor calls 
    33663366                case TOKdottype:        // type.member() calls directly 
    33673367                    directcall = 1; 
  • trunk/src/expression.c

    r639 r640  
    65266526     *  array.id(args) into .id(array,args) 
    65276527     *  aa.remove(arg) into delete aa[arg] 
     6528     *  super.id(args) into parent.id(args) 
    65286529     */ 
    65296530    if (e1->op == TOKdot) 
     
    65736574#endif 
    65746575            } 
     6576            else if (e1ty == Tclass && dotid->e1->op == TOKsuper) 
     6577            { 
     6578                // rewrite super.id into this.baseclass.id 
     6579 
     6580                FuncDeclaration *fd = hasThis(sc); 
     6581 
     6582                Dsymbol *s = fd->toParent(); 
     6583                while (s && s->isTemplateInstance()) 
     6584                    s = s->toParent(); 
     6585 
     6586                ClassDeclaration *cd = s->isClassDeclaration(); 
     6587                Expression *dte = new DotTypeExp(dotid->loc, new ThisExp(dotid->loc), cd->baseClass); 
     6588                e1 = new DotIdExp(dotid->loc, dte, dotid->ident); 
     6589            } 
     6590 
    65756591         L2: 
    65766592            ; 
     
    69406956    else if (e1->op == TOKsuper) 
    69416957    { 
     6958        // TODO: rewrite this to lower super(...) to baseclass(...) ? 
    69426959        // Base class constructor call 
    69436960        ClassDeclaration *cd = NULL; 
  • trunk/src/inline.c

    r520 r640  
    283283int CallExp::inlineCost(InlineCostState *ics) 
    284284{ 
    285     // Bugzilla 3500: super.func() calls must be devirtualized, and the inliner 
    286     // can't handle that at present. 
    287     if (e1->op == TOKdotvar && ((DotVarExp *)e1)->e1->op == TOKsuper) 
    288         return COST_MAX; 
    289  
    290285    return 1 + e1->inlineCost(ics) + arrayInlineCost(ics, arguments); 
    291286}