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

Method linearizedStateVariables

libsolidity/ast/Types.cpp:2153–2185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2151}
2152
2153std::vector<std::tuple<VariableDeclaration const*, u256, unsigned>> ContractType::linearizedStateVariables(DataLocation _location) const
2154{
2155 VariableDeclaration::Location location;
2156 switch (_location)
2157 {
2158 case DataLocation::Storage:
2159 location = VariableDeclaration::Location::Unspecified;
2160 break;
2161 case DataLocation::Transient:
2162 location = VariableDeclaration::Location::Transient;
2163 break;
2164 default:
2165 solAssert(false);
2166 }
2167
2168 std::vector<VariableDeclaration const*> variables;
2169 for (ContractDefinition const* contract: m_contract.annotation().linearizedBaseContracts | ranges::views::reverse)
2170 for (VariableDeclaration const* variable: contract->stateVariables())
2171 if (!(variable->isConstant() || variable->immutable()) && variable->referenceLocation() == location)
2172 variables.push_back(variable);
2173
2174 TypePointers types;
2175 for (auto variable: variables)
2176 types.push_back(variable->annotation().type);
2177 StorageOffsets offsets;
2178 offsets.computeOffsets(types, layoutBaseForInheritanceHierarchy(m_contract, _location));
2179
2180 std::vector<std::tuple<VariableDeclaration const*, u256, unsigned>> variablesAndOffsets;
2181 for (size_t index = 0; index < variables.size(); ++index)
2182 if (auto const* offset = offsets.offset(index))
2183 variablesAndOffsets.emplace_back(variables[index], offset->first, offset->second);
2184 return variablesAndOffsets;
2185}
2186
2187std::vector<VariableDeclaration const*> ContractType::immutableVariables() const
2188{

Callers 3

generateMethod · 0.80
resetContextMethod · 0.80

Calls 8

immutableMethod · 0.80
referenceLocationMethod · 0.80
computeOffsetsMethod · 0.80
offsetMethod · 0.80
stateVariablesMethod · 0.45
isConstantMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected