Emit immutable references for pure yul code

This commit is contained in:
Marenz
2022-02-07 12:32:54 +01:00
committed by chriseth
parent 6b8654384c
commit b9fe628b70
6 changed files with 88 additions and 12 deletions
+11 -11
View File
@@ -1461,36 +1461,36 @@ Json::Value StandardCompiler::compileYul(InputsAndSettings _inputsAndSettings)
stack.optimize();
MachineAssemblyObject object;
MachineAssemblyObject runtimeObject;
tie(object, runtimeObject) = stack.assembleWithDeployed();
MachineAssemblyObject deployedObject;
tie(object, deployedObject) = stack.assembleWithDeployed();
if (object.bytecode)
object.bytecode->link(_inputsAndSettings.libraries);
if (runtimeObject.bytecode)
runtimeObject.bytecode->link(_inputsAndSettings.libraries);
if (deployedObject.bytecode)
deployedObject.bytecode->link(_inputsAndSettings.libraries);
for (string const& objectKind: vector<string>{"bytecode", "deployedBytecode"})
for (auto&& [kind, isDeployed]: {make_pair("bytecode"s, false), make_pair("deployedBytecode"s, true)})
if (isArtifactRequested(
_inputsAndSettings.outputSelection,
sourceName,
contractName,
evmObjectComponents(objectKind),
evmObjectComponents(kind),
wildcardMatchesExperimental
))
{
MachineAssemblyObject const& o = objectKind == "bytecode" ? object : runtimeObject;
MachineAssemblyObject const& o = isDeployed ? deployedObject : object;
if (o.bytecode)
output["contracts"][sourceName][contractName]["evm"][objectKind] =
output["contracts"][sourceName][contractName]["evm"][kind] =
collectEVMObject(
*o.bytecode,
o.sourceMappings.get(),
Json::arrayValue,
false,
[&](string const& _element) { return isArtifactRequested(
isDeployed,
[&, kind = kind](string const& _element) { return isArtifactRequested(
_inputsAndSettings.outputSelection,
sourceName,
contractName,
"evm." + objectKind + "." + _element,
"evm." + kind + "." + _element,
wildcardMatchesExperimental
); }
);