Files
ldc/gen/dvalue.cpp
Tomas Lindquist Olsen 36f6ebc77f - Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM.
- Eliminated the DLRValue DValue.

- Implemented proactive handling of l-value CastExpS.

- Minor tweak in runtime memory.d .
2009-03-28 05:00:43 +01:00

81 lines
2.0 KiB
C++

#include "gen/llvm.h"
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/logger.h"
#include "gen/dvalue.h"
#include "gen/llvmhelpers.h"
#include "declaration.h"
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
DVarValue::DVarValue(Type* t, VarDeclaration* vd, LLValue* llvmValue)
{
var = vd;
val = llvmValue;
type = t;
}
DVarValue::DVarValue(Type* t, LLValue* llvmValue)
{
var = 0;
val = llvmValue;
type = t;
}
LLValue* DVarValue::getLVal()
{
assert(val);
return val;
}
LLValue* DVarValue::getRVal()
{
assert(val);
Type* bt = type->toBasetype();
if (DtoIsPassedByRef(bt))
return val;
return DtoLoad(val);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
LLValue* DSliceValue::getRVal()
{
assert(len);
assert(ptr);
return DtoAggrPair(len, ptr);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
DFuncValue::DFuncValue(FuncDeclaration* fd, LLValue* v, LLValue* vt)
{
func = fd;
type = func->type;
val = v;
vthis = vt;
}
LLValue* DFuncValue::getRVal()
{
assert(val);
return val;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
LLValue* DConstValue::getRVal()
{
assert(c);
return c;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////