mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replace constant/payable with StateMutability in AST
This commit is contained in:
+18
-20
@@ -2000,8 +2000,7 @@ TypePointer TupleType::closestTemporaryType(TypePointer const& _targetType) cons
|
||||
|
||||
FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal):
|
||||
m_kind(_isInternal ? Kind::Internal : Kind::External),
|
||||
m_isConstant(_function.isDeclaredConst()),
|
||||
m_isPayable(_isInternal ? false : _function.isPayable()),
|
||||
m_stateMutability(_function.stateMutability()),
|
||||
m_declaration(&_function)
|
||||
{
|
||||
TypePointers params;
|
||||
@@ -2009,6 +2008,9 @@ FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal
|
||||
TypePointers retParams;
|
||||
vector<string> retParamNames;
|
||||
|
||||
if (_isInternal && m_stateMutability == StateMutability::Payable)
|
||||
m_stateMutability = StateMutability::NonPayable;
|
||||
|
||||
params.reserve(_function.parameters().size());
|
||||
paramNames.reserve(_function.parameters().size());
|
||||
for (ASTPointer<VariableDeclaration> const& var: _function.parameters())
|
||||
@@ -2030,7 +2032,7 @@ FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal
|
||||
}
|
||||
|
||||
FunctionType::FunctionType(VariableDeclaration const& _varDecl):
|
||||
m_kind(Kind::External), m_isConstant(true), m_declaration(&_varDecl)
|
||||
m_kind(Kind::External), m_stateMutability(StateMutability::View), m_declaration(&_varDecl)
|
||||
{
|
||||
TypePointers paramTypes;
|
||||
vector<string> paramNames;
|
||||
@@ -2090,7 +2092,7 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl):
|
||||
}
|
||||
|
||||
FunctionType::FunctionType(EventDefinition const& _event):
|
||||
m_kind(Kind::Event), m_isConstant(true), m_declaration(&_event)
|
||||
m_kind(Kind::Event), m_stateMutability(StateMutability::View), m_declaration(&_event)
|
||||
{
|
||||
TypePointers params;
|
||||
vector<string> paramNames;
|
||||
@@ -2107,14 +2109,10 @@ FunctionType::FunctionType(EventDefinition const& _event):
|
||||
|
||||
FunctionType::FunctionType(FunctionTypeName const& _typeName):
|
||||
m_kind(_typeName.visibility() == VariableDeclaration::Visibility::External ? Kind::External : Kind::Internal),
|
||||
m_isConstant(_typeName.isDeclaredConst()),
|
||||
m_isPayable(_typeName.isPayable())
|
||||
m_stateMutability(_typeName.stateMutability())
|
||||
{
|
||||
if (_typeName.isPayable())
|
||||
{
|
||||
solAssert(m_kind == Kind::External, "Internal payable function type used.");
|
||||
solAssert(!m_isConstant, "Payable constant function");
|
||||
}
|
||||
for (auto const& t: _typeName.parameterTypes())
|
||||
{
|
||||
solAssert(t->annotation().type, "Type not set for parameter.");
|
||||
@@ -2241,8 +2239,8 @@ bool FunctionType::operator==(Type const& _other) const
|
||||
FunctionType const& other = dynamic_cast<FunctionType const&>(_other);
|
||||
if (
|
||||
m_kind != other.m_kind ||
|
||||
m_isConstant != other.isConstant() ||
|
||||
m_isPayable != other.isPayable() ||
|
||||
isConstant() != other.isConstant() ||
|
||||
isPayable() != other.isPayable() ||
|
||||
m_parameterTypes.size() != other.m_parameterTypes.size() ||
|
||||
m_returnParameterTypes.size() != other.m_returnParameterTypes.size()
|
||||
)
|
||||
@@ -2304,9 +2302,9 @@ string FunctionType::toString(bool _short) const
|
||||
for (auto it = m_parameterTypes.begin(); it != m_parameterTypes.end(); ++it)
|
||||
name += (*it)->toString(_short) + (it + 1 == m_parameterTypes.end() ? "" : ",");
|
||||
name += ")";
|
||||
if (m_isConstant)
|
||||
if (isConstant())
|
||||
name += " constant";
|
||||
if (m_isPayable)
|
||||
if (isPayable())
|
||||
name += " payable";
|
||||
if (m_kind == Kind::External)
|
||||
name += " external";
|
||||
@@ -2420,8 +2418,8 @@ FunctionTypePointer FunctionType::interfaceFunctionType() const
|
||||
m_kind,
|
||||
m_arbitraryParameters,
|
||||
m_declaration,
|
||||
m_isConstant,
|
||||
m_isPayable
|
||||
isConstant(),
|
||||
isPayable()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2438,7 +2436,7 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
|
||||
MemberList::MemberMap members;
|
||||
if (m_kind != Kind::BareDelegateCall && m_kind != Kind::DelegateCall)
|
||||
{
|
||||
if (m_isPayable)
|
||||
if (isPayable())
|
||||
members.push_back(MemberList::Member(
|
||||
"value",
|
||||
make_shared<FunctionType>(
|
||||
@@ -2604,8 +2602,8 @@ TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) con
|
||||
m_kind,
|
||||
m_arbitraryParameters,
|
||||
m_declaration,
|
||||
m_isConstant,
|
||||
m_isPayable,
|
||||
isConstant(),
|
||||
isPayable(),
|
||||
m_gasSet || _setGas,
|
||||
m_valueSet || _setValue,
|
||||
m_bound
|
||||
@@ -2654,8 +2652,8 @@ FunctionTypePointer FunctionType::asMemberFunction(bool _inLibrary, bool _bound)
|
||||
kind,
|
||||
m_arbitraryParameters,
|
||||
m_declaration,
|
||||
m_isConstant,
|
||||
m_isPayable,
|
||||
isConstant(),
|
||||
isPayable(),
|
||||
m_gasSet,
|
||||
m_valueSet,
|
||||
_bound
|
||||
|
||||
Reference in New Issue
Block a user