| 535 | } |
| 536 | |
| 537 | Result codegen(size_t /*execInputID*/, const llvm::DebugLoc& nodeLocation, |
| 538 | const std::vector<llvm::Value*>& io, llvm::BasicBlock* codegenInto, |
| 539 | const std::vector<llvm::BasicBlock*>& outputBlocks, |
| 540 | std::unordered_map<std::string, std::shared_ptr<void>>& compileCache) override { |
| 541 | llvm::IRBuilder<> builder{codegenInto}; |
| 542 | builder.SetCurrentDebugLocation(nodeLocation); |
| 543 | |
| 544 | std::shared_ptr<void>& local = compileCache[mDataType.name]; |
| 545 | |
| 546 | if (local == nullptr) { |
| 547 | // create a new one! |
| 548 | local = std::make_shared<llvm::Value*>(builder.CreateAlloca(mDataType.type.llvmType())); |
| 549 | |
| 550 | // TODO: create an error here |
| 551 | } |
| 552 | |
| 553 | builder.CreateStore(builder.CreateLoad(*static_cast<llvm::Value**>(local.get())), io[0]); |
| 554 | |
| 555 | builder.CreateBr(outputBlocks[0]); |
| 556 | |
| 557 | return {}; |
| 558 | } |
| 559 | |
| 560 | nlohmann::json toJSON() const override { return mDataType.type.qualifiedName(); } |
| 561 | std::unique_ptr<NodeType> clone() const override { |