mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-04-30 07:00:46 +03:00

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.
61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
|
|
#include "gen/llvm.h"
|
|
#include "gen/tollvm.h"
|
|
#include "ir/irfunction.h"
|
|
|
|
#include <sstream>
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
IrFunction::IrFunction(FuncDeclaration* fd)
|
|
{
|
|
decl = fd;
|
|
|
|
Type* t = DtoDType(fd->type);
|
|
assert(t->ty == Tfunction);
|
|
type = (TypeFunction*)t;
|
|
func = NULL;
|
|
allocapoint = NULL;
|
|
|
|
queued = false;
|
|
defined = false;
|
|
|
|
retArg = NULL;
|
|
thisVar = NULL;
|
|
nestedVar = NULL;
|
|
_arguments = NULL;
|
|
_argptr = NULL;
|
|
dwarfSubProg = NULL;
|
|
|
|
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();
|
|
}
|