diff options
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/AST.h | 21 | ||||
-rw-r--r-- | libsolidity/ast/ASTForward.h | 1 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.cpp | 10 | ||||
-rw-r--r-- | libsolidity/ast/ASTJsonConverter.h | 1 | ||||
-rw-r--r-- | libsolidity/ast/ASTPrinter.cpp | 12 | ||||
-rw-r--r-- | libsolidity/ast/ASTPrinter.h | 2 | ||||
-rw-r--r-- | libsolidity/ast/ASTVisitor.h | 4 | ||||
-rw-r--r-- | libsolidity/ast/AST_accept.h | 14 |
8 files changed, 64 insertions, 1 deletions
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index feffde64..c0d55aec 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -1197,6 +1197,27 @@ public: }; /** + * The emit statement is used to emit events: emit EventName(arg1, ..., argn) + */ +class EmitStatement: public Statement +{ +public: + explicit EmitStatement( + SourceLocation const& _location, + ASTPointer<ASTString> const& _docString, + ASTPointer<FunctionCall> const& _functionCall + ): + Statement(_location, _docString), m_eventCall(_functionCall) {} + virtual void accept(ASTVisitor& _visitor) override; + virtual void accept(ASTConstVisitor& _visitor) const override; + + FunctionCall const& eventCall() const { return *m_eventCall; } + +private: + ASTPointer<FunctionCall> m_eventCall; +}; + +/** * Definition of a variable as a statement inside a function. It requires a type name (which can * also be "var") but the actual assignment can be missing. * Examples: var a = 2; uint256 a; diff --git a/libsolidity/ast/ASTForward.h b/libsolidity/ast/ASTForward.h index 46675e51..992fe4cd 100644 --- a/libsolidity/ast/ASTForward.h +++ b/libsolidity/ast/ASTForward.h @@ -69,6 +69,7 @@ class Continue; class Break; class Return; class Throw; +class EmitStatement; class VariableDeclarationStatement; class ExpressionStatement; class Expression; diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp index cd9f7eca..4fef67c3 100644 --- a/libsolidity/ast/ASTJsonConverter.cpp +++ b/libsolidity/ast/ASTJsonConverter.cpp @@ -540,7 +540,15 @@ bool ASTJsonConverter::visit(Return const& _node) bool ASTJsonConverter::visit(Throw const& _node) { - setJsonNode(_node, "Throw", {});; + setJsonNode(_node, "Throw", {}); + return false; +} + +bool ASTJsonConverter::visit(EmitStatement const& _node) +{ + setJsonNode(_node, "EmitStatement", { + make_pair("eventCall", toJson(_node.eventCall())) + }); return false; } diff --git a/libsolidity/ast/ASTJsonConverter.h b/libsolidity/ast/ASTJsonConverter.h index 9a886220..88b93699 100644 --- a/libsolidity/ast/ASTJsonConverter.h +++ b/libsolidity/ast/ASTJsonConverter.h @@ -91,6 +91,7 @@ public: bool visit(Break const& _node) override; bool visit(Return const& _node) override; bool visit(Throw const& _node) override; + bool visit(EmitStatement const& _node) override; bool visit(VariableDeclarationStatement const& _node) override; bool visit(ExpressionStatement const& _node) override; bool visit(Conditional const& _node) override; diff --git a/libsolidity/ast/ASTPrinter.cpp b/libsolidity/ast/ASTPrinter.cpp index 23c3cbe1..4273f225 100644 --- a/libsolidity/ast/ASTPrinter.cpp +++ b/libsolidity/ast/ASTPrinter.cpp @@ -258,6 +258,13 @@ bool ASTPrinter::visit(Throw const& _node) return goDeeper(); } +bool ASTPrinter::visit(EmitStatement const& _node) +{ + writeLine("EmitStatement"); + printSourcePart(_node); + return goDeeper(); +} + bool ASTPrinter::visit(VariableDeclarationStatement const& _node) { writeLine("VariableDeclarationStatement"); @@ -517,6 +524,11 @@ void ASTPrinter::endVisit(Throw const&) m_indentation--; } +void ASTPrinter::endVisit(EmitStatement const&) +{ + m_indentation--; +} + void ASTPrinter::endVisit(VariableDeclarationStatement const&) { m_indentation--; diff --git a/libsolidity/ast/ASTPrinter.h b/libsolidity/ast/ASTPrinter.h index 01e4f7fc..de3bf8a2 100644 --- a/libsolidity/ast/ASTPrinter.h +++ b/libsolidity/ast/ASTPrinter.h @@ -76,6 +76,7 @@ public: bool visit(Break const& _node) override; bool visit(Return const& _node) override; bool visit(Throw const& _node) override; + bool visit(EmitStatement const& _node) override; bool visit(VariableDeclarationStatement const& _node) override; bool visit(ExpressionStatement const& _node) override; bool visit(Conditional const& _node) override; @@ -120,6 +121,7 @@ public: void endVisit(Break const&) override; void endVisit(Return const&) override; void endVisit(Throw const&) override; + void endVisit(EmitStatement const&) override; void endVisit(VariableDeclarationStatement const&) override; void endVisit(ExpressionStatement const&) override; void endVisit(Conditional const&) override; diff --git a/libsolidity/ast/ASTVisitor.h b/libsolidity/ast/ASTVisitor.h index b726d592..b1389f0f 100644 --- a/libsolidity/ast/ASTVisitor.h +++ b/libsolidity/ast/ASTVisitor.h @@ -73,6 +73,7 @@ public: virtual bool visit(Break& _node) { return visitNode(_node); } virtual bool visit(Return& _node) { return visitNode(_node); } virtual bool visit(Throw& _node) { return visitNode(_node); } + virtual bool visit(EmitStatement& _node) { return visitNode(_node); } virtual bool visit(VariableDeclarationStatement& _node) { return visitNode(_node); } virtual bool visit(ExpressionStatement& _node) { return visitNode(_node); } virtual bool visit(Conditional& _node) { return visitNode(_node); } @@ -118,6 +119,7 @@ public: virtual void endVisit(Break& _node) { endVisitNode(_node); } virtual void endVisit(Return& _node) { endVisitNode(_node); } virtual void endVisit(Throw& _node) { endVisitNode(_node); } + virtual void endVisit(EmitStatement& _node) { endVisitNode(_node); } virtual void endVisit(VariableDeclarationStatement& _node) { endVisitNode(_node); } virtual void endVisit(ExpressionStatement& _node) { endVisitNode(_node); } virtual void endVisit(Conditional& _node) { endVisitNode(_node); } @@ -175,6 +177,7 @@ public: virtual bool visit(Break const& _node) { return visitNode(_node); } virtual bool visit(Return const& _node) { return visitNode(_node); } virtual bool visit(Throw const& _node) { return visitNode(_node); } + virtual bool visit(EmitStatement const& _node) { return visitNode(_node); } virtual bool visit(VariableDeclarationStatement const& _node) { return visitNode(_node); } virtual bool visit(ExpressionStatement const& _node) { return visitNode(_node); } virtual bool visit(Conditional const& _node) { return visitNode(_node); } @@ -220,6 +223,7 @@ public: virtual void endVisit(Break const& _node) { endVisitNode(_node); } virtual void endVisit(Return const& _node) { endVisitNode(_node); } virtual void endVisit(Throw const& _node) { endVisitNode(_node); } + virtual void endVisit(EmitStatement const& _node) { endVisitNode(_node); } virtual void endVisit(VariableDeclarationStatement const& _node) { endVisitNode(_node); } virtual void endVisit(ExpressionStatement const& _node) { endVisitNode(_node); } virtual void endVisit(Conditional const& _node) { endVisitNode(_node); } diff --git a/libsolidity/ast/AST_accept.h b/libsolidity/ast/AST_accept.h index 904d9ff6..70ee997e 100644 --- a/libsolidity/ast/AST_accept.h +++ b/libsolidity/ast/AST_accept.h @@ -541,6 +541,20 @@ void Throw::accept(ASTConstVisitor& _visitor) const _visitor.endVisit(*this); } +void EmitStatement::accept(ASTVisitor& _visitor) +{ + if (_visitor.visit(*this)) + m_eventCall->accept(_visitor); + _visitor.endVisit(*this); +} + +void EmitStatement::accept(ASTConstVisitor& _visitor) const +{ + if (_visitor.visit(*this)) + m_eventCall->accept(_visitor); + _visitor.endVisit(*this); +} + void ExpressionStatement::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) |