Changeset 619:722630261d62
- Timestamp:
- 09/28/08 15:09:21
(3 months ago)
- Author:
- tomas@myhost
- Children:
621:0ecdb11ca85e 622:26fce59fe80a
- branch:
- default
- Message:
Implemented constant pointer casts (like casting function pointer to void* as a constant global initializer)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r599 |
r619 |
|
| 1004 | 1004 | // For operator overloading |
|---|
| 1005 | 1005 | Identifier *opId(); |
|---|
| | 1006 | |
|---|
| | 1007 | // LLVMDC |
|---|
| | 1008 | virtual llvm::Constant *toConstElem(IRState *irs); |
|---|
| 1006 | 1009 | }; |
|---|
| 1007 | 1010 | |
|---|
| r616 |
r619 |
|
| 816 | 816 | else |
|---|
| 817 | 817 | return v; |
|---|
| | 818 | } |
|---|
| | 819 | |
|---|
| | 820 | ////////////////////////////////////////////////////////////////////////////////////////// |
|---|
| | 821 | |
|---|
| | 822 | LLConstant* CastExp::toConstElem(IRState* p) |
|---|
| | 823 | { |
|---|
| | 824 | Logger::print("CastExp::toConstElem: %s | %s\n", toChars(), type->toChars()); |
|---|
| | 825 | LOG_SCOPE; |
|---|
| | 826 | |
|---|
| | 827 | LLConstant* c = e1->toConstElem(p); |
|---|
| | 828 | assert(isaPointer(c->getType())); |
|---|
| | 829 | |
|---|
| | 830 | const LLType* lltype = DtoType(type); |
|---|
| | 831 | assert(isaPointer(lltype)); |
|---|
| | 832 | |
|---|
| | 833 | return llvm::ConstantExpr::getBitCast(c, lltype); |
|---|
| 818 | 834 | } |
|---|
| 819 | 835 | |
|---|