mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
User-defined operators: AST
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <libsolidity/ast/ASTJsonImporter.h>
|
||||
#include <libsolidity/ast/UserDefinableOperators.h>
|
||||
|
||||
#include <libyul/AsmJsonImporter.h>
|
||||
#include <libyul/AST.h>
|
||||
@@ -397,15 +398,42 @@ ASTPointer<InheritanceSpecifier> ASTJsonImporter::createInheritanceSpecifier(Jso
|
||||
ASTPointer<UsingForDirective> ASTJsonImporter::createUsingForDirective(Json::Value const& _node)
|
||||
{
|
||||
vector<ASTPointer<IdentifierPath>> functions;
|
||||
vector<optional<Token>> operators;
|
||||
if (_node.isMember("libraryName"))
|
||||
{
|
||||
astAssert(!_node["libraryName"].isArray());
|
||||
astAssert(!_node["libraryName"]["operator"]);
|
||||
functions.emplace_back(createIdentifierPath(_node["libraryName"]));
|
||||
operators.emplace_back(nullopt);
|
||||
}
|
||||
else if (_node.isMember("functionList"))
|
||||
for (Json::Value const& function: _node["functionList"])
|
||||
functions.emplace_back(createIdentifierPath(function["function"]));
|
||||
{
|
||||
if (function.isMember("function"))
|
||||
{
|
||||
astAssert(!function.isMember("operator"));
|
||||
astAssert(!function.isMember("definition"));
|
||||
|
||||
functions.emplace_back(createIdentifierPath(function["function"]));
|
||||
operators.emplace_back(nullopt);
|
||||
}
|
||||
else
|
||||
{
|
||||
astAssert(function.isMember("operator"));
|
||||
astAssert(function.isMember("definition"));
|
||||
|
||||
Token const operatorName = scanSingleToken(function["operator"]);
|
||||
astAssert(util::contains(frontend::userDefinableOperators, operatorName));
|
||||
|
||||
functions.emplace_back(createIdentifierPath(function["definition"]));
|
||||
operators.emplace_back(operatorName);
|
||||
}
|
||||
}
|
||||
|
||||
return createASTNode<UsingForDirective>(
|
||||
_node,
|
||||
std::move(functions),
|
||||
std::move(operators),
|
||||
!_node.isMember("libraryName"),
|
||||
_node["typeName"].isNull() ? nullptr : convertJsonToASTNode<TypeName>(_node["typeName"]),
|
||||
memberAsBool(_node, "global")
|
||||
|
||||
Reference in New Issue
Block a user