Changeset 261
- Timestamp:
- 11/22/09 08:48:37 (15 years ago)
- Files:
-
- trunk/src/statement.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/statement.c
r253 r261 4295 4295 4296 4296 ThrowStatement::ThrowStatement(Loc loc, Expression *exp) 4297 4297 : Statement(loc) 4298 4298 { 4299 4299 this->exp = exp; 4300 4300 } 4301 4301 4302 4302 Statement *ThrowStatement::syntaxCopy() 4303 4303 { 4304 4304 ThrowStatement *s = new ThrowStatement(loc, exp->syntaxCopy()); 4305 4305 return s; 4306 4306 } 4307 4307 4308 4308 Statement *ThrowStatement::semantic(Scope *sc) 4309 4309 { 4310 4310 //printf("ThrowStatement::semantic()\n"); 4311 4311 4312 4312 FuncDeclaration *fd = sc->parent->isFuncDeclaration(); 4313 4313 fd->hasReturnExp |= 2; 4314 4314 4315 #if DMDV1 4316 // See bugzilla 3388. Should this be or not? 4315 4317 if (sc->incontract) 4316 4318 error("Throw statements cannot be in contracts"); 4319 #endif 4317 4320 exp = exp->semantic(sc); 4318 4321 exp = resolveProperties(sc, exp); 4319 4322 if (!exp->type->toBasetype()->isClassHandle()) 4320 4323 error("can only throw class objects, not type %s", exp->type->toChars()); 4321 4324 return this; 4322 4325 } 4323 4326 4324 4327 int ThrowStatement::blockExit() 4325 4328 { 4326 4329 return BEthrow; // obviously 4327 4330 } 4328 4331 4329 4332 4330 4333 void ThrowStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 4331 4334 { 4332 4335 buf->printf("throw "); 4333 4336 exp->toCBuffer(buf, hgs); 4334 4337 buf->writeByte(';'); 4335 4338 buf->writenl(); 4336 4339 }
