| 2151 | } |
| 2152 | |
| 2153 | std::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 | |
| 2187 | std::vector<VariableDeclaration const*> ContractType::immutableVariables() const |
| 2188 | { |
no test coverage detected