mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
[svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
It is now possible to add label scopes in IrFunction and all labels names will be prefixed accordingly. Also disallow goto into finally blocks. Fixes nocompile/finally_02 and others.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "gen/tollvm.h"
|
||||
#include "ir/irfunction.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -29,4 +31,31 @@ IrFunction::IrFunction(FuncDeclaration* fd)
|
||||
|
||||
srcfileArg = NULL;
|
||||
msgArg = NULL;
|
||||
|
||||
nextUnique.push(0);
|
||||
}
|
||||
|
||||
std::string IrFunction::getScopedLabelName(const char* ident)
|
||||
{
|
||||
if(labelScopes.empty())
|
||||
return std::string(ident);
|
||||
|
||||
std::string result = "__";
|
||||
for(unsigned int i = 0; i < labelScopes.size(); ++i)
|
||||
result += labelScopes[i] + "_";
|
||||
return result + ident;
|
||||
}
|
||||
|
||||
void IrFunction::pushUniqueLabelScope(const char* name)
|
||||
{
|
||||
std::ostringstream uniquename;
|
||||
uniquename << name << nextUnique.top()++;
|
||||
nextUnique.push(0);
|
||||
labelScopes.push_back(uniquename.str());
|
||||
}
|
||||
|
||||
void IrFunction::popLabelScope()
|
||||
{
|
||||
labelScopes.pop_back();
|
||||
nextUnique.pop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user