| 246 | } |
| 247 | |
| 248 | std::pair<MachineAssemblyObject, MachineAssemblyObject> |
| 249 | YulStack::assembleWithDeployed(std::optional<std::string_view> _deployName, bool _viaSSACFG) |
| 250 | { |
| 251 | yulAssert(m_charStream); |
| 252 | |
| 253 | auto [creationAssembly, deployedAssembly] = assembleEVMWithDeployed(_deployName, _viaSSACFG); |
| 254 | if (!creationAssembly) |
| 255 | { |
| 256 | yulAssert(!deployedAssembly); |
| 257 | return {MachineAssemblyObject{}, MachineAssemblyObject{}}; |
| 258 | } |
| 259 | |
| 260 | MachineAssemblyObject creationObject; |
| 261 | MachineAssemblyObject deployedObject; |
| 262 | try |
| 263 | { |
| 264 | creationObject.bytecode = std::make_shared<evmasm::LinkerObject>(creationAssembly->assemble()); |
| 265 | yulAssert(creationObject.bytecode->immutableReferences.empty(), "Leftover immutables."); |
| 266 | creationObject.assembly = creationAssembly; |
| 267 | creationObject.sourceMappings = std::make_unique<std::string>(); |
| 268 | for (auto const& codeSection: creationAssembly->codeSections()) |
| 269 | { |
| 270 | *creationObject.sourceMappings += evmasm::AssemblyItem::computeSourceMapping( |
| 271 | codeSection.items, |
| 272 | {{m_charStream->name(), 0}} |
| 273 | ); |
| 274 | } |
| 275 | if (debugInfoSelection().ethdebug) |
| 276 | creationObject.ethdebug = evmasm::ethdebug::program(creationObject.assembly->name(), 0, *creationObject.assembly, *creationObject.bytecode); |
| 277 | |
| 278 | if (deployedAssembly) |
| 279 | { |
| 280 | deployedObject.bytecode = std::make_shared<evmasm::LinkerObject>(deployedAssembly->assemble()); |
| 281 | deployedObject.assembly = deployedAssembly; |
| 282 | if (debugInfoSelection().ethdebug) |
| 283 | deployedObject.ethdebug = evmasm::ethdebug::program(deployedObject.assembly->name(), 0, *deployedObject.assembly, *deployedObject.bytecode); |
| 284 | solAssert(deployedAssembly->codeSections().size() == 1); |
| 285 | deployedObject.sourceMappings = std::make_unique<std::string>( |
| 286 | evmasm::AssemblyItem::computeSourceMapping( |
| 287 | deployedAssembly->codeSections().front().items, |
| 288 | {{m_charStream->name(), 0}} |
| 289 | ) |
| 290 | ); |
| 291 | } |
| 292 | } |
| 293 | catch (Error const& _error) |
| 294 | { |
| 295 | m_errorReporter.codeGenerationError(_error); |
| 296 | return {MachineAssemblyObject{}, MachineAssemblyObject{}}; |
| 297 | } |
| 298 | catch (UnimplementedFeatureError const& _error) |
| 299 | { |
| 300 | reportUnimplementedFeatureError(_error); |
| 301 | return {MachineAssemblyObject{}, MachineAssemblyObject{}}; |
| 302 | } |
| 303 | |
| 304 | return {std::move(creationObject), std::move(deployedObject)}; |
| 305 | } |
no test coverage detected