mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
Added DtoRawVarDeclaration routine to handle special variables in some statements.
This commit is contained in:
parent
51385239e8
commit
173639bdec
3 changed files with 46 additions and 30 deletions
|
@ -1320,6 +1320,46 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// does pretty much the same as DtoDeclarationExp, except it doesn't initialize, and only handles var declarations
|
||||
LLValue* DtoRawVarDeclaration(VarDeclaration* var)
|
||||
{
|
||||
// we don't handle globals with this one
|
||||
assert(!var->isDataseg());
|
||||
|
||||
// we don't handle aliases either
|
||||
assert(!var->aliassym);
|
||||
|
||||
// referenced by nested function?
|
||||
if (var->nestedref)
|
||||
{
|
||||
assert(var->ir.irLocal);
|
||||
assert(!var->ir.irLocal->value);
|
||||
|
||||
// alloca
|
||||
var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars());
|
||||
|
||||
// store the address into the nested vars array
|
||||
assert(var->ir.irLocal->nestedIndex >= 0);
|
||||
LLValue* gep = DtoGEPi(gIR->func()->decl->ir.irFunc->nestedVar, 0, var->ir.irLocal->nestedIndex);
|
||||
assert(isaPointer(var->ir.irLocal->value));
|
||||
LLValue* val = DtoBitCast(var->ir.irLocal->value, getVoidPtrType());
|
||||
DtoStore(val, gep);
|
||||
}
|
||||
// normal local variable
|
||||
else
|
||||
{
|
||||
assert(!var->ir.isSet());
|
||||
var->ir.irLocal = new IrLocal(var);
|
||||
var->ir.irLocal->value = DtoAlloca(DtoType(var->type), var->toChars());
|
||||
}
|
||||
|
||||
// add debug info
|
||||
if (global.params.symdebug)
|
||||
DtoDwarfLocalVariable(var->ir.irLocal->value, var);
|
||||
|
||||
// return the alloca
|
||||
return var->ir.irLocal->value;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
/*////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue