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:
+12
-6
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <libsolidity/interface/Exceptions.h>
|
||||
#include <libsolidity/ast/ASTForward.h>
|
||||
#include <libsolidity/ast/ASTEnums.h>
|
||||
#include <libsolidity/parsing/Token.h>
|
||||
|
||||
#include <libdevcore/Common.h>
|
||||
@@ -932,10 +933,15 @@ public:
|
||||
m_gasSet(_gasSet),
|
||||
m_valueSet(_valueSet),
|
||||
m_bound(_bound),
|
||||
m_isConstant(_isConstant),
|
||||
m_isPayable(_isPayable),
|
||||
m_declaration(_declaration)
|
||||
{
|
||||
solAssert(!(_isConstant && _isPayable), "");
|
||||
if (_isPayable)
|
||||
m_stateMutability = StateMutability::Payable;
|
||||
else if (_isConstant)
|
||||
m_stateMutability = StateMutability::View;
|
||||
else
|
||||
m_stateMutability = StateMutability::NonPayable;
|
||||
solAssert(
|
||||
!m_bound || !m_parameterTypes.empty(),
|
||||
"Attempted construction of bound function without self type"
|
||||
@@ -985,6 +991,7 @@ public:
|
||||
/// @returns true if the ABI is used for this call (only meaningful for external calls)
|
||||
bool isBareCall() const;
|
||||
Kind const& kind() const { return m_kind; }
|
||||
StateMutability stateMutability() const { return m_stateMutability; }
|
||||
/// @returns the external signature of this function type given the function name
|
||||
std::string externalSignature() const;
|
||||
/// @returns the external identifier of this function (the hash of the signature).
|
||||
@@ -995,12 +1002,12 @@ public:
|
||||
return *m_declaration;
|
||||
}
|
||||
bool hasDeclaration() const { return !!m_declaration; }
|
||||
bool isConstant() const { return m_isConstant; }
|
||||
bool isConstant() const { return m_stateMutability == StateMutability::View; }
|
||||
/// @returns true if the the result of this function only depends on its arguments
|
||||
/// and it does not modify the state.
|
||||
/// Currently, this will only return true for internal functions like keccak and ecrecover.
|
||||
bool isPure() const;
|
||||
bool isPayable() const { return m_isPayable; }
|
||||
bool isPayable() const { return m_stateMutability == StateMutability::Payable; }
|
||||
/// @return A shared pointer of an ASTString.
|
||||
/// Can contain a nullptr in which case indicates absence of documentation
|
||||
ASTPointer<ASTString> documentation() const;
|
||||
@@ -1033,13 +1040,12 @@ private:
|
||||
std::vector<std::string> m_parameterNames;
|
||||
std::vector<std::string> m_returnParameterNames;
|
||||
Kind const m_kind;
|
||||
StateMutability m_stateMutability = StateMutability::NonPayable;
|
||||
/// true if the function takes an arbitrary number of arguments of arbitrary types
|
||||
bool const m_arbitraryParameters = false;
|
||||
bool const m_gasSet = false; ///< true iff the gas value to be used is on the stack
|
||||
bool const m_valueSet = false; ///< true iff the value to be sent is on the stack
|
||||
bool const m_bound = false; ///< true iff the function is called as arg1.fun(arg2, ..., argn)
|
||||
bool m_isConstant = false;
|
||||
bool m_isPayable = false;
|
||||
Declaration const* m_declaration = nullptr;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user