MCPcopy Create free account
hub / github.com/argotorg/solidity / destSumType

Method destSumType

libsolidity/experimental/ast/TypeSystemHelper.cpp:173–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173std::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
203std::tuple<TypeConstructor, std::vector<experimental::Type>> TypeSystemHelpers::destTypeConstant(Type _type) const
204{

Callers

nothing calls this directly

Calls 2

constructorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected