mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Implement a rough AddrExp::toConstElem()
This commit is contained in:
@@ -865,6 +865,8 @@ struct AddrExp : UnaExp
|
||||
MATCH implicitConvTo(Type *t);
|
||||
Expression *castTo(Scope *sc, Type *t);
|
||||
Expression *optimize(int result);
|
||||
// LLVMDC
|
||||
virtual llvm::Constant *toConstElem(IRState *irs);
|
||||
};
|
||||
|
||||
struct PtrExp : UnaExp
|
||||
|
||||
11
gen/toir.cpp
11
gen/toir.cpp
@@ -847,6 +847,17 @@ DValue* AddrExp::toElem(IRState* p)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user