Mercurial > projects > ldc
comparison gen/toir.cpp @ 127:facc562f5674 trunk
[svn r131] Fixed #11
All associative array properties now work as they should.
Fixed problems with some cases of array.length and array.ptr.
Fixed some problems with array properties.
Fixed 'in' contracts.
author | lindquist |
---|---|
date | Fri, 30 Nov 2007 12:56:52 +0100 |
parents | c42d245468ea |
children | 8096ba7082db |
comparison
equal
deleted
inserted
replaced
126:a2c2c3c1a73d | 127:facc562f5674 |
---|---|
902 } | 902 } |
903 else { | 903 else { |
904 Logger::cout() << "what are we calling? : " << *funcval << '\n'; | 904 Logger::cout() << "what are we calling? : " << *funcval << '\n'; |
905 } | 905 } |
906 assert(llfnty); | 906 assert(llfnty); |
907 //Logger::cout() << "Function LLVM type: " << *llfnty << '\n'; | 907 Logger::cout() << "Function LLVM type: " << *llfnty << '\n'; |
908 | 908 |
909 // argument handling | 909 // argument handling |
910 llvm::FunctionType::param_iterator argiter = llfnty->param_begin(); | 910 llvm::FunctionType::param_iterator argiter = llfnty->param_begin(); |
911 int j = 0; | 911 int j = 0; |
912 | 912 |
2570 DValue* aa = e2->toElem(p); | 2570 DValue* aa = e2->toElem(p); |
2571 | 2571 |
2572 return DtoAAIn(type, aa, key); | 2572 return DtoAAIn(type, aa, key); |
2573 } | 2573 } |
2574 | 2574 |
2575 DValue* RemoveExp::toElem(IRState* p) | |
2576 { | |
2577 Logger::print("RemoveExp::toElem: %s\n", toChars()); | |
2578 LOG_SCOPE; | |
2579 | |
2580 DValue* aa = e1->toElem(p); | |
2581 DValue* key = e2->toElem(p); | |
2582 | |
2583 DtoAARemove(aa, key); | |
2584 | |
2585 return NULL; // does not produce anything useful | |
2586 } | |
2587 | |
2575 ////////////////////////////////////////////////////////////////////////////////////////// | 2588 ////////////////////////////////////////////////////////////////////////////////////////// |
2576 | 2589 |
2577 DValue* AssocArrayLiteralExp::toElem(IRState* p) | 2590 DValue* AssocArrayLiteralExp::toElem(IRState* p) |
2578 { | 2591 { |
2579 Logger::print("AssocArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); | 2592 Logger::print("AssocArrayLiteralExp::toElem: %s | %s\n", toChars(), type->toChars()); |
2581 | 2594 |
2582 assert(keys); | 2595 assert(keys); |
2583 assert(values); | 2596 assert(values); |
2584 assert(keys->dim == values->dim); | 2597 assert(keys->dim == values->dim); |
2585 | 2598 |
2599 Type* aatype = DtoDType(type); | |
2600 Type* vtype = aatype->next; | |
2601 | |
2602 DValue* aa; | |
2603 if (p->topexp() && p->topexp()->e2 == this) | |
2604 { | |
2605 aa = p->topexp()->v; | |
2606 } | |
2607 else | |
2608 { | |
2609 llvm::Value* tmp = new llvm::AllocaInst(DtoType(type),"aaliteral",p->topallocapoint()); | |
2610 aa = new DVarValue(type, tmp, true); | |
2611 } | |
2612 | |
2586 const size_t n = keys->dim; | 2613 const size_t n = keys->dim; |
2587 for (size_t i=0; i<n; ++i) | 2614 for (size_t i=0; i<n; ++i) |
2588 { | 2615 { |
2589 Expression* ekey = (Expression*)keys->data[i]; | 2616 Expression* ekey = (Expression*)keys->data[i]; |
2590 Expression* eval = (Expression*)values->data[i]; | 2617 Expression* eval = (Expression*)values->data[i]; |
2591 | 2618 |
2592 Logger::println("(%u) aa[%s] = %s", i, ekey->toChars(), eval->toChars()); | 2619 Logger::println("(%u) aa[%s] = %s", i, ekey->toChars(), eval->toChars()); |
2593 } | 2620 |
2594 | 2621 // index |
2595 assert(0); | 2622 DValue* key = ekey->toElem(p); |
2623 DValue* mem = DtoAAIndex(vtype, aa, key); | |
2624 | |
2625 // store | |
2626 DValue* val = eval->toElem(p); | |
2627 DtoAssign(mem, val); | |
2628 } | |
2629 | |
2630 return aa; | |
2596 } | 2631 } |
2597 | 2632 |
2598 ////////////////////////////////////////////////////////////////////////////////////////// | 2633 ////////////////////////////////////////////////////////////////////////////////////////// |
2599 | 2634 |
2600 #define STUB(x) DValue *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } | 2635 #define STUB(x) DValue *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } |
2664 //STUB(DeleteExp); | 2699 //STUB(DeleteExp); |
2665 //STUB(IndexExp); | 2700 //STUB(IndexExp); |
2666 //STUB(CommaExp); | 2701 //STUB(CommaExp); |
2667 //STUB(ArrayLengthExp); | 2702 //STUB(ArrayLengthExp); |
2668 //STUB(HaltExp); | 2703 //STUB(HaltExp); |
2669 STUB(RemoveExp); | 2704 //STUB(RemoveExp); |
2670 //STUB(ArrayLiteralExp); | 2705 //STUB(ArrayLiteralExp); |
2671 //STUB(AssocArrayLiteralExp); | 2706 //STUB(AssocArrayLiteralExp); |
2672 //STUB(StructLiteralExp); | 2707 //STUB(StructLiteralExp); |
2673 STUB(TupleExp); | 2708 STUB(TupleExp); |
2674 | 2709 |