diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index cd8a66ad7..a7d5e73ca 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -660,6 +660,27 @@ InlineAssemblyAnnotation& InlineAssembly::annotation() const return dynamic_cast(*m_annotation); } +BlockAnnotation& Block::annotation() const +{ + if (!m_annotation) + m_annotation = make_unique(); + return dynamic_cast(*m_annotation); +} + +TryCatchClauseAnnotation& TryCatchClause::annotation() const +{ + if (!m_annotation) + m_annotation = make_unique(); + return dynamic_cast(*m_annotation); +} + +ForStatementAnnotation& ForStatement::annotation() const +{ + if (!m_annotation) + m_annotation = make_unique(); + return dynamic_cast(*m_annotation); +} + ReturnAnnotation& Return::annotation() const { if (!m_annotation) diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 871760a41..4abaf93e3 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -1171,6 +1171,8 @@ public: std::vector> const& statements() const { return m_statements; } + BlockAnnotation& annotation() const override; + private: std::vector> m_statements; }; @@ -1250,6 +1252,8 @@ public: ParameterList const* parameters() const { return m_parameters.get(); } Block const& block() const { return *m_block; } + TryCatchClauseAnnotation& annotation() const override; + private: ASTPointer m_errorName; ASTPointer m_parameters; @@ -1359,6 +1363,8 @@ public: ExpressionStatement const* loopExpression() const { return m_loopExpression.get(); } Statement const& body() const { return *m_body; } + ForStatementAnnotation& annotation() const override; + private: /// For statement's initialization expression. for (XXX; ; ). Can be empty ASTPointer m_initExpression; diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index 107da87f5..0f11b1c5a 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -163,6 +163,18 @@ struct InlineAssemblyAnnotation: StatementAnnotation std::shared_ptr analysisInfo; }; +struct BlockAnnotation: StatementAnnotation, ScopableAnnotation +{ +}; + +struct TryCatchClauseAnnotation: ASTAnnotation, ScopableAnnotation +{ +}; + +struct ForStatementAnnotation: StatementAnnotation, ScopableAnnotation +{ +}; + struct ReturnAnnotation: StatementAnnotation { /// Reference to the return parameters of the function.