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

Method assembleYul

libsolidity/interface/CompilerStack.cpp:1492–1562  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1490}
1491
1492void CompilerStack::assembleYul(
1493 ContractDefinition const& _contract,
1494 std::shared_ptr<evmasm::Assembly> _assembly,
1495 std::shared_ptr<evmasm::Assembly> _runtimeAssembly
1496)
1497{
1498 solAssert(m_stackState >= AnalysisSuccessful, "");
1499
1500 Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
1501
1502 compiledContract.evmAssembly = _assembly;
1503 solAssert(compiledContract.evmAssembly, "");
1504 try
1505 {
1506 // Assemble deployment (incl. runtime) object.
1507 compiledContract.object = compiledContract.evmAssembly->assemble();
1508 }
1509 catch (evmasm::AssemblyException const& error)
1510 {
1511 solAssert(false, "Assembly exception for bytecode: "s + error.what());
1512 }
1513 solAssert(compiledContract.object.immutableReferences.empty(), "Leftover immutables.");
1514
1515 compiledContract.evmRuntimeAssembly = _runtimeAssembly;
1516 solAssert(compiledContract.evmRuntimeAssembly, "");
1517 try
1518 {
1519 // Assemble runtime object.
1520 compiledContract.runtimeObject = compiledContract.evmRuntimeAssembly->assemble();
1521 }
1522 catch (evmasm::AssemblyException const& error)
1523 {
1524 solAssert(false, "Assembly exception for deployed bytecode"s + error.what());
1525 }
1526
1527 // Throw a warning if EIP-170 limits are exceeded:
1528 // If contract creation returns data with length greater than 0x6000 (2^14 + 2^13) bytes,
1529 // contract creation fails with an out of gas error.
1530 if (
1531 m_evmVersion >= langutil::EVMVersion::spuriousDragon() &&
1532 compiledContract.runtimeObject.bytecode.size() > 0x6000
1533 )
1534 m_errorReporter.warning(
1535 5574_error,
1536 _contract.location(),
1537 "Contract code size is "s +
1538 std::to_string(compiledContract.runtimeObject.bytecode.size()) +
1539 " bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). "
1540 "This contract may not be deployable on Mainnet. "
1541 "Consider enabling the optimizer (with a low \"runs\" value!), "
1542 "turning off revert strings, or using libraries."
1543 );
1544
1545 // Throw a warning if EIP-3860 limits are exceeded:
1546 // If initcode is larger than 0xC000 bytes (twice the runtime code limit),
1547 // then contract creation fails with an out of gas error.
1548 if (
1549 m_evmVersion >= langutil::EVMVersion::shanghai() &&

Callers

nothing calls this directly

Calls 9

atMethod · 0.80
fullyQualifiedNameMethod · 0.80
whatMethod · 0.80
to_stringFunction · 0.50
assembleMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
warningMethod · 0.45
locationMethod · 0.45

Tested by

no test coverage detected