| 171 | } |
| 172 | |
| 173 | std::vector<experimental::Type> TypeSystemHelpers::destSumType(Type _tupleType) const |
| 174 | { |
| 175 | if (!isTypeConstant(_tupleType)) |
| 176 | return {_tupleType}; |
| 177 | TypeConstructor sumConstructor = typeSystem.constructor(PrimitiveType::Sum); |
| 178 | auto [constructor, arguments] = destTypeConstant(_tupleType); |
| 179 | if (constructor == typeSystem.constructor(PrimitiveType::Void)) |
| 180 | return {}; |
| 181 | if (constructor != sumConstructor) |
| 182 | return {_tupleType}; |
| 183 | solAssert(arguments.size() == 2); |
| 184 | |
| 185 | std::vector<Type> result; |
| 186 | result.emplace_back(arguments.front()); |
| 187 | Type tail = arguments.back(); |
| 188 | while (true) |
| 189 | { |
| 190 | if (!isTypeConstant(tail)) |
| 191 | break; |
| 192 | auto [tailConstructor, tailArguments] = destTypeConstant(tail); |
| 193 | if (tailConstructor != sumConstructor) |
| 194 | break; |
| 195 | solAssert(tailArguments.size() == 2); |
| 196 | result.emplace_back(tailArguments.front()); |
| 197 | tail = tailArguments.back(); |
| 198 | } |
| 199 | result.emplace_back(tail); |
| 200 | return result; |
| 201 | } |
| 202 | |
| 203 | std::tuple<TypeConstructor, std::vector<experimental::Type>> TypeSystemHelpers::destTypeConstant(Type _type) const |
| 204 | { |
nothing calls this directly
no test coverage detected