| 1018 | } |
| 1019 | |
| 1020 | CodegenAnyValReadWriteInfo CodegenAnyVal::ToReadWriteInfo() { |
| 1021 | llvm::IRBuilderBase::InsertPoint ip = builder_->saveIP(); |
| 1022 | |
| 1023 | llvm::LLVMContext& context = codegen_->context(); |
| 1024 | llvm::Function* fn = builder_->GetInsertBlock()->getParent(); |
| 1025 | |
| 1026 | CodegenAnyValReadWriteInfo res(codegen_, builder_, type_); |
| 1027 | |
| 1028 | llvm::BasicBlock* entry_block = llvm::BasicBlock::Create(context, "entry", fn); |
| 1029 | builder_->SetInsertPoint(entry_block); |
| 1030 | |
| 1031 | // Create new basic blocks and branch instruction |
| 1032 | llvm::BasicBlock* non_null_block = llvm::BasicBlock::Create(context, "non_null", fn); |
| 1033 | llvm::BasicBlock* null_block = llvm::BasicBlock::Create(context, "null", fn); |
| 1034 | llvm::Value* is_null = GetIsNull(); |
| 1035 | builder_->CreateCondBr(is_null, null_block, non_null_block); |
| 1036 | |
| 1037 | builder_->SetInsertPoint(non_null_block); |
| 1038 | if (type_.IsStructType()) { |
| 1039 | StructToReadWriteInfo(&res, GetPtr()); |
| 1040 | } else if (type_.IsStringType() || type_.IsCollectionType()) { |
| 1041 | res.SetPtrAndLen(GetPtr(), GetLen()); |
| 1042 | } else if (type_.type == TYPE_TIMESTAMP) { |
| 1043 | res.SetTimeAndDate(GetTimeOfDay(), GetDate()); |
| 1044 | } else { |
| 1045 | res.SetSimpleVal(GetVal()); |
| 1046 | } |
| 1047 | |
| 1048 | res.SetBlocks(entry_block, null_block, non_null_block); |
| 1049 | |
| 1050 | builder_->restoreIP(ip); |
| 1051 | return res; |
| 1052 | } |
| 1053 | |
| 1054 | void CodegenAnyVal::StructChildToReadWriteInfo( |
| 1055 | CodegenAnyValReadWriteInfo* read_write_info, |
no test coverage detected