comparison gen/statements.cpp @ 197:bfcb657756f6 trunk

[svn r213] Fixed: foreach on an object seems to have been broken, the issue was that DMD generates an implicit delegate with conflicting types for 'this'. Fixed: string switch runtime support had wrong param types. Fixed: string switch on a temporary slice was broken.
author lindquist
date Mon, 12 May 2008 20:02:52 +0200
parents 89e21eeaf4c4
children e937752e4541
comparison
equal deleted inserted replaced
196:48bebfd701a5 197:bfcb657756f6
600 assert(0 && "not char/wchar/dchar"); 600 assert(0 && "not char/wchar/dchar");
601 } 601 }
602 602
603 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname); 603 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
604 std::vector<llvm::Value*> args; 604 std::vector<llvm::Value*> args;
605 Logger::cout() << *table->getType() << '\n';
606 Logger::cout() << *fn->getFunctionType()->getParamType(0) << '\n';
607 assert(table->getType() == fn->getFunctionType()->getParamType(0));
605 args.push_back(table); 608 args.push_back(table);
606 args.push_back(e->toElem(gIR)->getRVal()); 609
610 DValue* val = e->toElem(gIR);
611 llvm::Value* llval;
612 if (DSliceValue* sval = val->isSlice())
613 {
614 // give storage
615 llval = new llvm::AllocaInst(DtoType(e->type), "tmp", gIR->topallocapoint());
616 DVarValue* vv = new DVarValue(e->type, llval, true);
617 DtoAssign(vv, val);
618 }
619 else
620 {
621 llval = val->getRVal();
622 }
623 assert(llval->getType() == fn->getFunctionType()->getParamType(1));
624 args.push_back(llval);
625
607 return gIR->ir->CreateCall(fn, args.begin(), args.end(), "tmp"); 626 return gIR->ir->CreateCall(fn, args.begin(), args.end(), "tmp");
608 } 627 }
609 628
610 void SwitchStatement::toIR(IRState* p) 629 void SwitchStatement::toIR(IRState* p)
611 { 630 {