mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 07:00:46 +03:00
There is no real need in FuncDeclaration::labmap
This commit is contained in:
parent
e4a7cf87d0
commit
a0b9f95869
9 changed files with 20 additions and 52 deletions
|
@ -223,43 +223,24 @@ LLValue *DtoModuleFileName(Module* M, const Loc& loc)
|
|||
}
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||
// LABEL HELPER
|
||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
LabelStatement* DtoLabelStatement(Identifier* ident)
|
||||
{
|
||||
FuncDeclaration* fd = gIR->func()->decl;
|
||||
FuncDeclaration::LabelMap::iterator iter = fd->labmap.find(ident->toChars());
|
||||
if (iter == fd->labmap.end())
|
||||
{
|
||||
if (fd->returnLabel && fd->returnLabel->ident->equals(ident))
|
||||
{
|
||||
assert(fd->returnLabel->statement);
|
||||
return fd->returnLabel->statement;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GOTO HELPER
|
||||
////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
void DtoGoto(Loc& loc, Identifier* target, TryFinallyStatement* sourceFinally)
|
||||
void DtoGoto(Loc &loc, LabelDsymbol *target, TryFinallyStatement *sourceFinally)
|
||||
{
|
||||
assert(!gIR->scopereturned());
|
||||
|
||||
LabelStatement* lblstmt = DtoLabelStatement(target);
|
||||
if(!lblstmt) {
|
||||
error(loc, "the label %s does not exist", target->toChars());
|
||||
LabelStatement *lblstmt = target->statement;
|
||||
if (!lblstmt)
|
||||
{
|
||||
error(loc, "the label %s does not exist", target->ident->toChars());
|
||||
fatal();
|
||||
}
|
||||
|
||||
// find target basic block
|
||||
std::string labelname = gIR->func()->gen->getScopedLabelName(target->toChars());
|
||||
llvm::BasicBlock*& targetBB = gIR->func()->gen->labelToBB[labelname];
|
||||
std::string labelname = gIR->func()->gen->getScopedLabelName(target->ident->toChars());
|
||||
llvm::BasicBlock* &targetBB = gIR->func()->gen->labelToBB[labelname];
|
||||
if (targetBB == NULL)
|
||||
targetBB = llvm::BasicBlock::Create(gIR->context(), "label_" + labelname, gIR->topfunc());
|
||||
|
||||
|
@ -268,7 +249,8 @@ void DtoGoto(Loc& loc, Identifier* target, TryFinallyStatement* sourceFinally)
|
|||
|
||||
// goto into finally blocks is forbidden by the spec
|
||||
// but should work fine
|
||||
if(lblstmt->tf != sourceFinally) {
|
||||
if (lblstmt->tf != sourceFinally)
|
||||
{
|
||||
error(loc, "spec disallows goto into or out of finally block");
|
||||
fatal();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue