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

Method destTupleType

libsolidity/experimental/ast/TypeSystemHelper.cpp:131–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131std::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
161experimental::Type TypeSystemHelpers::sumType(std::vector<Type> _elements) const
162{

Callers 2

visitMethod · 0.80
typeToStringMethod · 0.80

Calls 2

constructorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected