Mercurial > projects > ldc
comparison gen/aa.cpp @ 458:121624c14053
Fixed AA Rvalue-only access (like indexing an AA return value immediately).
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 02 Aug 2008 22:35:24 +0200 |
parents | d3d3519b72e8 |
children | 45a67b6f1310 |
comparison
equal
deleted
inserted
replaced
457:d82ebdba4191 | 458:121624c14053 |
---|---|
64 return DtoTypeInfoOf(keytype, false); | 64 return DtoTypeInfoOf(keytype, false); |
65 } | 65 } |
66 | 66 |
67 ///////////////////////////////////////////////////////////////////////////////////// | 67 ///////////////////////////////////////////////////////////////////////////////////// |
68 | 68 |
69 DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key) | 69 DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) |
70 { | 70 { |
71 // call: | 71 // call: |
72 // extern(C) void* _aaGet(AA* aa, TypeInfo keyti, void* pkey, size_t valuesize) | 72 // extern(C) void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) |
73 // or | |
74 // extern(C) void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) | |
73 | 75 |
74 // first get the runtime function | 76 // first get the runtime function |
75 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaGet"); | 77 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, lvalue?"_aaGet":"_aaGetRvalue"); |
76 const llvm::FunctionType* funcTy = func->getFunctionType(); | 78 const llvm::FunctionType* funcTy = func->getFunctionType(); |
77 | 79 |
78 // aa param | 80 // aa param |
79 LLValue* aaval = aa->getLVal(); | 81 LLValue* aaval = lvalue ? aa->getLVal() : aa->getRVal(); |
80 aaval = DtoBitCast(aaval, funcTy->getParamType(0)); | 82 aaval = DtoBitCast(aaval, funcTy->getParamType(0)); |
81 | 83 |
82 // keyti param | 84 // keyti param |
83 LLValue* keyti = to_keyti(key); | 85 LLValue* keyti = to_keyti(key); |
84 keyti = DtoBitCast(keyti, funcTy->getParamType(1)); | 86 keyti = DtoBitCast(keyti, funcTy->getParamType(1)); |