| 107 | }; |
| 108 | |
| 109 | struct ConstIntNodeType : NodeType { |
| 110 | ConstIntNodeType(LangModule& mod, int num) |
| 111 | : NodeType(mod, "const-int", "Int literal"), number(num) { |
| 112 | makePure(); |
| 113 | |
| 114 | setDataOutputs({{"", mod.typeFromName("i32")}}); |
| 115 | } |
| 116 | |
| 117 | Result codegen( |
| 118 | size_t /*inputExecID*/, const llvm::DebugLoc& nodeLocation, |
| 119 | const std::vector<llvm::Value*>& io, llvm::BasicBlock* codegenInto, |
| 120 | const std::vector<llvm::BasicBlock*>& outputBlocks, |
| 121 | std::unordered_map<std::string, std::shared_ptr<void>>& /*compileCache*/) override { |
| 122 | assert(io.size() == 1 && codegenInto != nullptr && outputBlocks.size() == 1); |
| 123 | |
| 124 | llvm::IRBuilder<> builder(codegenInto); |
| 125 | builder.SetCurrentDebugLocation(nodeLocation); |
| 126 | |
| 127 | builder.CreateStore(builder.getInt32(number), io[0], false); |
| 128 | builder.CreateBr(outputBlocks[0]); |
| 129 | |
| 130 | return {}; |
| 131 | } |
| 132 | |
| 133 | std::unique_ptr<NodeType> clone() const override { |
| 134 | return std::make_unique<ConstIntNodeType>(*this); |
| 135 | } |
| 136 | |
| 137 | nlohmann::json toJSON() const override { return number; } |
| 138 | int number; |
| 139 | }; |
| 140 | |
| 141 | struct ConstFloatNodeType : NodeType { |
| 142 | ConstFloatNodeType(LangModule& mod, double num) |
nothing calls this directly
no outgoing calls
no test coverage detected