Changeset 409

Show
Ignore:
Timestamp:
03/06/10 01:31:05 (2 years ago)
Author:
walter
Message:

bugzilla 3378 [tdpl] ++x should be an lvalue

Files:

Legend:

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

    r408 r409  
    55425542} 
    55435543 
     5544#if DMDV2 
     5545int BinAssignExp::isLvalue() 
     5546{ 
     5547    return 1; 
     5548} 
     5549 
     5550Expression *BinAssignExp::toLvalue(Scope *sc, Expression *ex) 
     5551{   Expression *e; 
     5552 
     5553    if (e1->op == TOKvar) 
     5554    { 
     5555    /* Convert (e1 op= e2) to 
     5556     *    e1 op= e2; 
     5557     *    e1 
     5558     */ 
     5559    e = e1->copy(); 
     5560    e = new CommaExp(loc, this, e); 
     5561    e = e->semantic(sc); 
     5562    } 
     5563    else 
     5564    { 
     5565    /* Convert (e1 op= e2) to 
     5566     *    ref v = e1; 
     5567     *    v op= e2; 
     5568     *    v 
     5569     */ 
     5570 
     5571    // ref v = e1; 
     5572    Identifier *id = Lexer::uniqueId("__assignop"); 
     5573    ExpInitializer *ei = new ExpInitializer(loc, e1); 
     5574    VarDeclaration *v = new VarDeclaration(loc, e1->type, id, ei); 
     5575    v->storage_class |= STCref | STCforeach; 
     5576    Expression *de = new DeclarationExp(loc, v); 
     5577 
     5578    // v op= e2 
     5579    e1 = new VarExp(e1->loc, v); 
     5580 
     5581    e = new CommaExp(loc, de, this); 
     5582    e = new CommaExp(loc, e, new VarExp(loc, v)); 
     5583    e = e->semantic(sc); 
     5584    } 
     5585    return e; 
     5586} 
     5587 
     5588Expression *BinAssignExp::modifiableLvalue(Scope *sc, Expression *e) 
     5589{ 
     5590    return toLvalue(sc, this); 
     5591} 
     5592 
     5593#endif 
     5594 
    55445595/************************************************************/ 
    55455596 
  • trunk/src/expression.h

    r403 r409  
    792792 
    793793    Expression *op_overload(Scope *sc); 
     794 
     795    int isLvalue(); 
     796    Expression *toLvalue(Scope *sc, Expression *ex); 
     797    Expression *modifiableLvalue(Scope *sc, Expression *e); 
    794798}; 
    795799 
  • trunk/src/linux.mak

    r259 r409  
    3838    hdrgen.o delegatize.o aa.o ti_achar.o toir.o interpret.o traits.o \ 
    3939    builtin.o clone.o aliasthis.o \ 
    40     man.o arrayop.o port.o response.o async.o json.o
     40    man.o arrayop.o port.o response.o async.o json.o speller.o
    4141    libelf.o elfobj.o 
    4242 
     
    8181    $(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \ 
    8282    $(ROOT)/stringtable.h $(ROOT)/stringtable.c \ 
    83     $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c 
     83    $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c \ 
     84    $(ROOT)/speller.h $(ROOT)/speller.c 
    8485 
    8586 
     
    433434scope.o: scope.c 
    434435    $(CC) -c $(CFLAGS) $< 
     436 
     437speller.o: $(ROOT)/speller.c 
     438    $(CC) -c $(GFLAGS) -I$(ROOT) $< 
    435439 
    436440statement.o: statement.c 
  • trunk/src/osx.mak

    r275 r409  
    4646    hdrgen.o delegatize.o aa.o ti_achar.o toir.o interpret.o traits.o \ 
    4747    builtin.o clone.o aliasthis.o \ 
    48     man.o arrayop.o port.o response.o async.o json.o
     48    man.o arrayop.o port.o response.o async.o json.o speller.o
    4949    libmach.o machobj.o 
    5050 
     
    8989    $(ROOT)/gnuc.h $(ROOT)/gnuc.c $(ROOT)/man.c \ 
    9090    $(ROOT)/stringtable.h $(ROOT)/stringtable.c \ 
    91     $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c 
     91    $(ROOT)/response.c $(ROOT)/async.h $(ROOT)/async.c \ 
     92    $(ROOT)/speller.h $(ROOT)/speller.c 
    9293 
    9394 
     
    441442scope.o: scope.c 
    442443    $(CC) -c $(CFLAGS) $< 
     444 
     445speller.o: $(ROOT)/speller.c 
     446    $(CC) -c $(GFLAGS) -I$(ROOT) $< 
    443447 
    444448statement.o: statement.c