| 3268 | } |
| 3269 | |
| 3270 | IRVariable IRGeneratorForStatements::readFromLValue(IRLValue const& _lvalue) |
| 3271 | { |
| 3272 | IRVariable result{m_context.newYulVariable(), _lvalue.type}; |
| 3273 | std::visit(GenericVisitor{ |
| 3274 | [&](IRLValue::Storage const& _storage) { |
| 3275 | if (!_lvalue.type.isValueType()) |
| 3276 | define(result) << _storage.slot << "\n"; |
| 3277 | else if (std::holds_alternative<std::string>(_storage.offset)) |
| 3278 | define(result) << |
| 3279 | m_utils.readFromStorageDynamic(_lvalue.type, true, VariableDeclaration::Location::Unspecified) << |
| 3280 | "(" << |
| 3281 | _storage.slot << |
| 3282 | ", " << |
| 3283 | std::get<std::string>(_storage.offset) << |
| 3284 | ")\n"; |
| 3285 | else |
| 3286 | define(result) << |
| 3287 | m_utils.readFromStorage(_lvalue.type, std::get<unsigned>(_storage.offset), true, VariableDeclaration::Location::Unspecified) << |
| 3288 | "(" << |
| 3289 | _storage.slot << |
| 3290 | ")\n"; |
| 3291 | }, |
| 3292 | [&](IRLValue::TransientStorage const& _transientStorage) { |
| 3293 | if (!_lvalue.type.isValueType()) |
| 3294 | define(result) << _transientStorage.slot << "\n"; |
| 3295 | else if (std::holds_alternative<std::string>(_transientStorage.offset)) |
| 3296 | define(result) << |
| 3297 | m_utils.readFromStorageDynamic(_lvalue.type, true, VariableDeclaration::Location::Transient) << |
| 3298 | "(" << |
| 3299 | _transientStorage.slot << |
| 3300 | ", " << |
| 3301 | std::get<std::string>(_transientStorage.offset) << |
| 3302 | ")\n"; |
| 3303 | else |
| 3304 | define(result) << |
| 3305 | m_utils.readFromStorage(_lvalue.type, std::get<unsigned>(_transientStorage.offset), true, VariableDeclaration::Location::Transient) << |
| 3306 | "(" << |
| 3307 | _transientStorage.slot << |
| 3308 | ")\n"; |
| 3309 | }, |
| 3310 | [&](IRLValue::Memory const& _memory) { |
| 3311 | if (_lvalue.type.isValueType()) |
| 3312 | define(result) << |
| 3313 | m_utils.readFromMemory(_lvalue.type) << |
| 3314 | "(" << |
| 3315 | _memory.address << |
| 3316 | ")\n"; |
| 3317 | else |
| 3318 | define(result) << "mload(" << _memory.address << ")\n"; |
| 3319 | }, |
| 3320 | [&](IRLValue::Stack const& _stack) { |
| 3321 | define(result, _stack.variable); |
| 3322 | }, |
| 3323 | [&](IRLValue::Immutable const& _immutable) { |
| 3324 | solUnimplementedAssert(_lvalue.type.isValueType()); |
| 3325 | solUnimplementedAssert(_lvalue.type.sizeOnStack() == 1); |
| 3326 | solAssert(_lvalue.type == *_immutable.variable->type()); |
| 3327 | if (m_context.executionContext() == IRGenerationContext::ExecutionContext::Creation) |
nothing calls this directly
no test coverage detected