aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/AST.cpp7
-rw-r--r--libsolidity/ast/AST.h53
-rw-r--r--libsolidity/ast/ASTAnnotations.h8
3 files changed, 51 insertions, 17 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 9d1fb811..41a4d182 100644
--- a/libsolidity/ast/AST.cpp
+++ b/libsolidity/ast/AST.cpp
@@ -336,6 +336,13 @@ VariableDeclarationAnnotation& VariableDeclaration::annotation() const
return static_cast<VariableDeclarationAnnotation&>(*m_annotation);
}
+StatementAnnotation& Statement::annotation() const
+{
+ if (!m_annotation)
+ m_annotation = new StatementAnnotation();
+ return static_cast<StatementAnnotation&>(*m_annotation);
+}
+
ReturnAnnotation& Return::annotation() const
{
if (!m_annotation)
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index 6a593d3e..1a204dca 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -792,10 +792,15 @@ private:
/**
* Abstract base class for statements.
*/
-class Statement: public ASTNode
+class Statement: public ASTNode, public Documented
{
public:
- explicit Statement(SourceLocation const& _location): ASTNode(_location) {}
+ explicit Statement(
+ SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString
+ ): ASTNode(_location), Documented(_docString) {}
+
+ virtual StatementAnnotation& annotation() const override;
};
/**
@@ -806,9 +811,10 @@ class Block: public Statement
public:
Block(
SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString,
std::vector<ASTPointer<Statement>> const& _statements
):
- Statement(_location), m_statements(_statements) {}
+ Statement(_location, _docString), m_statements(_statements) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
@@ -823,7 +829,10 @@ private:
class PlaceholderStatement: public Statement
{
public:
- explicit PlaceholderStatement(SourceLocation const& _location): Statement(_location) {}
+ explicit PlaceholderStatement(
+ SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString
+ ): Statement(_location, _docString) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
@@ -838,11 +847,12 @@ class IfStatement: public Statement
public:
IfStatement(
SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> const& _condition,
ASTPointer<Statement> const& _trueBody,
ASTPointer<Statement> const& _falseBody
):
- Statement(_location),
+ Statement(_location, _docString),
m_condition(_condition),
m_trueBody(_trueBody),
m_falseBody(_falseBody)
@@ -867,7 +877,10 @@ private:
class BreakableStatement: public Statement
{
public:
- explicit BreakableStatement(SourceLocation const& _location): Statement(_location) {}
+ explicit BreakableStatement(
+ SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString
+ ): Statement(_location, _docString) {}
};
class WhileStatement: public BreakableStatement
@@ -875,10 +888,11 @@ class WhileStatement: public BreakableStatement
public:
WhileStatement(
SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> const& _condition,
ASTPointer<Statement> const& _body
):
- BreakableStatement(_location), m_condition(_condition), m_body(_body) {}
+ BreakableStatement(_location, _docString), m_condition(_condition), m_body(_body) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
@@ -898,12 +912,13 @@ class ForStatement: public BreakableStatement
public:
ForStatement(
SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString,
ASTPointer<Statement> const& _initExpression,
ASTPointer<Expression> const& _conditionExpression,
ASTPointer<ExpressionStatement> const& _loopExpression,
ASTPointer<Statement> const& _body
):
- BreakableStatement(_location),
+ BreakableStatement(_location, _docString),
m_initExpression(_initExpression),
m_condExpression(_conditionExpression),
m_loopExpression(_loopExpression),
@@ -931,7 +946,8 @@ private:
class Continue: public Statement
{
public:
- explicit Continue(SourceLocation const& _location): Statement(_location) {}
+ explicit Continue(SourceLocation const& _location, ASTPointer<ASTString> const& _docString):
+ Statement(_location, _docString) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
};
@@ -939,7 +955,8 @@ public:
class Break: public Statement
{
public:
- explicit Break(SourceLocation const& _location): Statement(_location) {}
+ explicit Break(SourceLocation const& _location, ASTPointer<ASTString> const& _docString):
+ Statement(_location, _docString) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
};
@@ -947,8 +964,11 @@ public:
class Return: public Statement
{
public:
- Return(SourceLocation const& _location, ASTPointer<Expression> _expression):
- Statement(_location), m_expression(_expression) {}
+ Return(
+ SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString,
+ ASTPointer<Expression> _expression
+ ): Statement(_location, _docString), m_expression(_expression) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
@@ -966,7 +986,8 @@ private:
class Throw: public Statement
{
public:
- explicit Throw(SourceLocation const& _location): Statement(_location) {}
+ explicit Throw(SourceLocation const& _location, ASTPointer<ASTString> const& _docString):
+ Statement(_location, _docString) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
};
@@ -985,10 +1006,11 @@ class VariableDeclarationStatement: public Statement
public:
VariableDeclarationStatement(
SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString,
std::vector<ASTPointer<VariableDeclaration>> const& _variables,
ASTPointer<Expression> const& _initialValue
):
- Statement(_location), m_variables(_variables), m_initialValue(_initialValue) {}
+ Statement(_location, _docString), m_variables(_variables), m_initialValue(_initialValue) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
@@ -1012,9 +1034,10 @@ class ExpressionStatement: public Statement
public:
ExpressionStatement(
SourceLocation const& _location,
+ ASTPointer<ASTString> const& _docString,
ASTPointer<Expression> _expression
):
- Statement(_location), m_expression(_expression) {}
+ Statement(_location, _docString), m_expression(_expression) {}
virtual void accept(ASTVisitor& _visitor) override;
virtual void accept(ASTConstVisitor& _visitor) const override;
diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h
index 094a178e..bb59ceae 100644
--- a/libsolidity/ast/ASTAnnotations.h
+++ b/libsolidity/ast/ASTAnnotations.h
@@ -90,7 +90,11 @@ struct VariableDeclarationAnnotation: ASTAnnotation
TypePointer type;
};
-struct ReturnAnnotation: ASTAnnotation
+struct StatementAnnotation: ASTAnnotation, DocumentedAnnotation
+{
+};
+
+struct ReturnAnnotation: StatementAnnotation
{
/// Reference to the return parameters of the function.
ParameterList const* functionReturnParameters = nullptr;
@@ -109,7 +113,7 @@ struct UserDefinedTypeNameAnnotation: TypeNameAnnotation
Declaration const* referencedDeclaration = nullptr;
};
-struct VariableDeclarationStatementAnnotation: ASTAnnotation
+struct VariableDeclarationStatementAnnotation: StatementAnnotation
{
/// Information about which component of the value is assigned to which variable.
/// The pointer can be null to signify that the component is discarded.