Mercurial > projects > ldc
comparison gen/toir.c @ 49:e5c4bece7fa1 trunk
[svn r53] added basic support for delegate literals. if you access outer variables you get a broken module
author | lindquist |
---|---|
date | Fri, 19 Oct 2007 17:43:46 +0200 |
parents | 4d171915a77b |
children | 6fcc08a4d406 |
comparison
equal
deleted
inserted
replaced
48:4d171915a77b | 49:e5c4bece7fa1 |
---|---|
568 else if (r->inplace) { | 568 else if (r->inplace) { |
569 // do nothing | 569 // do nothing |
570 e->inplace = true; | 570 e->inplace = true; |
571 e->mem = l->mem; | 571 e->mem = l->mem; |
572 } | 572 } |
573 else | 573 else { |
574 assert(0); | 574 LLVM_DtoDelegateCopy(l->mem, r->getValue()); |
575 e->mem = l->mem; | |
576 } | |
575 } | 577 } |
576 else | 578 else |
577 assert(0); | 579 assert(0); |
578 } | 580 } |
579 // !struct && !array && !pointer && !class | 581 // !struct && !array && !pointer && !class |
2575 Expression* expr = (Expression*)elements->data[i]; | 2577 Expression* expr = (Expression*)elements->data[i]; |
2576 vals[i] = expr->toConstElem(p); | 2578 vals[i] = expr->toConstElem(p); |
2577 } | 2579 } |
2578 | 2580 |
2579 return llvm::ConstantArray::get(arrtype, vals); | 2581 return llvm::ConstantArray::get(arrtype, vals); |
2582 } | |
2583 | |
2584 ////////////////////////////////////////////////////////////////////////////////////////// | |
2585 | |
2586 elem* FuncExp::toElem(IRState* p) | |
2587 { | |
2588 Logger::print("FuncExp::toElem: %s | %s\n", toChars(), type->toChars()); | |
2589 LOG_SCOPE; | |
2590 | |
2591 assert(fd); | |
2592 | |
2593 if (fd->isNested()) Logger::println("nested"); | |
2594 Logger::println("kind = %s\n", fd->kind()); | |
2595 | |
2596 fd->toObjFile(); | |
2597 | |
2598 llvm::Value* lval = p->toplval(); | |
2599 | |
2600 elem* e = new elem; | |
2601 | |
2602 llvm::Value* context = LLVM_DtoGEPi(lval,0,0,"tmp",p->scopebb()); | |
2603 //llvm::Value* castcontext = llvm::ConstantPointerNull::get(context->getType()); | |
2604 //new llvm::StoreInst(castcontext, context, p->scopebb()); | |
2605 | |
2606 llvm::Value* fptr = LLVM_DtoGEPi(lval,0,1,"tmp",p->scopebb()); | |
2607 | |
2608 assert(fd->llvmValue); | |
2609 llvm::Value* castfptr = new llvm::BitCastInst(fd->llvmValue,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); | |
2610 new llvm::StoreInst(castfptr, fptr, p->scopebb()); | |
2611 | |
2612 e->inplace = true; | |
2613 | |
2614 return e; | |
2580 } | 2615 } |
2581 | 2616 |
2582 ////////////////////////////////////////////////////////////////////////////////////////// | 2617 ////////////////////////////////////////////////////////////////////////////////////////// |
2583 | 2618 |
2584 #define STUB(x) elem *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } | 2619 #define STUB(x) elem *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } |
2620 //STUB(CallExp); | 2655 //STUB(CallExp); |
2621 STUB(DotTypeExp); | 2656 STUB(DotTypeExp); |
2622 STUB(TypeDotIdExp); | 2657 STUB(TypeDotIdExp); |
2623 //STUB(DotVarExp); | 2658 //STUB(DotVarExp); |
2624 //STUB(AssertExp); | 2659 //STUB(AssertExp); |
2625 STUB(FuncExp); | 2660 //STUB(FuncExp); |
2626 //STUB(DelegateExp); | 2661 //STUB(DelegateExp); |
2627 //STUB(VarExp); | 2662 //STUB(VarExp); |
2628 //STUB(DeclarationExp); | 2663 //STUB(DeclarationExp); |
2629 //STUB(NewExp); | 2664 //STUB(NewExp); |
2630 //STUB(SymOffExp); | 2665 //STUB(SymOffExp); |