comparison gen/llvmhelpers.cpp @ 1145:40caa8207b3e

Moved IRTargetScopeS from IRState into IrFunction, fixes #240 .
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Thu, 26 Mar 2009 18:46:21 +0100
parents f99a3b393c03
children dbe4af57b240
comparison
equal deleted inserted replaced
1144:cdda73cf2f8a 1145:40caa8207b3e
246 LabelStatement* lblstmt = dynamic_cast<LabelStatement*>(target); 246 LabelStatement* lblstmt = dynamic_cast<LabelStatement*>(target);
247 if (lblstmt) 247 if (lblstmt)
248 target = lblstmt->enclosingScopeExit; 248 target = lblstmt->enclosingScopeExit;
249 249
250 // figure out up until what handler we need to emit 250 // figure out up until what handler we need to emit
251 IRState::TargetScopeVec::reverse_iterator targetit; 251 IrFunction::TargetScopeVec::reverse_iterator targetit = gIR->func()->targetScopes.rbegin();
252 for (targetit = gIR->targetScopes.rbegin(); targetit != gIR->targetScopes.rend(); ++targetit) { 252 IrFunction::TargetScopeVec::reverse_iterator it_end = gIR->func()->targetScopes.rend();
253 while(targetit != it_end) {
253 if (targetit->s == target) { 254 if (targetit->s == target) {
254 break; 255 break;
255 } 256 }
256 } 257 ++targetit;
257 258 }
258 if (target && targetit == gIR->targetScopes.rend()) { 259
260 if (target && targetit == it_end) {
259 if (lblstmt) 261 if (lblstmt)
260 error(loc, "cannot goto into try, volatile or synchronized statement at %s", target->loc.toChars()); 262 error(loc, "cannot goto into try, volatile or synchronized statement at %s", target->loc.toChars());
261 else 263 else
262 error(loc, "internal error, cannot find jump path to statement at %s", target->loc.toChars()); 264 error(loc, "internal error, cannot find jump path to statement at %s", target->loc.toChars());
263 return; 265 return;
268 // 270 //
269 271
270 // since the labelstatements possibly inside are private 272 // since the labelstatements possibly inside are private
271 // and might already exist push a label scope 273 // and might already exist push a label scope
272 gIR->func()->pushUniqueLabelScope("enclosing"); 274 gIR->func()->pushUniqueLabelScope("enclosing");
273 IRState::TargetScopeVec::reverse_iterator it; 275 IrFunction::TargetScopeVec::reverse_iterator it = gIR->func()->targetScopes.rbegin();
274 for (it = gIR->targetScopes.rbegin(); it != targetit; ++it) { 276 while (it != targetit) {
275 if (it->enclosinghandler) 277 if (it->enclosinghandler)
276 it->enclosinghandler->emitCode(gIR); 278 it->enclosinghandler->emitCode(gIR);
279 ++it;
277 } 280 }
278 gIR->func()->popLabelScope(); 281 gIR->func()->popLabelScope();
279 } 282 }
280 283
281 /****************************************************************************************/ 284 /****************************************************************************************/