| 199 | } |
| 200 | |
| 201 | void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBoundaries, bool _cleanup) |
| 202 | { |
| 203 | // process special types (Reference, StringLiteral, Function) |
| 204 | if (auto ref = dynamic_cast<ReferenceType const*>(&_type)) |
| 205 | { |
| 206 | solUnimplementedAssert( |
| 207 | ref->location() == DataLocation::Memory, |
| 208 | "Only in-memory reference type can be stored." |
| 209 | ); |
| 210 | storeInMemoryDynamic(*TypeProvider::uint256(), _padToWordBoundaries, _cleanup); |
| 211 | } |
| 212 | else if (auto str = dynamic_cast<StringLiteralType const*>(&_type)) |
| 213 | { |
| 214 | m_context << Instruction::DUP1; |
| 215 | storeStringData(bytesConstRef(str->value())); |
| 216 | if (_padToWordBoundaries) |
| 217 | m_context << u256(std::max<size_t>(32, ((str->value().size() + 31) / 32) * 32)); |
| 218 | else |
| 219 | m_context << u256(str->value().size()); |
| 220 | m_context << Instruction::ADD; |
| 221 | } |
| 222 | else if ( |
| 223 | _type.category() == Type::Category::Function && |
| 224 | dynamic_cast<FunctionType const&>(_type).kind() == FunctionType::Kind::External |
| 225 | ) |
| 226 | { |
| 227 | combineExternalFunctionType(true); |
| 228 | m_context << Instruction::DUP2 << Instruction::MSTORE; |
| 229 | m_context << u256(_padToWordBoundaries ? 32 : 24) << Instruction::ADD; |
| 230 | } |
| 231 | else if (_type.isValueType()) |
| 232 | { |
| 233 | unsigned numBytes = prepareMemoryStore(_type, _padToWordBoundaries, _cleanup); |
| 234 | m_context << Instruction::DUP2 << Instruction::MSTORE; |
| 235 | m_context << u256(numBytes) << Instruction::ADD; |
| 236 | } |
| 237 | else // Should never happen |
| 238 | { |
| 239 | solAssert( |
| 240 | false, |
| 241 | "Memory store of type " + _type.toString(true) + " not allowed." |
| 242 | ); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMemory) |
| 247 | { |
no test coverage detected