Implement new with CREATE2 and function call options.

This commit is contained in:
Mathias Baumann
2020-01-23 21:20:01 +01:00
committed by chriseth
parent 679f729f2f
commit a3f23d3158
28 changed files with 528 additions and 38 deletions
+14 -6
View File
@@ -2741,6 +2741,8 @@ string FunctionType::richIdentifier() const
id += "gas";
if (m_valueSet)
id += "value";
if (m_saltSet)
id += "salt";
if (bound())
id += "bound_to" + identifierList(selfType());
return id;
@@ -2918,6 +2920,8 @@ unsigned FunctionType::sizeOnStack() const
size++;
if (m_valueSet)
size++;
if (m_saltSet)
size++;
if (bound())
size += m_parameterTypes.front()->sizeOnStack();
return size;
@@ -3001,7 +3005,7 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const* _sco
"value",
TypeProvider::function(
parseElementaryTypeVector({"uint"}),
TypePointers{copyAndSetGasOrValue(false, true)},
TypePointers{copyAndSetCallOptions(false, true, false)},
strings(1, ""),
strings(1, ""),
Kind::SetValue,
@@ -3009,7 +3013,8 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const* _sco
StateMutability::Pure,
nullptr,
m_gasSet,
m_valueSet
m_valueSet,
m_saltSet
)
);
}
@@ -3018,7 +3023,7 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const* _sco
"gas",
TypeProvider::function(
parseElementaryTypeVector({"uint"}),
TypePointers{copyAndSetGasOrValue(true, false)},
TypePointers{copyAndSetCallOptions(true, false, false)},
strings(1, ""),
strings(1, ""),
Kind::SetGas,
@@ -3026,7 +3031,8 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const* _sco
StateMutability::Pure,
nullptr,
m_gasSet,
m_valueSet
m_valueSet,
m_saltSet
)
);
return members;
@@ -3149,7 +3155,7 @@ bool FunctionType::equalExcludingStateMutability(FunctionType const& _other) con
return false;
//@todo this is ugly, but cannot be prevented right now
if (m_gasSet != _other.m_gasSet || m_valueSet != _other.m_valueSet)
if (m_gasSet != _other.m_gasSet || m_valueSet != _other.m_valueSet || m_saltSet != _other.m_saltSet)
return false;
if (bound() != _other.bound())
@@ -3250,7 +3256,7 @@ TypePointers FunctionType::parseElementaryTypeVector(strings const& _types)
return pointers;
}
TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) const
TypePointer FunctionType::copyAndSetCallOptions(bool _setGas, bool _setValue, bool _setSalt) const
{
solAssert(m_kind != Kind::Declaration, "");
return TypeProvider::function(
@@ -3264,6 +3270,7 @@ TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) con
m_declaration,
m_gasSet || _setGas,
m_valueSet || _setValue,
m_saltSet || _setSalt,
m_bound
);
}
@@ -3304,6 +3311,7 @@ FunctionTypePointer FunctionType::asCallableFunction(bool _inLibrary, bool _boun
m_declaration,
m_gasSet,
m_valueSet,
m_saltSet,
_bound
);
}