| 129 | } |
| 130 | |
| 131 | std::vector<experimental::Type> TypeSystemHelpers::destTupleType(Type _tupleType) const |
| 132 | { |
| 133 | if (!isTypeConstant(_tupleType)) |
| 134 | return {_tupleType}; |
| 135 | TypeConstructor pairConstructor = typeSystem.constructor(PrimitiveType::Pair); |
| 136 | auto [constructor, arguments] = destTypeConstant(_tupleType); |
| 137 | if (constructor == typeSystem.constructor(PrimitiveType::Unit)) |
| 138 | return {}; |
| 139 | if (constructor != pairConstructor) |
| 140 | return {_tupleType}; |
| 141 | solAssert(arguments.size() == 2); |
| 142 | |
| 143 | std::vector<Type> result; |
| 144 | result.emplace_back(arguments.front()); |
| 145 | Type tail = arguments.back(); |
| 146 | while (true) |
| 147 | { |
| 148 | if (!isTypeConstant(tail)) |
| 149 | break; |
| 150 | auto [tailConstructor, tailArguments] = destTypeConstant(tail); |
| 151 | if (tailConstructor != pairConstructor) |
| 152 | break; |
| 153 | solAssert(tailArguments.size() == 2); |
| 154 | result.emplace_back(tailArguments.front()); |
| 155 | tail = tailArguments.back(); |
| 156 | } |
| 157 | result.emplace_back(tail); |
| 158 | return result; |
| 159 | } |
| 160 | |
| 161 | experimental::Type TypeSystemHelpers::sumType(std::vector<Type> _elements) const |
| 162 | { |
no test coverage detected