mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow marking free functions as suffixes
This commit is contained in:
@@ -951,6 +951,7 @@ public:
|
||||
bool _free,
|
||||
Token _kind,
|
||||
bool _isVirtual,
|
||||
bool _usableAsSuffix,
|
||||
ASTPointer<OverrideSpecifier> const& _overrides,
|
||||
ASTPointer<StructuredDocumentation> const& _documentation,
|
||||
ASTPointer<ParameterList> const& _parameters,
|
||||
@@ -964,11 +965,14 @@ public:
|
||||
m_stateMutability(_stateMutability),
|
||||
m_free(_free),
|
||||
m_kind(_kind),
|
||||
m_usableAsSuffix(_usableAsSuffix),
|
||||
m_functionModifiers(std::move(_modifiers)),
|
||||
m_body(_body)
|
||||
{
|
||||
solAssert(_kind == Token::Constructor || _kind == Token::Function || _kind == Token::Fallback || _kind == Token::Receive, "");
|
||||
solAssert(isOrdinary() == !name().empty(), "");
|
||||
if (_usableAsSuffix)
|
||||
solAssert(_free);
|
||||
}
|
||||
|
||||
void accept(ASTVisitor& _visitor) override;
|
||||
@@ -981,6 +985,7 @@ public:
|
||||
bool isFallback() const { return m_kind == Token::Fallback; }
|
||||
bool isReceive() const { return m_kind == Token::Receive; }
|
||||
bool isFree() const { return m_free; }
|
||||
bool usableAsSuffix() const { return m_usableAsSuffix; }
|
||||
Token kind() const { return m_kind; }
|
||||
bool isPayable() const { return m_stateMutability == StateMutability::Payable; }
|
||||
std::vector<ASTPointer<ModifierInvocation>> const& modifiers() const { return m_functionModifiers; }
|
||||
@@ -1027,9 +1032,10 @@ public:
|
||||
) const override;
|
||||
|
||||
private:
|
||||
StateMutability m_stateMutability;
|
||||
bool m_free;
|
||||
Token const m_kind;
|
||||
StateMutability m_stateMutability{};
|
||||
bool m_free{};
|
||||
Token const m_kind{};
|
||||
bool m_usableAsSuffix{};
|
||||
std::vector<ASTPointer<ModifierInvocation>> m_functionModifiers;
|
||||
ASTPointer<Block> m_body;
|
||||
};
|
||||
|
||||
@@ -458,6 +458,7 @@ bool ASTJsonExporter::visit(FunctionDefinition const& _node)
|
||||
make_pair("kind", _node.isFree() ? "freeFunction" : TokenTraits::toString(_node.kind())),
|
||||
make_pair("stateMutability", stateMutabilityToString(_node.stateMutability())),
|
||||
make_pair("virtual", _node.markedVirtual()),
|
||||
make_pair("suffix", _node.usableAsSuffix()),
|
||||
make_pair("overrides", _node.overrides() ? toJson(*_node.overrides()) : Json::nullValue),
|
||||
make_pair("parameters", toJson(_node.parameterList())),
|
||||
make_pair("returnParameters", toJson(*_node.returnParameterList())),
|
||||
|
||||
@@ -557,6 +557,7 @@ ASTPointer<FunctionDefinition> ASTJsonImporter::createFunctionDefinition(Json::V
|
||||
freeFunction,
|
||||
kind,
|
||||
memberAsBool(_node, "virtual"),
|
||||
memberAsBool(_node, "suffix"),
|
||||
_node["overrides"].isNull() ? nullptr : createOverrideSpecifier(member(_node, "overrides")),
|
||||
_node["documentation"].isNull() ? nullptr : createDocumentation(member(_node, "documentation")),
|
||||
createParameterList(member(_node, "parameters")),
|
||||
|
||||
Reference in New Issue
Block a user