| 156 | } |
| 157 | |
| 158 | void V9Builder::AddV9Reducer(const std::string& reducer_name, |
| 159 | const std::vector<bsatn::AlgebraicType>& param_types, |
| 160 | const std::vector<std::string>& param_names, |
| 161 | const std::vector<const std::type_info*>& param_cpp_types, |
| 162 | const std::vector<std::string>& param_type_names, |
| 163 | std::optional<Lifecycle> lifecycle) { |
| 164 | // Create the reducer definition |
| 165 | RawReducerDefV9 reducer_def; |
| 166 | reducer_def.name = reducer_name; |
| 167 | |
| 168 | // Build the params ProductType |
| 169 | ProductType params; |
| 170 | for (size_t i = 0; i < param_types.size(); ++i) { |
| 171 | ProductTypeElement elem; |
| 172 | elem.name = i < param_names.size() ? std::make_optional(param_names[i]) : std::nullopt; |
| 173 | |
| 174 | // Register the parameter type with proper C++ type info and name |
| 175 | const std::type_info* cpp_type = i < param_cpp_types.size() ? param_cpp_types[i] : nullptr; |
| 176 | const std::string& type_name = i < param_type_names.size() ? param_type_names[i] : ""; |
| 177 | |
| 178 | // Register the parameter type using the unified system |
| 179 | elem.algebraic_type = registerType(param_types[i], type_name, cpp_type); |
| 180 | |
| 181 | params.elements.push_back(elem); |
| 182 | } |
| 183 | |
| 184 | reducer_def.params = params; |
| 185 | reducer_def.lifecycle = lifecycle; |
| 186 | |
| 187 | // Add directly to the global V9 module |
| 188 | GetV9Module().reducers.push_back(reducer_def); |
| 189 | //fprintf(stdout, "DEBUG: Added reducer '%s' to V9 module\n", reducer_name.c_str()); |
| 190 | } |
| 191 | |
| 192 | // Helper function to get field name from Product type structure |
| 193 | std::string V9Builder::getFieldName(const bsatn::AlgebraicType& table_type, uint16_t column_index) const { |