Mercurial > projects > ldc
comparison gen/toir.cpp @ 820:bb4a81e68ddb
Implemented allocating storage for a slice if its address is taken, fixes #115
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 02 Dec 2008 01:20:22 +0100 |
parents | 446263a8a30d |
children | 794c8af186ce |
comparison
equal
deleted
inserted
replaced
819:446263a8a30d | 820:bb4a81e68ddb |
---|---|
886 else if (DImValue* im = v->isIm()) { | 886 else if (DImValue* im = v->isIm()) { |
887 Logger::println("is immediate"); | 887 Logger::println("is immediate"); |
888 return v; | 888 return v; |
889 } | 889 } |
890 Logger::println("is nothing special"); | 890 Logger::println("is nothing special"); |
891 LLValue* lval = v->getLVal(); | 891 |
892 // we special case here, since apparently taking the address of a slice is ok | |
893 LLValue* lval; | |
894 if (v->isLVal()) | |
895 lval = v->getLVal(); | |
896 else | |
897 { | |
898 assert(v->isSlice()); | |
899 LLValue* rval = v->getRVal(); | |
900 lval = DtoAlloca(rval->getType(), ".tmp_slice_storage"); | |
901 DtoStore(rval, lval); | |
902 } | |
903 | |
892 if (Logger::enabled()) | 904 if (Logger::enabled()) |
893 Logger::cout() << "lval: " << *lval << '\n'; | 905 Logger::cout() << "lval: " << *lval << '\n'; |
894 return new DImValue(type, DtoBitCast(v->getLVal(), DtoType(type))); | 906 |
907 return new DImValue(type, DtoBitCast(lval, DtoType(type))); | |
895 } | 908 } |
896 | 909 |
897 LLConstant* AddrExp::toConstElem(IRState* p) | 910 LLConstant* AddrExp::toConstElem(IRState* p) |
898 { | 911 { |
899 // FIXME: this should probably be generalized more so we don't | 912 // FIXME: this should probably be generalized more so we don't |