AST import and export for revert statement.

This commit is contained in:
chriseth 2021-03-16 19:17:57 +01:00
parent fb67051467
commit b552e5aeeb
4 changed files with 21 additions and 0 deletions

View File

@ -675,6 +675,14 @@ bool ASTJsonConverter::visit(EmitStatement const& _node)
return false; return false;
} }
bool ASTJsonConverter::visit(RevertStatement const& _node)
{
setJsonNode(_node, "RevertStatement", {
make_pair("errorCall", toJson(_node.errorCall()))
});
return false;
}
bool ASTJsonConverter::visit(VariableDeclarationStatement const& _node) bool ASTJsonConverter::visit(VariableDeclarationStatement const& _node)
{ {
Json::Value varDecs(Json::arrayValue); Json::Value varDecs(Json::arrayValue);

View File

@ -107,6 +107,7 @@ public:
bool visit(Return const& _node) override; bool visit(Return const& _node) override;
bool visit(Throw const& _node) override; bool visit(Throw const& _node) override;
bool visit(EmitStatement const& _node) override; bool visit(EmitStatement const& _node) override;
bool visit(RevertStatement const& _node) override;
bool visit(VariableDeclarationStatement const& _node) override; bool visit(VariableDeclarationStatement const& _node) override;
bool visit(ExpressionStatement const& _node) override; bool visit(ExpressionStatement const& _node) override;
bool visit(Conditional const& _node) override; bool visit(Conditional const& _node) override;

View File

@ -191,6 +191,8 @@ ASTPointer<ASTNode> ASTJsonImporter::convertJsonToASTNode(Json::Value const& _js
return createReturn(_json); return createReturn(_json);
if (nodeType == "EmitStatement") if (nodeType == "EmitStatement")
return createEmitStatement(_json); return createEmitStatement(_json);
if (nodeType == "RevertStatement")
return createRevertStatement(_json);
if (nodeType == "Throw") if (nodeType == "Throw")
return createThrow(_json); return createThrow(_json);
if (nodeType == "VariableDeclarationStatement") if (nodeType == "VariableDeclarationStatement")
@ -747,6 +749,15 @@ ASTPointer<EmitStatement> ASTJsonImporter::createEmitStatement(Json::Value const
); );
} }
ASTPointer<RevertStatement> ASTJsonImporter::createRevertStatement(Json::Value const& _node)
{
return createASTNode<RevertStatement>(
_node,
nullOrASTString(_node, "documentation"),
createFunctionCall(member(_node, "errorCall"))
);
}
ASTPointer<VariableDeclarationStatement> ASTJsonImporter::createVariableDeclarationStatement(Json::Value const& _node) ASTPointer<VariableDeclarationStatement> ASTJsonImporter::createVariableDeclarationStatement(Json::Value const& _node)
{ {
std::vector<ASTPointer<VariableDeclaration>> variables; std::vector<ASTPointer<VariableDeclaration>> variables;

View File

@ -107,6 +107,7 @@ private:
ASTPointer<Return> createReturn(Json::Value const& _node); ASTPointer<Return> createReturn(Json::Value const& _node);
ASTPointer<Throw> createThrow(Json::Value const& _node); ASTPointer<Throw> createThrow(Json::Value const& _node);
ASTPointer<EmitStatement> createEmitStatement(Json::Value const& _node); ASTPointer<EmitStatement> createEmitStatement(Json::Value const& _node);
ASTPointer<RevertStatement> createRevertStatement(Json::Value const& _node);
ASTPointer<VariableDeclarationStatement> createVariableDeclarationStatement(Json::Value const& _node); ASTPointer<VariableDeclarationStatement> createVariableDeclarationStatement(Json::Value const& _node);
ASTPointer<ExpressionStatement> createExpressionStatement(Json::Value const& _node); ASTPointer<ExpressionStatement> createExpressionStatement(Json::Value const& _node);
ASTPointer<Conditional> createConditional(Json::Value const& _node); ASTPointer<Conditional> createConditional(Json::Value const& _node);