comparison gen/statements.cpp @ 1636:332925de1881

Fix #398. Tested by Deewiant.
author Christian Kamm <kamm incasoftware de>
date Mon, 08 Mar 2010 17:44:38 +0100
parents 8d086d552909
children 638a823ace45
comparison
equal deleted inserted replaced
1635:601d3eea4a68 1636:332925de1881
293 // rewrite scope 293 // rewrite scope
294 gIR->scope() = IRScope(whilebodybb,endbb); 294 gIR->scope() = IRScope(whilebodybb,endbb);
295 295
296 // while body code 296 // while body code
297 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,whilebb,endbb)); 297 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,whilebb,endbb));
298 body->toIR(p); 298 if (body)
299 body->toIR(p);
299 p->func()->gen->targetScopes.pop_back(); 300 p->func()->gen->targetScopes.pop_back();
300 301
301 // loop 302 // loop
302 if (!gIR->scopereturned()) 303 if (!gIR->scopereturned())
303 llvm::BranchInst::Create(whilebb, gIR->scopebb()); 304 llvm::BranchInst::Create(whilebb, gIR->scopebb());
329 // replace current scope 330 // replace current scope
330 gIR->scope() = IRScope(dowhilebb,condbb); 331 gIR->scope() = IRScope(dowhilebb,condbb);
331 332
332 // do-while body code 333 // do-while body code
333 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,condbb,endbb)); 334 p->func()->gen->targetScopes.push_back(IRTargetScope(this,NULL,condbb,endbb));
334 body->toIR(p); 335 if (body)
336 body->toIR(p);
335 p->func()->gen->targetScopes.pop_back(); 337 p->func()->gen->targetScopes.pop_back();
336 338
337 // branch to condition block 339 // branch to condition block
338 llvm::BranchInst::Create(condbb, gIR->scopebb()); 340 llvm::BranchInst::Create(condbb, gIR->scopebb());
339 gIR->scope() = IRScope(condbb,endbb); 341 gIR->scope() = IRScope(condbb,endbb);
399 401
400 // rewrite scope 402 // rewrite scope
401 gIR->scope() = IRScope(forbodybb,forincbb); 403 gIR->scope() = IRScope(forbodybb,forincbb);
402 404
403 // do for body code 405 // do for body code
404 body->toIR(p); 406 if (body)
407 body->toIR(p);
405 408
406 // move into the for increment block 409 // move into the for increment block
407 if (!gIR->scopereturned()) 410 if (!gIR->scopereturned())
408 llvm::BranchInst::Create(forincbb, gIR->scopebb()); 411 llvm::BranchInst::Create(forincbb, gIR->scopebb());
409 gIR->scope() = IRScope(forincbb, endbb); 412 gIR->scope() = IRScope(forincbb, endbb);