aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/ast/AST.h27
-rw-r--r--libsolidity/ast/ASTForward.h1
-rw-r--r--libsolidity/ast/AST_accept.h22
3 files changed, 50 insertions, 0 deletions
diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h
index 4baf95d3..e1063467 100644
--- a/libsolidity/ast/AST.h
+++ b/libsolidity/ast/AST.h
@@ -1119,6 +1119,33 @@ public:
ExpressionAnnotation& annotation() const override;
};
+class Conditional: public Expression
+{
+public:
+ Conditional(
+ SourceLocation const& _location,
+ ASTPointer<Expression> const& _condition,
+ ASTPointer<Expression> const& _trueExpression,
+ ASTPointer<Expression> const& _falseExpression
+ ):
+ Expression(_location),
+ m_condition(_condition),
+ m_trueExpression(_trueExpression),
+ m_falseExpression(_falseExpression)
+ {}
+ virtual void accept(ASTVisitor& _visitor) override;
+ virtual void accept(ASTConstVisitor& _visitor) const override;
+
+ Expression const& condition() const { return *m_condition; }
+ Expression const& trueExpression() const { return *m_trueExpression; }
+ Expression const& falseExpression() const { return *m_falseExpression; }
+
+private:
+ ASTPointer<Expression> m_condition;
+ ASTPointer<Expression> m_trueExpression;
+ ASTPointer<Expression> m_falseExpression;
+};
+
/// Assignment, can also be a compound assignment.
/// Examples: (a = 7 + 8) or (a *= 2)
class Assignment: public Expression
diff --git a/libsolidity/ast/ASTForward.h b/libsolidity/ast/ASTForward.h
index 6aaa77ce..dad2b2e2 100644
--- a/libsolidity/ast/ASTForward.h
+++ b/libsolidity/ast/ASTForward.h
@@ -69,6 +69,7 @@ class Throw;
class VariableDeclarationStatement;
class ExpressionStatement;
class Expression;
+class Conditional;
class Assignment;
class TupleExpression;
class UnaryOperation;
diff --git a/libsolidity/ast/AST_accept.h b/libsolidity/ast/AST_accept.h
index 61370c55..dee9d5b1 100644
--- a/libsolidity/ast/AST_accept.h
+++ b/libsolidity/ast/AST_accept.h
@@ -551,6 +551,28 @@ void VariableDeclarationStatement::accept(ASTConstVisitor& _visitor) const
_visitor.endVisit(*this);
}
+void Conditional::accept(ASTVisitor& _visitor)
+{
+ if (_visitor.visit(*this))
+ {
+ m_condition->accept(_visitor);
+ m_trueExpression->accept(_visitor);
+ m_falseExpression->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
+void Conditional::accept(ASTConstVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_condition->accept(_visitor);
+ m_trueExpression->accept(_visitor);
+ m_falseExpression->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void Assignment::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))