mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add location for member in MemberAccess ASTNode
This commit is contained in:
parent
4d8a14b653
commit
ee710eadd4
@ -2190,19 +2190,27 @@ public:
|
|||||||
int64_t _id,
|
int64_t _id,
|
||||||
SourceLocation const& _location,
|
SourceLocation const& _location,
|
||||||
ASTPointer<Expression> _expression,
|
ASTPointer<Expression> _expression,
|
||||||
ASTPointer<ASTString> _memberName
|
ASTPointer<ASTString> _memberName,
|
||||||
|
SourceLocation _memberLocation
|
||||||
):
|
):
|
||||||
Expression(_id, _location), m_expression(std::move(_expression)), m_memberName(std::move(_memberName)) {}
|
Expression(_id, _location),
|
||||||
|
m_expression(std::move(_expression)),
|
||||||
|
m_memberName(std::move(_memberName)),
|
||||||
|
m_memberLocation(std::move(_memberLocation))
|
||||||
|
{}
|
||||||
|
|
||||||
void accept(ASTVisitor& _visitor) override;
|
void accept(ASTVisitor& _visitor) override;
|
||||||
void accept(ASTConstVisitor& _visitor) const override;
|
void accept(ASTConstVisitor& _visitor) const override;
|
||||||
Expression const& expression() const { return *m_expression; }
|
Expression const& expression() const { return *m_expression; }
|
||||||
ASTString const& memberName() const { return *m_memberName; }
|
ASTString const& memberName() const { return *m_memberName; }
|
||||||
|
SourceLocation const& memberLocation() const { return m_memberLocation; }
|
||||||
|
|
||||||
MemberAccessAnnotation& annotation() const override;
|
MemberAccessAnnotation& annotation() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ASTPointer<Expression> m_expression;
|
ASTPointer<Expression> m_expression;
|
||||||
ASTPointer<ASTString> m_memberName;
|
ASTPointer<ASTString> m_memberName;
|
||||||
|
SourceLocation m_memberLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -889,6 +889,7 @@ bool ASTJsonExporter::visit(MemberAccess const& _node)
|
|||||||
{
|
{
|
||||||
std::vector<pair<string, Json::Value>> attributes = {
|
std::vector<pair<string, Json::Value>> attributes = {
|
||||||
make_pair("memberName", _node.memberName()),
|
make_pair("memberName", _node.memberName()),
|
||||||
|
make_pair("memberLocation", Json::Value(sourceLocationToString(_node.memberLocation()))),
|
||||||
make_pair("expression", toJson(_node.expression())),
|
make_pair("expression", toJson(_node.expression())),
|
||||||
make_pair("referencedDeclaration", idOrNull(_node.annotation().referencedDeclaration)),
|
make_pair("referencedDeclaration", idOrNull(_node.annotation().referencedDeclaration)),
|
||||||
};
|
};
|
||||||
|
@ -931,10 +931,15 @@ ASTPointer<NewExpression> ASTJsonImporter::createNewExpression(Json::Value const
|
|||||||
|
|
||||||
ASTPointer<MemberAccess> ASTJsonImporter::createMemberAccess(Json::Value const& _node)
|
ASTPointer<MemberAccess> ASTJsonImporter::createMemberAccess(Json::Value const& _node)
|
||||||
{
|
{
|
||||||
|
SourceLocation memberLocation;
|
||||||
|
if (member(_node, "memberLocation").isString())
|
||||||
|
memberLocation = solidity::langutil::parseSourceLocation(_node["memberLocation"].asString(), m_sourceNames);
|
||||||
|
|
||||||
return createASTNode<MemberAccess>(
|
return createASTNode<MemberAccess>(
|
||||||
_node,
|
_node,
|
||||||
convertJsonToASTNode<Expression>(member(_node, "expression")),
|
convertJsonToASTNode<Expression>(member(_node, "expression")),
|
||||||
memberAsASTString(_node, "memberName")
|
memberAsASTString(_node, "memberName"),
|
||||||
|
std::move(memberLocation)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1897,7 +1897,9 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression(
|
|||||||
{
|
{
|
||||||
advance();
|
advance();
|
||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
expression = nodeFactory.createNode<MemberAccess>(expression, expectIdentifierTokenOrAddress());
|
SourceLocation memberLocation = currentLocation();
|
||||||
|
ASTPointer<ASTString> memberName = expectIdentifierTokenOrAddress();
|
||||||
|
expression = nodeFactory.createNode<MemberAccess>(expression, std::move(memberName), std::move(memberLocation));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Token::LParen:
|
case Token::LParen:
|
||||||
@ -2335,7 +2337,8 @@ ASTPointer<Expression> Parser::expressionFromIndexAccessStructure(
|
|||||||
Identifier const& identifier = dynamic_cast<Identifier const&>(*_iap.path[i]);
|
Identifier const& identifier = dynamic_cast<Identifier const&>(*_iap.path[i]);
|
||||||
expression = nodeFactory.createNode<MemberAccess>(
|
expression = nodeFactory.createNode<MemberAccess>(
|
||||||
expression,
|
expression,
|
||||||
make_shared<ASTString>(identifier.name())
|
make_shared<ASTString>(identifier.name()),
|
||||||
|
identifier.location()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (auto const& index: _iap.indices)
|
for (auto const& index: _iap.indices)
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
"isLValue": false,
|
"isLValue": false,
|
||||||
"isPure": true,
|
"isPure": true,
|
||||||
"lValueRequested": false,
|
"lValueRequested": false,
|
||||||
|
"memberLocation": "57:1:1",
|
||||||
"memberName": "X",
|
"memberName": "X",
|
||||||
"nodeType": "MemberAccess",
|
"nodeType": "MemberAccess",
|
||||||
"referencedDeclaration": 1,
|
"referencedDeclaration": 1,
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
"typeDescriptions": {}
|
"typeDescriptions": {}
|
||||||
},
|
},
|
||||||
"id": 10,
|
"id": 10,
|
||||||
|
"memberLocation": "57:1:1",
|
||||||
"memberName": "X",
|
"memberName": "X",
|
||||||
"nodeType": "MemberAccess",
|
"nodeType": "MemberAccess",
|
||||||
"src": "55:3:1",
|
"src": "55:3:1",
|
||||||
|
Loading…
Reference in New Issue
Block a user