Changeset 587
- Timestamp:
- 07/25/10 02:09:37 (14 years ago)
- Files:
-
- branches/dmd-1.x/src/expression.c (modified) (1 diff)
- trunk/src/expression.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/expression.c
r585 r587 6035 6035 6036 6036 DelegateExp::DelegateExp(Loc loc, Expression *e, FuncDeclaration *f) 6037 6037 : UnaExp(loc, TOKdelegate, sizeof(DelegateExp), e) 6038 6038 { 6039 6039 this->func = f; 6040 6040 } 6041 6041 6042 6042 Expression *DelegateExp::semantic(Scope *sc) 6043 6043 { 6044 6044 #if LOGSEMANTIC 6045 6045 printf("DelegateExp::semantic('%s')\n", toChars()); 6046 6046 #endif 6047 6047 if (!type) 6048 6048 { 6049 6049 e1 = e1->semantic(sc); 6050 6050 type = new TypeDelegate(func->type); 6051 6051 type = type->semantic(loc, sc); 6052 6052 AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration(); 6053 6053 if (func->needThis()) 6054 6054 e1 = getRightThis(loc, sc, ad, e1, func); 6055 if (ad && ad->type != e1->type) 6056 { // A downcast is required for interfaces, see Bugzilla 3706 6057 e1 = new CastExp(loc, e1, ad->type); 6058 e1 = e1->semantic(sc); 6059 } 6055 6060 } 6056 6061 return this; 6057 6062 } 6058 6063 6059 6064 void DelegateExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 6060 6065 { 6061 6066 buf->writeByte('&'); 6062 6067 if (!func->isNested()) 6063 6068 { 6064 6069 expToCBuffer(buf, hgs, e1, PREC_primary); 6065 6070 buf->writeByte('.'); 6066 6071 } 6067 6072 buf->writestring(func->toChars()); 6068 6073 } 6069 6074 6070 6075 /************************************************************/ 6071 6076 6072 6077 DotTypeExp::DotTypeExp(Loc loc, Expression *e, Dsymbol *s) 6073 6078 : UnaExp(loc, TOKdottype, sizeof(DotTypeExp), e) 6074 6079 { trunk/src/expression.c
r585 r587 6370 6370 DelegateExp::DelegateExp(Loc loc, Expression *e, FuncDeclaration *f, int hasOverloads) 6371 6371 : UnaExp(loc, TOKdelegate, sizeof(DelegateExp), e) 6372 6372 { 6373 6373 this->func = f; 6374 6374 this->hasOverloads = hasOverloads; 6375 6375 } 6376 6376 6377 6377 Expression *DelegateExp::semantic(Scope *sc) 6378 6378 { 6379 6379 #if LOGSEMANTIC 6380 6380 printf("DelegateExp::semantic('%s')\n", toChars()); 6381 6381 #endif 6382 6382 if (!type) 6383 6383 { 6384 6384 e1 = e1->semantic(sc); 6385 6385 type = new TypeDelegate(func->type); 6386 6386 type = type->semantic(loc, sc); 6387 6387 AggregateDeclaration *ad = func->toParent()->isAggregateDeclaration(); 6388 6388 if (func->needThis()) 6389 6389 e1 = getRightThis(loc, sc, ad, e1, func); 6390 if (ad && ad->type != e1->type) 6391 { // A downcast is required for interfaces, see Bugzilla 3706 6392 e1 = new CastExp(loc, e1, ad->type); 6393 e1 = e1->semantic(sc); 6394 } 6390 6395 } 6391 6396 return this; 6392 6397 } 6393 6398 6394 6399 void DelegateExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 6395 6400 { 6396 6401 buf->writeByte('&'); 6397 6402 if (!func->isNested()) 6398 6403 { 6399 6404 expToCBuffer(buf, hgs, e1, PREC_primary); 6400 6405 buf->writeByte('.'); 6401 6406 } 6402 6407 buf->writestring(func->toChars()); 6403 6408 } 6404 6409 6405 6410 /************************************************************/ 6406 6411 6407 6412 DotTypeExp::DotTypeExp(Loc loc, Expression *e, Dsymbol *s) 6408 6413 : UnaExp(loc, TOKdottype, sizeof(DotTypeExp), e) 6409 6414 {
