mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add ast json converter for ModifierDefinition
This commit is contained in:
parent
95832da16e
commit
a5d15e6895
@ -175,6 +175,12 @@ bool ASTJsonConverter::visit(VariableDeclaration const& _node)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ASTJsonConverter::visit(ModifierDefinition const& _node)
|
||||||
|
{
|
||||||
|
addJsonNode(_node, "ModifierDefinition", { make_pair("name", _node.name()) }, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ASTJsonConverter::visit(TypeName const&)
|
bool ASTJsonConverter::visit(TypeName const&)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -409,6 +415,11 @@ void ASTJsonConverter::endVisit(VariableDeclaration const&)
|
|||||||
goUp();
|
goUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ASTJsonConverter::endVisit(ModifierDefinition const&)
|
||||||
|
{
|
||||||
|
goUp();
|
||||||
|
}
|
||||||
|
|
||||||
void ASTJsonConverter::endVisit(TypeName const&)
|
void ASTJsonConverter::endVisit(TypeName const&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
bool visit(ParameterList const& _node) override;
|
bool visit(ParameterList const& _node) override;
|
||||||
bool visit(FunctionDefinition const& _node) override;
|
bool visit(FunctionDefinition const& _node) override;
|
||||||
bool visit(VariableDeclaration const& _node) override;
|
bool visit(VariableDeclaration const& _node) override;
|
||||||
|
bool visit(ModifierDefinition const& _node) override;
|
||||||
bool visit(TypeName const& _node) override;
|
bool visit(TypeName const& _node) override;
|
||||||
bool visit(ElementaryTypeName const& _node) override;
|
bool visit(ElementaryTypeName const& _node) override;
|
||||||
bool visit(UserDefinedTypeName const& _node) override;
|
bool visit(UserDefinedTypeName const& _node) override;
|
||||||
@ -99,6 +100,7 @@ public:
|
|||||||
void endVisit(ParameterList const&) override;
|
void endVisit(ParameterList const&) override;
|
||||||
void endVisit(FunctionDefinition const&) override;
|
void endVisit(FunctionDefinition const&) override;
|
||||||
void endVisit(VariableDeclaration const&) override;
|
void endVisit(VariableDeclaration const&) override;
|
||||||
|
void endVisit(ModifierDefinition const&) override;
|
||||||
void endVisit(TypeName const&) override;
|
void endVisit(TypeName const&) override;
|
||||||
void endVisit(ElementaryTypeName const&) override;
|
void endVisit(ElementaryTypeName const&) override;
|
||||||
void endVisit(UserDefinedTypeName const&) override;
|
void endVisit(UserDefinedTypeName const&) override;
|
||||||
|
@ -125,6 +125,20 @@ BOOST_AUTO_TEST_CASE(enum_value)
|
|||||||
BOOST_CHECK_EQUAL(enumDefinition["children"][1]["src"], "25:1:1");
|
BOOST_CHECK_EQUAL(enumDefinition["children"][1]["src"], "25:1:1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(modifier_definition)
|
||||||
|
{
|
||||||
|
CompilerStack c;
|
||||||
|
c.addSource("a", "contract C { modifier M(uint i) { _ } function F() M(1) {} }");
|
||||||
|
c.parse();
|
||||||
|
map<string, unsigned> sourceIndices;
|
||||||
|
sourceIndices["a"] = 1;
|
||||||
|
Json::Value astJson = ASTJsonConverter(c.ast("a"), sourceIndices).json();
|
||||||
|
Json::Value modifier = astJson["children"][0]["children"][0];
|
||||||
|
BOOST_CHECK_EQUAL(modifier["name"], "ModifierDefinition");
|
||||||
|
BOOST_CHECK_EQUAL(modifier["attributes"]["name"], "M");
|
||||||
|
BOOST_CHECK_EQUAL(modifier["src"], "13:24:1");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user