Skip to content

Commit

Permalink
Implements AST JSON import for function call options.
Browse files Browse the repository at this point in the history
  • Loading branch information
erak authored and chriseth committed Jan 23, 2020
1 parent 8e7aef6 commit 893fb4d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions libsolidity/ast/ASTJsonImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ ASTPointer<ASTNode> ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js
return createBinaryOperation(_json);
if (nodeType == "FunctionCall")
return createFunctionCall(_json);
if (nodeType == "FunctionCallOptions")
return createFunctionCallOptions(_json);
if (nodeType == "NewExpression")
return createNewExpression(_json);
if (nodeType == "MemberAccess")
Expand Down Expand Up @@ -752,6 +754,26 @@ ASTPointer<FunctionCall> ASTJsonImporter::createFunctionCall(Json::Value const&
);
}

ASTPointer<FunctionCallOptions> ASTJsonImporter::createFunctionCallOptions(Json::Value const& _node)
{
std::vector<ASTPointer<Expression>> options;
for (auto& option: member(_node, "options"))
options.push_back(convertJsonToASTNode<Expression>(option));
std::vector<ASTPointer<ASTString>> names;
for (auto& name: member(_node, "names"))
{
astAssert(name.isString(), "Expected 'names' members to be strings!");
names.push_back(make_shared<ASTString>(name.asString()));
}

return createASTNode<FunctionCallOptions>(
_node,
convertJsonToASTNode<Expression>(member(_node, "expression")),
options,
names
);
}

ASTPointer<NewExpression> ASTJsonImporter::createNewExpression(Json::Value const& _node)
{
return createASTNode<NewExpression>(
Expand Down
1 change: 1 addition & 0 deletions libsolidity/ast/ASTJsonImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class ASTJsonImporter
ASTPointer<UnaryOperation> createUnaryOperation(Json::Value const& _node);
ASTPointer<BinaryOperation> createBinaryOperation(Json::Value const& _node);
ASTPointer<FunctionCall> createFunctionCall(Json::Value const& _node);
ASTPointer<FunctionCallOptions> createFunctionCallOptions(Json::Value const& _node);
ASTPointer<NewExpression> createNewExpression(Json::Value const& _node);
ASTPointer<MemberAccess> createMemberAccess(Json::Value const& _node);
ASTPointer<IndexAccess> createIndexAccess(Json::Value const& _node);
Expand Down

0 comments on commit 893fb4d

Please sign in to comment.