Give error messages for invalid casts.

This required passing Loc information to certain functions.
Fixes nocompile/b/bug_cgcs_354_A/B.
This commit is contained in:
Christian Kamm 2008-07-26 17:19:16 +02:00
parent a278651178
commit 907a03a3be
11 changed files with 133 additions and 129 deletions

View file

@ -14,7 +14,7 @@
// makes sure the key value lives in memory so it can be passed to the runtime functions without problems // makes sure the key value lives in memory so it can be passed to the runtime functions without problems
// returns the pointer // returns the pointer
static LLValue* to_pkey(DValue* key) static LLValue* to_pkey(Loc& loc, DValue* key)
{ {
Type* keytype = key->getType(); Type* keytype = key->getType();
bool needmem = !DtoIsPassedByRef(keytype); bool needmem = !DtoIsPassedByRef(keytype);
@ -38,7 +38,7 @@ static LLValue* to_pkey(DValue* key)
else { else {
LLValue* tmp = new llvm::AllocaInst(DtoType(keytype), "aatmpkeystorage", gIR->topallocapoint()); LLValue* tmp = new llvm::AllocaInst(DtoType(keytype), "aatmpkeystorage", gIR->topallocapoint());
DVarValue* var = new DVarValue(keytype, tmp, true); DVarValue* var = new DVarValue(keytype, tmp, true);
DtoAssign(var, key); DtoAssign(loc, var, key);
return tmp; return tmp;
} }
@ -62,7 +62,7 @@ static LLValue* to_keyti(DValue* key)
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
DValue* DtoAAIndex(Type* type, DValue* aa, DValue* key) DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key)
{ {
// call: // call:
// extern(C) void* _aaGet(AA* aa, TypeInfo keyti, void* pkey, size_t valuesize) // extern(C) void* _aaGet(AA* aa, TypeInfo keyti, void* pkey, size_t valuesize)
@ -83,7 +83,7 @@ DValue* DtoAAIndex(Type* type, DValue* aa, DValue* key)
LLValue* valsize = DtoConstSize_t(getABITypeSize(DtoType(type))); LLValue* valsize = DtoConstSize_t(getABITypeSize(DtoType(type)));
// pkey param // pkey param
LLValue* pkey = to_pkey(key); LLValue* pkey = to_pkey(loc, key);
pkey = DtoBitCast(pkey, funcTy->getParamType(3)); pkey = DtoBitCast(pkey, funcTy->getParamType(3));
// call runtime // call runtime
@ -99,7 +99,7 @@ DValue* DtoAAIndex(Type* type, DValue* aa, DValue* key)
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
DValue* DtoAAIn(Type* type, DValue* aa, DValue* key) DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key)
{ {
// call: // call:
// extern(C) void* _aaIn(AA aa*, TypeInfo keyti, void* pkey) // extern(C) void* _aaIn(AA aa*, TypeInfo keyti, void* pkey)
@ -121,7 +121,7 @@ DValue* DtoAAIn(Type* type, DValue* aa, DValue* key)
keyti = DtoBitCast(keyti, funcTy->getParamType(1)); keyti = DtoBitCast(keyti, funcTy->getParamType(1));
// pkey param // pkey param
LLValue* pkey = to_pkey(key); LLValue* pkey = to_pkey(loc, key);
pkey = DtoBitCast(pkey, funcTy->getParamType(2)); pkey = DtoBitCast(pkey, funcTy->getParamType(2));
// call runtime // call runtime
@ -137,7 +137,7 @@ DValue* DtoAAIn(Type* type, DValue* aa, DValue* key)
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
void DtoAARemove(DValue* aa, DValue* key) void DtoAARemove(Loc& loc, DValue* aa, DValue* key)
{ {
// call: // call:
// extern(C) void _aaDel(AA aa, TypeInfo keyti, void* pkey) // extern(C) void _aaDel(AA aa, TypeInfo keyti, void* pkey)
@ -159,7 +159,7 @@ void DtoAARemove(DValue* aa, DValue* key)
keyti = DtoBitCast(keyti, funcTy->getParamType(1)); keyti = DtoBitCast(keyti, funcTy->getParamType(1));
// pkey param // pkey param
LLValue* pkey = to_pkey(key); LLValue* pkey = to_pkey(loc, key);
pkey = DtoBitCast(pkey, funcTy->getParamType(2)); pkey = DtoBitCast(pkey, funcTy->getParamType(2));
// build arg vector // build arg vector

View file

@ -1,8 +1,8 @@
#ifndef LLVMDC_GEN_AA_H #ifndef LLVMDC_GEN_AA_H
#define LLVMDC_GEN_AA_H #define LLVMDC_GEN_AA_H
DValue* DtoAAIndex(Type* type, DValue* aa, DValue* key); DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key);
DValue* DtoAAIn(Type* type, DValue* aa, DValue* key); DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key);
void DtoAARemove(DValue* aa, DValue* key); void DtoAARemove(Loc& loc, DValue* aa, DValue* key);
#endif // LLVMDC_GEN_AA_H #endif // LLVMDC_GEN_AA_H

View file

@ -106,7 +106,7 @@ void DtoArrayAssign(LLValue* dst, LLValue* src)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
void DtoArrayInit(DValue* array, DValue* value) void DtoArrayInit(Loc& loc, DValue* array, DValue* value)
{ {
Logger::println("DtoArrayInit"); Logger::println("DtoArrayInit");
LOG_SCOPE; LOG_SCOPE;
@ -120,7 +120,7 @@ void DtoArrayInit(DValue* array, DValue* value)
{ {
val = new llvm::AllocaInst(DtoType(value->getType()), ".tmpparam", gIR->topallocapoint()); val = new llvm::AllocaInst(DtoType(value->getType()), ".tmpparam", gIR->topallocapoint());
DVarValue lval(value->getType(), val, true); DVarValue lval(value->getType(), val, true);
DtoAssign(&lval, value); DtoAssign(loc, &lval, value);
} }
else else
{ {
@ -531,7 +531,7 @@ DSliceValue* DtoCatAssignElement(DValue* array, Expression* exp)
DValue* e = exp->toElem(gIR); DValue* e = exp->toElem(gIR);
if (!e->inPlace()) if (!e->inPlace())
DtoAssign(dptr, e); DtoAssign(exp->loc, dptr, e);
return slice; return slice;
} }
@ -633,7 +633,7 @@ DSliceValue* DtoCatArrayElement(Type* type, Expression* exp1, Expression* exp2)
LLValue* mem = slice->ptr; LLValue* mem = slice->ptr;
DVarValue* memval = new DVarValue(e1->getType(), mem, true); DVarValue* memval = new DVarValue(e1->getType(), mem, true);
DtoAssign(memval, e1); DtoAssign(exp1->loc, memval, e1);
src1 = DtoArrayPtr(e2); src1 = DtoArrayPtr(e2);
@ -664,7 +664,7 @@ DSliceValue* DtoCatArrayElement(Type* type, Expression* exp1, Expression* exp2)
mem = gIR->ir->CreateGEP(mem,len1,"tmp"); mem = gIR->ir->CreateGEP(mem,len1,"tmp");
DVarValue* memval = new DVarValue(e2->getType(), mem, true); DVarValue* memval = new DVarValue(e2->getType(), mem, true);
DtoAssign(memval, e2); DtoAssign(exp1->loc, memval, e2);
return slice; return slice;
} }

View file

@ -14,7 +14,7 @@ LLConstant* DtoConstStaticArray(const LLType* t, LLConstant* c);
void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src); void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src);
void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src); void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src);
void DtoArrayInit(DValue* array, DValue* value); void DtoArrayInit(Loc& loc, DValue* array, DValue* value);
void DtoArrayAssign(LLValue* l, LLValue* r); void DtoArrayAssign(LLValue* l, LLValue* r);
void DtoSetArray(LLValue* arr, LLValue* dim, LLValue* ptr); void DtoSetArray(LLValue* arr, LLValue* dim, LLValue* ptr);
void DtoSetArrayToNull(LLValue* v); void DtoSetArrayToNull(LLValue* v);

View file

@ -101,12 +101,12 @@ LLValue* DtoImagPart(DValue* val)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
DValue* DtoComplex(Type* to, DValue* val) DValue* DtoComplex(Loc& loc, Type* to, DValue* val)
{ {
Type* t = DtoDType(val->getType()); Type* t = DtoDType(val->getType());
if (val->isComplex() || t->iscomplex()) { if (val->isComplex() || t->iscomplex()) {
return DtoCastComplex(val, to); return DtoCastComplex(loc, val, to);
} }
const LLType* base = DtoComplexBaseType(to); const LLType* base = DtoComplexBaseType(to);
@ -126,13 +126,13 @@ DValue* DtoComplex(Type* to, DValue* val)
} }
if (t->isimaginary()) { if (t->isimaginary()) {
return new DComplexValue(to, LLConstant::getNullValue(DtoType(baserety)), DtoCastFloat(val, baseimty)->getRVal()); return new DComplexValue(to, LLConstant::getNullValue(DtoType(baserety)), DtoCastFloat(loc, val, baseimty)->getRVal());
} }
else if (t->isfloating()) { else if (t->isfloating()) {
return new DComplexValue(to, DtoCastFloat(val, baserety)->getRVal(), LLConstant::getNullValue(DtoType(baseimty))); return new DComplexValue(to, DtoCastFloat(loc, val, baserety)->getRVal(), LLConstant::getNullValue(DtoType(baseimty)));
} }
else if (t->isintegral()) { else if (t->isintegral()) {
return new DComplexValue(to, DtoCastInt(val, baserety)->getRVal(), LLConstant::getNullValue(DtoType(baseimty))); return new DComplexValue(to, DtoCastInt(loc, val, baserety)->getRVal(), LLConstant::getNullValue(DtoType(baseimty)));
} }
assert(0); assert(0);
} }
@ -179,10 +179,10 @@ DValue* resolveLR(DValue* val, bool getlval)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
DValue* DtoComplexAdd(Type* type, DValue* lhs, DValue* rhs) DValue* DtoComplexAdd(Loc& loc, Type* type, DValue* lhs, DValue* rhs)
{ {
lhs = DtoComplex(type, resolveLR(lhs, true)); lhs = DtoComplex(loc, type, resolveLR(lhs, true));
rhs = DtoComplex(type, resolveLR(rhs, false)); rhs = DtoComplex(loc, type, resolveLR(rhs, false));
llvm::Value *a, *b, *c, *d, *re, *im; llvm::Value *a, *b, *c, *d, *re, *im;
@ -200,10 +200,10 @@ DValue* DtoComplexAdd(Type* type, DValue* lhs, DValue* rhs)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
DValue* DtoComplexSub(Type* type, DValue* lhs, DValue* rhs) DValue* DtoComplexSub(Loc& loc, Type* type, DValue* lhs, DValue* rhs)
{ {
lhs = DtoComplex(type, resolveLR(lhs, true)); lhs = DtoComplex(loc, type, resolveLR(lhs, true));
rhs = DtoComplex(type, resolveLR(rhs, false)); rhs = DtoComplex(loc, type, resolveLR(rhs, false));
llvm::Value *a, *b, *c, *d, *re, *im; llvm::Value *a, *b, *c, *d, *re, *im;
@ -221,10 +221,10 @@ DValue* DtoComplexSub(Type* type, DValue* lhs, DValue* rhs)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
DValue* DtoComplexMul(Type* type, DValue* lhs, DValue* rhs) DValue* DtoComplexMul(Loc& loc, Type* type, DValue* lhs, DValue* rhs)
{ {
lhs = DtoComplex(type, resolveLR(lhs, true)); lhs = DtoComplex(loc, type, resolveLR(lhs, true));
rhs = DtoComplex(type, resolveLR(rhs, false)); rhs = DtoComplex(loc, type, resolveLR(rhs, false));
llvm::Value *a, *b, *c, *d; llvm::Value *a, *b, *c, *d;
@ -248,10 +248,10 @@ DValue* DtoComplexMul(Type* type, DValue* lhs, DValue* rhs)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
DValue* DtoComplexDiv(Type* type, DValue* lhs, DValue* rhs) DValue* DtoComplexDiv(Loc& loc, Type* type, DValue* lhs, DValue* rhs)
{ {
lhs = DtoComplex(type, resolveLR(lhs, true)); lhs = DtoComplex(loc, type, resolveLR(lhs, true));
rhs = DtoComplex(type, resolveLR(rhs, false)); rhs = DtoComplex(loc, type, resolveLR(rhs, false));
llvm::Value *a, *b, *c, *d; llvm::Value *a, *b, *c, *d;
@ -281,9 +281,9 @@ DValue* DtoComplexDiv(Type* type, DValue* lhs, DValue* rhs)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
DValue* DtoComplexNeg(Type* type, DValue* val) DValue* DtoComplexNeg(Loc& loc, Type* type, DValue* val)
{ {
val = DtoComplex(type, resolveLR(val, false)); val = DtoComplex(loc, type, resolveLR(val, false));
llvm::Value *a, *b, *re, *im; llvm::Value *a, *b, *re, *im;
@ -299,12 +299,12 @@ DValue* DtoComplexNeg(Type* type, DValue* val)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
LLValue* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs) LLValue* DtoComplexEquals(Loc& loc, TOK op, DValue* lhs, DValue* rhs)
{ {
Type* type = lhs->getType(); Type* type = lhs->getType();
lhs = DtoComplex(type, resolveLR(lhs, false)); lhs = DtoComplex(loc, type, resolveLR(lhs, false));
rhs = DtoComplex(type, resolveLR(rhs, false)); rhs = DtoComplex(loc, type, resolveLR(rhs, false));
llvm::Value *a, *b, *c, *d; llvm::Value *a, *b, *c, *d;
@ -332,7 +332,7 @@ LLValue* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
DValue* DtoCastComplex(DValue* val, Type* _to) DValue* DtoCastComplex(Loc& loc, DValue* val, Type* _to)
{ {
Type* to = DtoDType(_to); Type* to = DtoDType(_to);
Type* vty = val->getType(); Type* vty = val->getType();
@ -370,14 +370,14 @@ DValue* DtoCastComplex(DValue* val, Type* _to)
return new DImValue(to, val->isComplex()->im); return new DImValue(to, val->isComplex()->im);
LLValue* v = val->getRVal(); LLValue* v = val->getRVal();
DImValue* im = new DImValue(to, DtoLoad(DtoGEPi(v,0,1,"tmp"))); DImValue* im = new DImValue(to, DtoLoad(DtoGEPi(v,0,1,"tmp")));
return DtoCastFloat(im, to); return DtoCastFloat(loc, im, to);
} }
else if (to->isfloating()) { else if (to->isfloating()) {
if (val->isComplex()) if (val->isComplex())
return new DImValue(to, val->isComplex()->re); return new DImValue(to, val->isComplex()->re);
LLValue* v = val->getRVal(); LLValue* v = val->getRVal();
DImValue* re = new DImValue(to, DtoLoad(DtoGEPi(v,0,0,"tmp"))); DImValue* re = new DImValue(to, DtoLoad(DtoGEPi(v,0,0,"tmp")));
return DtoCastFloat(re, to); return DtoCastFloat(loc, re, to);
} }
else else
assert(0); assert(0);

View file

@ -11,21 +11,21 @@ LLConstant* DtoComplexShuffleMask(unsigned a, unsigned b);
LLValue* DtoRealPart(DValue* val); LLValue* DtoRealPart(DValue* val);
LLValue* DtoImagPart(DValue* val); LLValue* DtoImagPart(DValue* val);
DValue* DtoComplex(Type* to, DValue* val); DValue* DtoComplex(Loc& loc, Type* to, DValue* val);
void DtoComplexAssign(LLValue* l, LLValue* r); void DtoComplexAssign(LLValue* l, LLValue* r);
void DtoComplexSet(LLValue* c, LLValue* re, LLValue* im); void DtoComplexSet(LLValue* c, LLValue* re, LLValue* im);
void DtoGetComplexParts(DValue* c, LLValue*& re, LLValue*& im); void DtoGetComplexParts(DValue* c, LLValue*& re, LLValue*& im);
DValue* DtoComplexAdd(Type* type, DValue* lhs, DValue* rhs); DValue* DtoComplexAdd(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
DValue* DtoComplexSub(Type* type, DValue* lhs, DValue* rhs); DValue* DtoComplexSub(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
DValue* DtoComplexMul(Type* type, DValue* lhs, DValue* rhs); DValue* DtoComplexMul(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
DValue* DtoComplexDiv(Type* type, DValue* lhs, DValue* rhs); DValue* DtoComplexDiv(Loc& loc, Type* type, DValue* lhs, DValue* rhs);
DValue* DtoComplexNeg(Type* type, DValue* val); DValue* DtoComplexNeg(Loc& loc, Type* type, DValue* val);
LLValue* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs); LLValue* DtoComplexEquals(Loc& loc, TOK op, DValue* lhs, DValue* rhs);
DValue* DtoCastComplex(DValue* val, Type* to); DValue* DtoCastComplex(Loc& loc, DValue* val, Type* to);
#endif // LLVMDC_GEN_COMPLEX_H #endif // LLVMDC_GEN_COMPLEX_H

View file

@ -793,7 +793,7 @@ DValue* DtoArgument(Argument* fnarg, Expression* argexp)
{ {
LLValue* alloc = new llvm::AllocaInst(DtoType(argexp->type), "tmpparam", gIR->topallocapoint()); LLValue* alloc = new llvm::AllocaInst(DtoType(argexp->type), "tmpparam", gIR->topallocapoint());
DVarValue* vv = new DVarValue(argexp->type, alloc, true); DVarValue* vv = new DVarValue(argexp->type, alloc, true);
DtoAssign(vv, arg); DtoAssign(argexp->loc, vv, arg);
arg = vv; arg = vv;
} }
@ -807,7 +807,7 @@ void DtoVariadicArgument(Expression* argexp, LLValue* dst)
Logger::println("DtoVariadicArgument"); Logger::println("DtoVariadicArgument");
LOG_SCOPE; LOG_SCOPE;
DVarValue vv(argexp->type, dst, true); DVarValue vv(argexp->type, dst, true);
DtoAssign(&vv, argexp->toElem(gIR)); DtoAssign(argexp->loc, &vv, argexp->toElem(gIR));
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////

View file

@ -512,7 +512,7 @@ LLValue* DtoNestedVariable(VarDeclaration* vd)
// ASSIGNMENT HELPER (store this in that) // ASSIGNMENT HELPER (store this in that)
////////////////////////////////////////////////////////////////////////////////////////*/ ////////////////////////////////////////////////////////////////////////////////////////*/
void DtoAssign(DValue* lhs, DValue* rhs) void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
{ {
Logger::cout() << "DtoAssign(...);\n"; Logger::cout() << "DtoAssign(...);\n";
LOG_SCOPE; LOG_SCOPE;
@ -536,7 +536,7 @@ void DtoAssign(DValue* lhs, DValue* rhs)
DtoArrayCopySlices(s, s2); DtoArrayCopySlices(s, s2);
} }
else if (t->next->toBasetype()->equals(t2)) { else if (t->next->toBasetype()->equals(t2)) {
DtoArrayInit(s, rhs); DtoArrayInit(loc, s, rhs);
} }
else { else {
DtoArrayCopyToSlice(s, rhs); DtoArrayCopyToSlice(s, rhs);
@ -561,7 +561,7 @@ void DtoAssign(DValue* lhs, DValue* rhs)
DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal()); DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal());
} }
else { else {
DtoArrayInit(lhs, rhs); DtoArrayInit(loc, lhs, rhs);
} }
} }
else if (t->ty == Tdelegate) { else if (t->ty == Tdelegate) {
@ -596,7 +596,7 @@ void DtoAssign(DValue* lhs, DValue* rhs)
LLValue* dst; LLValue* dst;
if (DLRValue* lr = lhs->isLRValue()) { if (DLRValue* lr = lhs->isLRValue()) {
dst = lr->getLVal(); dst = lr->getLVal();
rhs = DtoCastComplex(rhs, lr->getLType()); rhs = DtoCastComplex(loc, rhs, lr->getLType());
} }
else { else {
dst = lhs->getRVal(); dst = lhs->getRVal();
@ -616,10 +616,10 @@ void DtoAssign(DValue* lhs, DValue* rhs)
// handle lvalue cast assignments // handle lvalue cast assignments
if (DLRValue* lr = lhs->isLRValue()) { if (DLRValue* lr = lhs->isLRValue()) {
Logger::println("lvalue cast!"); Logger::println("lvalue cast!");
r = DtoCast(rhs, lr->getLType())->getRVal(); r = DtoCast(loc, rhs, lr->getLType())->getRVal();
} }
else { else {
r = DtoCast(rhs, lhs->getType())->getRVal(); r = DtoCast(loc, rhs, lhs->getType())->getRVal();
} }
Logger::cout() << "really assign\nlhs: " << *l << "rhs: " << *r << '\n'; Logger::cout() << "really assign\nlhs: " << *l << "rhs: " << *r << '\n';
assert(r->getType() == l->getType()->getContainedType(0)); assert(r->getType() == l->getType()->getContainedType(0));
@ -676,7 +676,7 @@ DValue* DtoNullValue(Type* type)
// CASTING HELPERS // CASTING HELPERS
////////////////////////////////////////////////////////////////////////////////////////*/ ////////////////////////////////////////////////////////////////////////////////////////*/
DValue* DtoCastInt(DValue* val, Type* _to) DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
{ {
const LLType* tolltype = DtoType(_to); const LLType* tolltype = DtoType(_to);
@ -709,7 +709,7 @@ DValue* DtoCastInt(DValue* val, Type* _to)
} }
} }
else if (to->iscomplex()) { else if (to->iscomplex()) {
return DtoComplex(to, val); return DtoComplex(loc, to, val);
} }
else if (to->isfloating()) { else if (to->isfloating()) {
if (from->isunsigned()) { if (from->isunsigned()) {
@ -724,13 +724,14 @@ DValue* DtoCastInt(DValue* val, Type* _to)
rval = gIR->ir->CreateIntToPtr(rval, tolltype, "tmp"); rval = gIR->ir->CreateIntToPtr(rval, tolltype, "tmp");
} }
else { else {
assert(0 && "bad int cast"); error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), _to->toChars());
fatal();
} }
return new DImValue(_to, rval); return new DImValue(_to, rval);
} }
DValue* DtoCastPtr(DValue* val, Type* to) DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to)
{ {
const LLType* tolltype = DtoType(to); const LLType* tolltype = DtoType(to);
@ -749,14 +750,14 @@ DValue* DtoCastPtr(DValue* val, Type* to)
rval = new llvm::PtrToIntInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); rval = new llvm::PtrToIntInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
} }
else { else {
Logger::println("invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars()); error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
assert(0); fatal();
} }
return new DImValue(to, rval); return new DImValue(to, rval);
} }
DValue* DtoCastFloat(DValue* val, Type* to) DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to)
{ {
if (val->getType() == to) if (val->getType() == to)
return val; return val;
@ -773,7 +774,7 @@ DValue* DtoCastFloat(DValue* val, Type* to)
LLValue* rval; LLValue* rval;
if (totype->iscomplex()) { if (totype->iscomplex()) {
return DtoComplex(to, val); return DtoComplex(loc, to, val);
} }
else if (totype->isfloating()) { else if (totype->isfloating()) {
if ((fromtype->ty == Tfloat80 || fromtype->ty == Tfloat64) && (totype->ty == Tfloat80 || totype->ty == Tfloat64)) { if ((fromtype->ty == Tfloat80 || fromtype->ty == Tfloat64) && (totype->ty == Tfloat80 || totype->ty == Tfloat64)) {
@ -789,7 +790,8 @@ DValue* DtoCastFloat(DValue* val, Type* to)
rval = new llvm::FPTruncInst(val->getRVal(), tolltype, "tmp", gIR->scopebb()); rval = new llvm::FPTruncInst(val->getRVal(), tolltype, "tmp", gIR->scopebb());
} }
else { else {
assert(0 && "bad float cast"); error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
fatal();
} }
} }
else if (totype->isintegral()) { else if (totype->isintegral()) {
@ -801,24 +803,25 @@ DValue* DtoCastFloat(DValue* val, Type* to)
} }
} }
else { else {
assert(0 && "bad float cast"); error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
fatal();
} }
return new DImValue(to, rval); return new DImValue(to, rval);
} }
DValue* DtoCast(DValue* val, Type* to) DValue* DtoCast(Loc& loc, DValue* val, Type* to)
{ {
Type* fromtype = DtoDType(val->getType()); Type* fromtype = DtoDType(val->getType());
Logger::println("Casting from '%s' to '%s'", fromtype->toChars(), to->toChars()); Logger::println("Casting from '%s' to '%s'", fromtype->toChars(), to->toChars());
if (fromtype->isintegral()) { if (fromtype->isintegral()) {
return DtoCastInt(val, to); return DtoCastInt(loc, val, to);
} }
else if (fromtype->iscomplex()) { else if (fromtype->iscomplex()) {
return DtoCastComplex(val, to); return DtoCastComplex(loc, val, to);
} }
else if (fromtype->isfloating()) { else if (fromtype->isfloating()) {
return DtoCastFloat(val, to); return DtoCastFloat(loc, val, to);
} }
else if (fromtype->ty == Tclass) { else if (fromtype->ty == Tclass) {
return DtoCastClass(val, to); return DtoCastClass(val, to);
@ -827,10 +830,11 @@ DValue* DtoCast(DValue* val, Type* to)
return DtoCastArray(val, to); return DtoCastArray(val, to);
} }
else if (fromtype->ty == Tpointer || fromtype->ty == Tfunction) { else if (fromtype->ty == Tpointer || fromtype->ty == Tfunction) {
return DtoCastPtr(val, to); return DtoCastPtr(loc, val, to);
} }
else { else {
assert(0); error(loc, "invalid cast from '%s' to '%s'", val->getType()->toChars(), to->toChars());
fatal();
} }
} }
@ -872,7 +876,7 @@ void DtoLazyStaticInit(bool istempl, LLValue* gvar, Initializer* init, Type* t)
DValue* ie = DtoInitializer(init); DValue* ie = DtoInitializer(init);
if (!ie->inPlace()) { if (!ie->inPlace()) {
DValue* dst = new DVarValue(t, gvar, true); DValue* dst = new DVarValue(t, gvar, true);
DtoAssign(dst, ie); DtoAssign(init->loc, dst, ie);
} }
gIR->ir->CreateStore(DtoConstBool(true), gflag); gIR->ir->CreateStore(DtoConstBool(true), gflag);
gIR->ir->CreateBr(endinitbb); gIR->ir->CreateBr(endinitbb);
@ -1359,7 +1363,7 @@ void findDefaultTarget()
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
LLValue* DtoBoolean(DValue* dval) LLValue* DtoBoolean(Loc& loc, DValue* dval)
{ {
Type* dtype = dval->getType()->toBasetype(); Type* dtype = dval->getType()->toBasetype();
TY ty = dtype->ty; TY ty = dtype->ty;
@ -1378,7 +1382,7 @@ LLValue* DtoBoolean(DValue* dval)
// complex // complex
else if (dtype->iscomplex()) else if (dtype->iscomplex())
{ {
return DtoComplexEquals(TOKnotequal, dval, DtoNullValue(dtype)); return DtoComplexEquals(loc, TOKnotequal, dval, DtoNullValue(dtype));
} }
// floating point // floating point
else if (dtype->isfloating()) else if (dtype->isfloating())

View file

@ -39,16 +39,16 @@ LLValue* DtoNestedContext(FuncDeclaration* func);
LLValue* DtoNestedVariable(VarDeclaration* vd); LLValue* DtoNestedVariable(VarDeclaration* vd);
// basic operations // basic operations
void DtoAssign(DValue* lhs, DValue* rhs); void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs);
// create a null dvalue // create a null dvalue
DValue* DtoNullValue(Type* t); DValue* DtoNullValue(Type* t);
// casts // casts
DValue* DtoCastInt(DValue* val, Type* to); DValue* DtoCastInt(Loc& loc, DValue* val, Type* to);
DValue* DtoCastPtr(DValue* val, Type* to); DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to);
DValue* DtoCastFloat(DValue* val, Type* to); DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to);
DValue* DtoCast(DValue* val, Type* to); DValue* DtoCast(Loc& loc, DValue* val, Type* to);
// is template instance check // is template instance check
bool DtoIsTemplateInstance(Dsymbol* s); bool DtoIsTemplateInstance(Dsymbol* s);
@ -102,6 +102,6 @@ void findDefaultTarget();
DValue* DtoCallDFunc(FuncDeclaration* fdecl, Array* arguments, TypeClass* type=0, LLValue* thismem=0); DValue* DtoCallDFunc(FuncDeclaration* fdecl, Array* arguments, TypeClass* type=0, LLValue* thismem=0);
/// Converts any value to a boolean (llvm i1) /// Converts any value to a boolean (llvm i1)
LLValue* DtoBoolean(DValue* dval); LLValue* DtoBoolean(Loc& loc, DValue* dval);
#endif #endif

View file

@ -67,7 +67,7 @@ void ReturnStatement::toIR(IRState* p)
DValue* e = exp->toElem(p); DValue* e = exp->toElem(p);
if (!e->inPlace()) if (!e->inPlace())
DtoAssign(rvar, e); DtoAssign(loc, rvar, e);
DtoEnclosingHandlers(enclosinghandler, NULL); DtoEnclosingHandlers(enclosinghandler, NULL);
@ -160,7 +160,7 @@ void IfStatement::toIR(IRState* p)
if (cond_val->getType() != LLType::Int1Ty) { if (cond_val->getType() != LLType::Int1Ty) {
Logger::cout() << "if conditional: " << *cond_val << '\n'; Logger::cout() << "if conditional: " << *cond_val << '\n';
cond_val = DtoBoolean(cond_e); cond_val = DtoBoolean(loc, cond_e);
} }
LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb()); LLValue* ifgoback = llvm::BranchInst::Create(ifbb, elsebb, cond_val, gIR->scopebb());
@ -248,7 +248,7 @@ void WhileStatement::toIR(IRState* p)
// create the condition // create the condition
DValue* cond_e = condition->toElem(p); DValue* cond_e = condition->toElem(p);
LLValue* cond_val = DtoBoolean(cond_e); LLValue* cond_val = DtoBoolean(loc, cond_e);
delete cond_e; delete cond_e;
// conditional branch // conditional branch
@ -299,7 +299,7 @@ void DoStatement::toIR(IRState* p)
// create the condition // create the condition
DValue* cond_e = condition->toElem(p); DValue* cond_e = condition->toElem(p);
LLValue* cond_val = DtoBoolean(cond_e); LLValue* cond_val = DtoBoolean(loc, cond_e);
delete cond_e; delete cond_e;
// conditional branch // conditional branch
@ -341,7 +341,7 @@ void ForStatement::toIR(IRState* p)
// create the condition // create the condition
DValue* cond_e = condition->toElem(p); DValue* cond_e = condition->toElem(p);
LLValue* cond_val = DtoBoolean(cond_e); LLValue* cond_val = DtoBoolean(loc, cond_e);
delete cond_e; delete cond_e;
// conditional branch // conditional branch
@ -677,7 +677,7 @@ static LLValue* call_string_switch_runtime(llvm::GlobalVariable* table, Expressi
// give storage // give storage
llval = new llvm::AllocaInst(DtoType(e->type), "tmp", gIR->topallocapoint()); llval = new llvm::AllocaInst(DtoType(e->type), "tmp", gIR->topallocapoint());
DVarValue* vv = new DVarValue(e->type, llval, true); DVarValue* vv = new DVarValue(e->type, llval, true);
DtoAssign(vv, val); DtoAssign(e->loc, vv, val);
} }
else else
{ {
@ -994,7 +994,7 @@ void ForeachStatement::toIR(IRState* p)
if (!value->isRef() && !value->isOut()) { if (!value->isRef() && !value->isOut()) {
DValue* dst = new DVarValue(value->type, valvar, true); DValue* dst = new DVarValue(value->type, valvar, true);
DValue* src = new DVarValue(value->type, value->ir.irLocal->value, true); DValue* src = new DVarValue(value->type, value->ir.irLocal->value, true);
DtoAssign(dst, src); DtoAssign(loc, dst, src);
value->ir.irLocal->value = valvar; value->ir.irLocal->value = valvar;
} }

View file

@ -568,7 +568,7 @@ DValue* AssignExp::toElem(IRState* p)
DVarValue arrval(ale->e1->type, arr->getLVal(), true); DVarValue arrval(ale->e1->type, arr->getLVal(), true);
DValue* newlen = e2->toElem(p); DValue* newlen = e2->toElem(p);
DSliceValue* slice = DtoResizeDynArray(arrval.getType(), &arrval, newlen); DSliceValue* slice = DtoResizeDynArray(arrval.getType(), &arrval, newlen);
DtoAssign(&arrval, slice); DtoAssign(loc, &arrval, slice);
return newlen; return newlen;
} }
@ -576,7 +576,7 @@ DValue* AssignExp::toElem(IRState* p)
DValue* l = e1->toElem(p); DValue* l = e1->toElem(p);
DValue* r = e2->toElem(p); DValue* r = e2->toElem(p);
DtoAssign(l, r); DtoAssign(loc, l, r);
if (l->isSlice() || l->isComplex()) if (l->isSlice() || l->isComplex())
return l; return l;
@ -630,12 +630,12 @@ DValue* AddExp::toElem(IRState* p)
return new DImValue(type, v); return new DImValue(type, v);
} }
else if (t->iscomplex()) { else if (t->iscomplex()) {
return DtoComplexAdd(type, l, r); return DtoComplexAdd(loc, type, l, r);
} }
assert(0); assert(0);
} }
else if (t->iscomplex()) { else if (t->iscomplex()) {
return DtoComplexAdd(type, l, r); return DtoComplexAdd(loc, type, l, r);
} }
else { else {
return DtoBinAdd(l,r); return DtoBinAdd(l,r);
@ -660,12 +660,12 @@ DValue* AddAssignExp::toElem(IRState* p)
res = new DImValue(type, gep); res = new DImValue(type, gep);
} }
else if (t->iscomplex()) { else if (t->iscomplex()) {
res = DtoComplexAdd(e1->type, l, r); res = DtoComplexAdd(loc, e1->type, l, r);
} }
else { else {
res = DtoBinAdd(l,r); res = DtoBinAdd(l,r);
} }
DtoAssign(l, res); DtoAssign(loc, l, res);
return res; return res;
} }
@ -701,7 +701,7 @@ DValue* MinExp::toElem(IRState* p)
return new DImValue(type, v); return new DImValue(type, v);
} }
else if (t->iscomplex()) { else if (t->iscomplex()) {
return DtoComplexSub(type, l, r); return DtoComplexSub(loc, type, l, r);
} }
else { else {
return DtoBinSub(l,r); return DtoBinSub(l,r);
@ -731,13 +731,13 @@ DValue* MinAssignExp::toElem(IRState* p)
} }
else if (t->iscomplex()) { else if (t->iscomplex()) {
Logger::println("complex"); Logger::println("complex");
res = DtoComplexSub(type, l, r); res = DtoComplexSub(loc, type, l, r);
} }
else { else {
Logger::println("basic"); Logger::println("basic");
res = DtoBinSub(l,r); res = DtoBinSub(l,r);
} }
DtoAssign(l, res); DtoAssign(loc, l, res);
return res; return res;
} }
@ -753,7 +753,7 @@ DValue* MulExp::toElem(IRState* p)
DValue* r = e2->toElem(p); DValue* r = e2->toElem(p);
if (type->iscomplex()) { if (type->iscomplex()) {
return DtoComplexMul(type, l, r); return DtoComplexMul(loc, type, l, r);
} }
return DtoBinMul(l,r); return DtoBinMul(l,r);
@ -771,12 +771,12 @@ DValue* MulAssignExp::toElem(IRState* p)
DValue* res; DValue* res;
if (type->iscomplex()) { if (type->iscomplex()) {
res = DtoComplexMul(type, l, r); res = DtoComplexMul(loc, type, l, r);
} }
else { else {
res = DtoBinMul(l,r); res = DtoBinMul(l,r);
} }
DtoAssign(l, res); DtoAssign(loc, l, res);
return res; return res;
} }
@ -792,7 +792,7 @@ DValue* DivExp::toElem(IRState* p)
DValue* r = e2->toElem(p); DValue* r = e2->toElem(p);
if (type->iscomplex()) { if (type->iscomplex()) {
return DtoComplexDiv(type, l, r); return DtoComplexDiv(loc, type, l, r);
} }
return DtoBinDiv(l, r); return DtoBinDiv(l, r);
@ -810,12 +810,12 @@ DValue* DivAssignExp::toElem(IRState* p)
DValue* res; DValue* res;
if (type->iscomplex()) { if (type->iscomplex()) {
res = DtoComplexDiv(type, l, r); res = DtoComplexDiv(loc, type, l, r);
} }
else { else {
res = DtoBinDiv(l,r); res = DtoBinDiv(l,r);
} }
DtoAssign(l, res); DtoAssign(loc, l, res);
return res; return res;
} }
@ -844,7 +844,7 @@ DValue* ModAssignExp::toElem(IRState* p)
DValue* r = e2->toElem(p); DValue* r = e2->toElem(p);
DValue* res = DtoBinRem(l, r); DValue* res = DtoBinRem(l, r);
DtoAssign(l, res); DtoAssign(loc, l, res);
return res; return res;
} }
@ -933,7 +933,7 @@ DValue* CallExp::toElem(IRState* p)
Expression* exp = (Expression*)arguments->data[0]; Expression* exp = (Expression*)arguments->data[0];
DValue* expv = exp->toElem(p); DValue* expv = exp->toElem(p);
if (expv->getType()->toBasetype()->ty != Tint32) if (expv->getType()->toBasetype()->ty != Tint32)
expv = DtoCast(expv, Type::tint32); expv = DtoCast(loc, expv, Type::tint32);
LLValue* alloc = new llvm::AllocaInst(LLType::Int8Ty, expv->getRVal(), "alloca", p->scopebb()); LLValue* alloc = new llvm::AllocaInst(LLType::Int8Ty, expv->getRVal(), "alloca", p->scopebb());
// done // done
return new DImValue(type, alloc); return new DImValue(type, alloc);
@ -1208,7 +1208,7 @@ DValue* CastExp::toElem(IRState* p)
LOG_SCOPE; LOG_SCOPE;
DValue* u = e1->toElem(p); DValue* u = e1->toElem(p);
DValue* v = DtoCast(u, to); DValue* v = DtoCast(loc, u, to);
// force d type to this->type // force d type to this->type
v->getType() = type; v->getType() = type;
@ -1437,7 +1437,7 @@ DValue* IndexExp::toElem(IRState* p)
arrptr = DtoGEP1(arrptr,r->getRVal()); arrptr = DtoGEP1(arrptr,r->getRVal());
} }
else if (e1type->ty == Taarray) { else if (e1type->ty == Taarray) {
return DtoAAIndex(type, l, r); return DtoAAIndex(loc, type, l, r);
} }
else { else {
Logger::println("invalid index exp! e1type: %s", e1type->toChars()); Logger::println("invalid index exp! e1type: %s", e1type->toChars());
@ -1671,7 +1671,7 @@ DValue* EqualExp::toElem(IRState* p)
else if (t->iscomplex()) else if (t->iscomplex())
{ {
Logger::println("complex"); Logger::println("complex");
eval = DtoComplexEquals(op, l, r); eval = DtoComplexEquals(loc, op, l, r);
} }
else if (t->isfloating()) else if (t->isfloating())
{ {
@ -1837,7 +1837,7 @@ DValue* NewExp::toElem(IRState* p)
// default initialize // default initialize
Expression* exp = newtype->defaultInit(loc); Expression* exp = newtype->defaultInit(loc);
DValue* iv = exp->toElem(gIR); DValue* iv = exp->toElem(gIR);
DtoAssign(&tmpvar, iv); DtoAssign(loc, &tmpvar, iv);
// return as pointer-to // return as pointer-to
return new DImValue(type, mem, false); return new DImValue(type, mem, false);
@ -1934,7 +1934,7 @@ DValue* AssertExp::toElem(IRState* p)
llvm::BasicBlock* endbb = llvm::BasicBlock::Create("noassert", p->topfunc(), oldend); llvm::BasicBlock* endbb = llvm::BasicBlock::Create("noassert", p->topfunc(), oldend);
// test condition // test condition
LLValue* condval = DtoBoolean(cond); LLValue* condval = DtoBoolean(loc, cond);
// branch // branch
llvm::BranchInst::Create(endbb, assertbb, condval, p->scopebb()); llvm::BranchInst::Create(endbb, assertbb, condval, p->scopebb());
@ -1963,7 +1963,7 @@ DValue* NotExp::toElem(IRState* p)
DValue* u = e1->toElem(p); DValue* u = e1->toElem(p);
LLValue* b = DtoBoolean(u); LLValue* b = DtoBoolean(loc, u);
LLConstant* zero = DtoConstBool(false); LLConstant* zero = DtoConstBool(false);
b = p->ir->CreateICmpEQ(b,zero); b = p->ir->CreateICmpEQ(b,zero);
@ -1989,14 +1989,14 @@ DValue* AndAndExp::toElem(IRState* p)
llvm::BasicBlock* andand = llvm::BasicBlock::Create("andand", gIR->topfunc(), oldend); llvm::BasicBlock* andand = llvm::BasicBlock::Create("andand", gIR->topfunc(), oldend);
llvm::BasicBlock* andandend = llvm::BasicBlock::Create("andandend", gIR->topfunc(), oldend); llvm::BasicBlock* andandend = llvm::BasicBlock::Create("andandend", gIR->topfunc(), oldend);
LLValue* ubool = DtoBoolean(u); LLValue* ubool = DtoBoolean(loc, u);
DtoStore(ubool,resval); DtoStore(ubool,resval);
llvm::BranchInst::Create(andand,andandend,ubool,p->scopebb()); llvm::BranchInst::Create(andand,andandend,ubool,p->scopebb());
p->scope() = IRScope(andand, andandend); p->scope() = IRScope(andand, andandend);
DValue* v = e2->toElem(p); DValue* v = e2->toElem(p);
LLValue* vbool = DtoBoolean(v); LLValue* vbool = DtoBoolean(loc, v);
LLValue* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb()); LLValue* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb());
DtoStore(uandvbool,resval); DtoStore(uandvbool,resval);
llvm::BranchInst::Create(andandend,p->scopebb()); llvm::BranchInst::Create(andandend,p->scopebb());
@ -2025,14 +2025,14 @@ DValue* OrOrExp::toElem(IRState* p)
llvm::BasicBlock* oror = llvm::BasicBlock::Create("oror", gIR->topfunc(), oldend); llvm::BasicBlock* oror = llvm::BasicBlock::Create("oror", gIR->topfunc(), oldend);
llvm::BasicBlock* ororend = llvm::BasicBlock::Create("ororend", gIR->topfunc(), oldend); llvm::BasicBlock* ororend = llvm::BasicBlock::Create("ororend", gIR->topfunc(), oldend);
LLValue* ubool = DtoBoolean(u); LLValue* ubool = DtoBoolean(loc, u);
DtoStore(ubool,resval); DtoStore(ubool,resval);
llvm::BranchInst::Create(ororend,oror,ubool,p->scopebb()); llvm::BranchInst::Create(ororend,oror,ubool,p->scopebb());
p->scope() = IRScope(oror, ororend); p->scope() = IRScope(oror, ororend);
DValue* v = e2->toElem(p); DValue* v = e2->toElem(p);
LLValue* vbool = DtoBoolean(v); LLValue* vbool = DtoBoolean(loc, v);
DtoStore(vbool,resval); DtoStore(vbool,resval);
llvm::BranchInst::Create(ororend,p->scopebb()); llvm::BranchInst::Create(ororend,p->scopebb());
@ -2289,17 +2289,17 @@ DValue* CondExp::toElem(IRState* p)
llvm::BasicBlock* condend = llvm::BasicBlock::Create("condend", gIR->topfunc(), oldend); llvm::BasicBlock* condend = llvm::BasicBlock::Create("condend", gIR->topfunc(), oldend);
DValue* c = econd->toElem(p); DValue* c = econd->toElem(p);
LLValue* cond_val = DtoBoolean(c); LLValue* cond_val = DtoBoolean(loc, c);
llvm::BranchInst::Create(condtrue,condfalse,cond_val,p->scopebb()); llvm::BranchInst::Create(condtrue,condfalse,cond_val,p->scopebb());
p->scope() = IRScope(condtrue, condfalse); p->scope() = IRScope(condtrue, condfalse);
DValue* u = e1->toElem(p); DValue* u = e1->toElem(p);
DtoAssign(dvv, u); DtoAssign(loc, dvv, u);
llvm::BranchInst::Create(condend,p->scopebb()); llvm::BranchInst::Create(condend,p->scopebb());
p->scope() = IRScope(condfalse, condend); p->scope() = IRScope(condfalse, condend);
DValue* v = e2->toElem(p); DValue* v = e2->toElem(p);
DtoAssign(dvv, v); DtoAssign(loc, dvv, v);
llvm::BranchInst::Create(condend,p->scopebb()); llvm::BranchInst::Create(condend,p->scopebb());
p->scope() = IRScope(condend, oldend); p->scope() = IRScope(condend, oldend);
@ -2332,7 +2332,7 @@ DValue* NegExp::toElem(IRState* p)
DValue* l = e1->toElem(p); DValue* l = e1->toElem(p);
if (type->iscomplex()) { if (type->iscomplex()) {
return DtoComplexNeg(type, l); return DtoComplexNeg(loc, type, l);
} }
LLValue* val = l->getRVal(); LLValue* val = l->getRVal();
@ -2390,11 +2390,11 @@ DValue* CatAssignExp::toElem(IRState* p)
if (e2type == elemtype) { if (e2type == elemtype) {
DSliceValue* slice = DtoCatAssignElement(l,e2); DSliceValue* slice = DtoCatAssignElement(l,e2);
DtoAssign(l, slice); DtoAssign(loc, l, slice);
} }
else if (e1type == e2type) { else if (e1type == e2type) {
DSliceValue* slice = DtoCatAssignArray(l,e2); DSliceValue* slice = DtoCatAssignArray(l,e2);
DtoAssign(l, slice); DtoAssign(loc, l, slice);
} }
else else
assert(0 && "only one element at a time right now"); assert(0 && "only one element at a time right now");
@ -2481,7 +2481,7 @@ DValue* ArrayLiteralExp::toElem(IRState* p)
DValue* e = expr->toElem(p); DValue* e = expr->toElem(p);
DImValue* im = e->isIm(); DImValue* im = e->isIm();
if (!im || !im->inPlace()) { if (!im || !im->inPlace()) {
DtoAssign(vv, e); DtoAssign(loc, vv, e);
} }
} }
@ -2566,7 +2566,7 @@ DValue* StructLiteralExp::toElem(IRState* p)
DValue* ve = vx->toElem(p); DValue* ve = vx->toElem(p);
if (!ve->inPlace()) if (!ve->inPlace())
DtoAssign(darrptr, ve); DtoAssign(loc, darrptr, ve);
j++; j++;
} }
@ -2606,7 +2606,7 @@ DValue* InExp::toElem(IRState* p)
DValue* key = e1->toElem(p); DValue* key = e1->toElem(p);
DValue* aa = e2->toElem(p); DValue* aa = e2->toElem(p);
return DtoAAIn(type, aa, key); return DtoAAIn(loc, type, aa, key);
} }
DValue* RemoveExp::toElem(IRState* p) DValue* RemoveExp::toElem(IRState* p)
@ -2617,7 +2617,7 @@ DValue* RemoveExp::toElem(IRState* p)
DValue* aa = e1->toElem(p); DValue* aa = e1->toElem(p);
DValue* key = e2->toElem(p); DValue* key = e2->toElem(p);
DtoAARemove(aa, key); DtoAARemove(loc, aa, key);
return NULL; // does not produce anything useful return NULL; // does not produce anything useful
} }
@ -2652,11 +2652,11 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p)
// index // index
DValue* key = ekey->toElem(p); DValue* key = ekey->toElem(p);
DValue* mem = DtoAAIndex(vtype, aa, key); DValue* mem = DtoAAIndex(loc, vtype, aa, key);
// store // store
DValue* val = eval->toElem(p); DValue* val = eval->toElem(p);
DtoAssign(mem, val); DtoAssign(loc, mem, val);
} }
return aa; return aa;