Mercurial > projects > ldc
changeset 459:9db9099583ca
Implement a rough AddrExp::toConstElem()
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 02 Aug 2008 22:54:36 +0200 |
parents | b975f29b7256 |
children | 3a5d6ff8c70f |
files | dmd/expression.h gen/toir.cpp |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/expression.h Sat Aug 02 21:20:31 2008 +0200 +++ b/dmd/expression.h Sat Aug 02 22:54:36 2008 +0200 @@ -865,6 +865,8 @@ MATCH implicitConvTo(Type *t); Expression *castTo(Scope *sc, Type *t); Expression *optimize(int result); + // LLVMDC + virtual llvm::Constant *toConstElem(IRState *irs); }; struct PtrExp : UnaExp
--- a/gen/toir.cpp Sat Aug 02 21:20:31 2008 +0200 +++ b/gen/toir.cpp Sat Aug 02 22:54:36 2008 +0200 @@ -847,6 +847,17 @@ return new DFieldValue(type, v->getLVal(), false); } +LLConstant* AddrExp::toConstElem(IRState* p) +{ + assert(e1->op == TOKvar); + VarExp* vexp = (VarExp*)e1; + VarDeclaration* vd = vexp->var->isVarDeclaration(); + assert(vd); + LLConstant* llc = llvm::dyn_cast<LLConstant>(vd->ir.getIrValue()); + assert(llc); + return llc; +} + ////////////////////////////////////////////////////////////////////////////////////////// DValue* PtrExp::toElem(IRState* p)