mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Reimplemented support for nested functions/class using a new approach. Added error on taking address of intrinsic. Fixed problems with the ->syntaxCopy of TypeFunction delegate exp. Removed DtoDType and replaced all uses with ->toBasetype() instead. Removed unused inplace stuff. Fixed a bunch of issues in the runtime unittests, not complete yet. Added mini tests.
66 lines
1.4 KiB
C++
66 lines
1.4 KiB
C++
|
|
#include "gen/llvm.h"
|
|
#include "gen/tollvm.h"
|
|
#include "ir/irfunction.h"
|
|
|
|
#include <sstream>
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
IrFunction::IrFunction(FuncDeclaration* fd)
|
|
{
|
|
decl = fd;
|
|
|
|
Type* t = fd->type->toBasetype();
|
|
assert(t->ty == Tfunction);
|
|
type = (TypeFunction*)t;
|
|
func = NULL;
|
|
allocapoint = NULL;
|
|
|
|
queued = false;
|
|
defined = false;
|
|
|
|
retArg = NULL;
|
|
thisArg = NULL;
|
|
nestArg = 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();
|
|
}
|