mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 10:57:35 +03:00
Some minor changes to handling of variables referenced from nested functions in D2 .
Added generation of new 'void*[4] reserved;' !ModuleInfo member .
This commit is contained in:
parent
f6997cb604
commit
092381577f
3 changed files with 33 additions and 14 deletions
|
@ -1163,7 +1163,11 @@ void VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
|
||||||
fdthis->getLevel(loc, fdv);
|
fdthis->getLevel(loc, fdv);
|
||||||
nestedref = 1;
|
nestedref = 1;
|
||||||
fdv->nestedFrameRef = 1;
|
fdv->nestedFrameRef = 1;
|
||||||
|
#if IN_LLVM
|
||||||
|
#if DMDV1
|
||||||
fdv->nestedVars.insert(this);
|
fdv->nestedVars.insert(this);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
//printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars());
|
//printf("var %s in function %s is nested ref\n", toChars(), fdv->toChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -673,14 +673,12 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
||||||
if (global.params.symdebug)
|
if (global.params.symdebug)
|
||||||
DtoDwarfLocalVariable(thismem, fd->vthis);
|
DtoDwarfLocalVariable(thismem, fd->vthis);
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV1
|
||||||
if (fd->vthis->nestedrefs.dim)
|
|
||||||
#else
|
|
||||||
if (fd->vthis->nestedref)
|
if (fd->vthis->nestedref)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
fd->nestedVars.insert(fd->vthis);
|
fd->nestedVars.insert(fd->vthis);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// give arguments storage
|
// give arguments storage
|
||||||
|
@ -698,14 +696,12 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
||||||
IrLocal* irloc = vd->ir.irLocal;
|
IrLocal* irloc = vd->ir.irLocal;
|
||||||
assert(irloc);
|
assert(irloc);
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV1
|
||||||
if (vd->nestedrefs.dim)
|
|
||||||
#else
|
|
||||||
if (vd->nestedref)
|
if (vd->nestedref)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
fd->nestedVars.insert(vd);
|
fd->nestedVars.insert(vd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool refout = vd->storage_class & (STCref | STCout);
|
bool refout = vd->storage_class & (STCref | STCout);
|
||||||
bool lazy = vd->storage_class & STClazy;
|
bool lazy = vd->storage_class & STClazy;
|
||||||
|
@ -734,19 +730,27 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// need result variable? (nested)
|
// need result variable? (nested)
|
||||||
#if DMDV2
|
#if DMDV1
|
||||||
if (fd->vresult && fd->vresult->nestedrefs.dim) {
|
|
||||||
#else
|
|
||||||
if (fd->vresult && fd->vresult->nestedref) {
|
if (fd->vresult && fd->vresult->nestedref) {
|
||||||
#endif
|
|
||||||
Logger::println("nested vresult value: %s", fd->vresult->toChars());
|
Logger::println("nested vresult value: %s", fd->vresult->toChars());
|
||||||
fd->nestedVars.insert(fd->vresult);
|
fd->nestedVars.insert(fd->vresult);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DMDV2
|
||||||
|
// fill nestedVars
|
||||||
|
size_t nnest = fd->closureVars.dim;
|
||||||
|
for (size_t i = 0; i < nnest; ++i)
|
||||||
|
{
|
||||||
|
VarDeclaration* vd = (VarDeclaration*)fd->closureVars.data[i];
|
||||||
|
fd->nestedVars.insert(vd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DtoCreateNestedContext(fd);
|
DtoCreateNestedContext(fd);
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
if (fd->vresult && fd->vresult->nestedrefs.dim)
|
if (fd->vresult && fd->vresult->nestedrefs.dim) // FIXME: not sure here :/
|
||||||
#else
|
#else
|
||||||
if (fd->vresult && fd->vresult->nestedref)
|
if (fd->vresult && fd->vresult->nestedref)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -611,6 +611,8 @@ void Module::genmoduleinfo()
|
||||||
//
|
//
|
||||||
// void* xgetMembers;
|
// void* xgetMembers;
|
||||||
// void function() ictor;
|
// void function() ictor;
|
||||||
|
//
|
||||||
|
// void*[4] reserved; // useless to us
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// resolve ModuleInfo
|
// resolve ModuleInfo
|
||||||
|
@ -756,6 +758,15 @@ void Module::genmoduleinfo()
|
||||||
c = getNullValue(fnptrTy);
|
c = getNullValue(fnptrTy);
|
||||||
b.push(c);
|
b.push(c);
|
||||||
|
|
||||||
|
#if DMDV2
|
||||||
|
|
||||||
|
// void*[4] reserved :/
|
||||||
|
const LLType* AT = llvm::ArrayType::get(getVoidPtrType(), 4);
|
||||||
|
c = getNullValue(AT);
|
||||||
|
b.push(c);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*Logger::println("MODULE INFO INITIALIZERS");
|
/*Logger::println("MODULE INFO INITIALIZERS");
|
||||||
for (size_t i=0; i<initVec.size(); ++i)
|
for (size_t i=0; i<initVec.size(); ++i)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue