Legacy codegeneration for immutable state variables.

This commit is contained in:
Daniel Kirchner
2020-03-24 16:45:25 +01:00
committed by chriseth
parent 83cbfbb7bf
commit 04d8ad2ae1
22 changed files with 471 additions and 17 deletions
+23
View File
@@ -80,6 +80,13 @@ unsigned AssemblyItem::bytesRequired(unsigned _addressLength) const
case PushLibraryAddress:
case PushDeployTimeAddress:
return 1 + 20;
case PushImmutable:
return 1 + 32;
case AssignImmutable:
if (m_immutableOccurrences)
return 1 + (3 + 32) * *m_immutableOccurrences;
else
return 1 + (3 + 32) * 1024; // 1024 occurrences are beyond the maximum code size anyways.
default:
break;
}
@@ -90,6 +97,8 @@ int AssemblyItem::arguments() const
{
if (type() == Operation)
return instructionInfo(instruction()).args;
else if (type() == AssignImmutable)
return 1;
else
return 0;
}
@@ -108,6 +117,7 @@ int AssemblyItem::returnValues() const
case PushSubSize:
case PushProgramSize:
case PushLibraryAddress:
case PushImmutable:
case PushDeployTimeAddress:
return 1;
case Tag:
@@ -135,6 +145,7 @@ bool AssemblyItem::canBeFunctional() const
case PushProgramSize:
case PushLibraryAddress:
case PushDeployTimeAddress:
case PushImmutable:
return true;
case Tag:
return false;
@@ -210,6 +221,12 @@ string AssemblyItem::toAssemblyText() const
case PushDeployTimeAddress:
text = string("deployTimeAddress()");
break;
case PushImmutable:
text = string("immutable(\"") + toHex(util::toCompactBigEndian(data(), 1), util::HexPrefix::Add) + "\")";
break;
case AssignImmutable:
text = string("assignImmutable(\"") + toHex(util::toCompactBigEndian(data(), 1), util::HexPrefix::Add) + "\")";
break;
case UndefinedItem:
assertThrow(false, AssemblyException, "Invalid assembly item.");
break;
@@ -275,6 +292,12 @@ ostream& solidity::evmasm::operator<<(ostream& _out, AssemblyItem const& _item)
case PushDeployTimeAddress:
_out << " PushDeployTimeAddress";
break;
case PushImmutable:
_out << " PushImmutable";
break;
case AssignImmutable:
_out << " AssignImmutable";
break;
case UndefinedItem:
_out << " ???";
break;