Merge pull request #13185 from ethereum/functionCall_locations

Add location for parameter names in FunctionCall ASTNode
This commit is contained in:
Mathias L. Baumann
2022-07-04 16:40:45 +02:00
committed by GitHub
14 changed files with 103 additions and 25 deletions
+21 -1
View File
@@ -95,6 +95,20 @@ SourceLocation const ASTJsonImporter::createSourceLocation(Json::Value const& _n
return solidity::langutil::parseSourceLocation(_node["src"].asString(), m_sourceNames);
}
optional<vector<SourceLocation>> ASTJsonImporter::createSourceLocations(Json::Value const& _node) const
{
vector<SourceLocation> locations;
if (_node.isMember("nameLocations") && _node["nameLocations"].isArray())
{
for (auto const& val: _node["nameLocations"])
locations.emplace_back(langutil::parseSourceLocation(val.asString(), m_sourceNames));
return locations;
}
return nullopt;
}
SourceLocation ASTJsonImporter::createNameSourceLocation(Json::Value const& _node)
{
astAssert(member(_node, "nameLocation").isString(), "'nameLocation' must be a string");
@@ -893,11 +907,17 @@ ASTPointer<FunctionCall> ASTJsonImporter::createFunctionCall(Json::Value const&
astAssert(name.isString(), "Expected 'names' members to be strings!");
names.push_back(make_shared<ASTString>(name.asString()));
}
optional<vector<SourceLocation>> sourceLocations = createSourceLocations(_node);
return createASTNode<FunctionCall>(
_node,
convertJsonToASTNode<Expression>(member(_node, "expression")),
arguments,
names
names,
sourceLocations ?
*sourceLocations :
vector<SourceLocation>(names.size())
);
}