Fix delegate equality.

Fixes:
mini/delegate.d
run/d/delegate_17_A
This commit is contained in:
Christian Kamm
2008-08-16 10:48:25 +02:00
parent 6c117e4301
commit 406cefb53f

View File

@@ -205,25 +205,24 @@ const LLStructType* DtoDelegateType(Type* t)
LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs)
{
Logger::println("Doing delegate equality");
llvm::ICmpInst::Predicate pred = (op == TOKequal || op == TOKidentity) ? llvm::ICmpInst::ICMP_EQ : llvm::ICmpInst::ICMP_NE;
llvm::Value *b1, *b2;
if (rhs == NULL)
{
LLValue* l = DtoLoad(DtoGEPi(lhs,0,0));
LLValue* r = llvm::Constant::getNullValue(l->getType());
b1 = gIR->ir->CreateICmp(pred,l,r,"tmp");
b1 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp");
l = DtoLoad(DtoGEPi(lhs,0,1));
r = llvm::Constant::getNullValue(l->getType());
b2 = gIR->ir->CreateICmp(pred,l,r,"tmp");
b2 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp");
}
else
{
LLValue* l = DtoLoad(DtoGEPi(lhs,0,0));
LLValue* r = DtoLoad(DtoGEPi(rhs,0,0));
b1 = gIR->ir->CreateICmp(pred,l,r,"tmp");
b1 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp");
l = DtoLoad(DtoGEPi(lhs,0,1));
r = DtoLoad(DtoGEPi(rhs,0,1));
b2 = gIR->ir->CreateICmp(pred,l,r,"tmp");
b2 = gIR->ir->CreateICmp(llvm::ICmpInst::ICMP_EQ,l,r,"tmp");
}
LLValue* b = gIR->ir->CreateAnd(b1,b2,"tmp");
if (op == TOKnotequal || op == TOKnotidentity)