User-defined literal suffixes: AST

This commit is contained in:
Kamil Śliwak
2023-04-12 12:07:46 +02:00
parent 9af3439ff7
commit 2986772f3f
10 changed files with 27 additions and 4 deletions
+10 -2
View File
@@ -2156,9 +2156,15 @@ public:
ASTPointer<Expression> _expression,
std::vector<ASTPointer<Expression>> _arguments,
std::vector<ASTPointer<ASTString>> _names,
std::vector<SourceLocation> _nameLocations
std::vector<SourceLocation> _nameLocations,
bool _isSuffixCall = false
):
Expression(_id, _location), m_expression(std::move(_expression)), m_arguments(std::move(_arguments)), m_names(std::move(_names)), m_nameLocations(std::move(_nameLocations))
Expression(_id, _location),
m_expression(std::move(_expression)),
m_arguments(std::move(_arguments)),
m_names(std::move(_names)),
m_nameLocations(std::move(_nameLocations)),
m_isSuffixCall(_isSuffixCall)
{
solAssert(m_nameLocations.size() == m_names.size());
}
@@ -2176,6 +2182,7 @@ public:
/// If this is not a named call, this is empty.
std::vector<ASTPointer<ASTString>> const& names() const { return m_names; }
std::vector<SourceLocation> const& nameLocations() const { return m_nameLocations; }
bool isSuffixCall() const { return m_isSuffixCall; }
FunctionCallAnnotation& annotation() const override;
@@ -2184,6 +2191,7 @@ private:
std::vector<ASTPointer<Expression>> m_arguments;
std::vector<ASTPointer<ASTString>> m_names;
std::vector<SourceLocation> m_nameLocations;
bool m_isSuffixCall;
};
/**
+2 -1
View File
@@ -878,7 +878,8 @@ bool ASTJsonExporter::visit(FunctionCall const& _node)
make_pair("names", std::move(names)),
make_pair("nameLocations", sourceLocationsToJson(_node.nameLocations())),
make_pair("arguments", toJson(_node.arguments())),
make_pair("tryCall", _node.annotation().tryCall)
make_pair("tryCall", _node.annotation().tryCall),
make_pair("isSuffixCall", _node.isSuffixCall())
};
if (_node.annotation().kind.set())
+2 -1
View File
@@ -965,7 +965,8 @@ ASTPointer<FunctionCall> ASTJsonImporter::createFunctionCall(Json::Value const&
names,
sourceLocations ?
*sourceLocations :
vector<SourceLocation>(names.size())
vector<SourceLocation>(names.size()),
memberAsBool(_node, "isSuffixCall")
);
}