comparison gen/toir.cpp @ 1512:09734fb929c0

Make == for associative arrays test for equality, not identity. _aaEq was added to runtime/internal/aaA.d which forwards to TypeInfo_AssociativeArray.equals in genobj.d. On the codegen side, DtoAAEquals was added to gen/aa.cpp and is called from EqualExp::toElem in gen/toir.cpp. I assume that the frontend will produce an error if == is used on associative arrays of different type. This fixes DMD bug 1429.
author Christian Kamm <kamm incasoftware de>
date Sun, 21 Jun 2009 19:05:24 +0200
parents 5b66008246bb
children 8a5570ddad25
comparison
equal deleted inserted replaced
1511:5b66008246bb 1512:09734fb929c0
1446 1446
1447 LLValue* eval = 0; 1447 LLValue* eval = 0;
1448 1448
1449 // the Tclass catches interface comparisons, regular 1449 // the Tclass catches interface comparisons, regular
1450 // class equality should be rewritten as a.opEquals(b) by this time 1450 // class equality should be rewritten as a.opEquals(b) by this time
1451 if (t->isintegral() || t->ty == Tpointer || t->ty == Tclass || t->ty == Taarray) 1451 if (t->isintegral() || t->ty == Tpointer || t->ty == Tclass)
1452 { 1452 {
1453 Logger::println("integral or pointer or interface"); 1453 Logger::println("integral or pointer or interface");
1454 llvm::ICmpInst::Predicate cmpop; 1454 llvm::ICmpInst::Predicate cmpop;
1455 switch(op) 1455 switch(op)
1456 { 1456 {
1480 else if (t->ty == Tsarray || t->ty == Tarray) 1480 else if (t->ty == Tsarray || t->ty == Tarray)
1481 { 1481 {
1482 Logger::println("static or dynamic array"); 1482 Logger::println("static or dynamic array");
1483 eval = DtoArrayEquals(loc,op,l,r); 1483 eval = DtoArrayEquals(loc,op,l,r);
1484 } 1484 }
1485 else if (t->ty == Taarray)
1486 {
1487 Logger::println("associative array");
1488 eval = DtoAAEquals(loc,op,l,r);
1489 }
1485 else if (t->ty == Tdelegate) 1490 else if (t->ty == Tdelegate)
1486 { 1491 {
1487 Logger::println("delegate"); 1492 Logger::println("delegate");
1488 eval = DtoDelegateEquals(op,l->getRVal(),r->getRVal()); 1493 eval = DtoDelegateEquals(op,l->getRVal(),r->getRVal());
1489 } 1494 }