aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-12-06 00:29:20 +0800
committerChristian <c@ethdev.com>2014-12-08 19:49:03 +0800
commit41b8d7b7f1221c6caae142a6833228ccd098ef5b (patch)
tree7ca2f85bb0a03db17a835d9a3b36da8e67266abb /AST.cpp
parent260a1529a758fb7b75840e05d8c0be18975ff3b2 (diff)
downloaddexon-solidity-41b8d7b7f1221c6caae142a6833228ccd098ef5b.tar.gz
dexon-solidity-41b8d7b7f1221c6caae142a6833228ccd098ef5b.tar.zst
dexon-solidity-41b8d7b7f1221c6caae142a6833228ccd098ef5b.zip
Const functions for ASTVisitor and const ASTPrinter.
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp209
1 files changed, 205 insertions, 4 deletions
diff --git a/AST.cpp b/AST.cpp
index 697ffe8e..619d3f5c 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -57,6 +57,17 @@ void ContractDefinition::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void ContractDefinition::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ listAccept(m_definedStructs, _visitor);
+ listAccept(m_stateVariables, _visitor);
+ listAccept(m_definedFunctions, _visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void StructDefinition::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -64,6 +75,13 @@ void StructDefinition::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void StructDefinition::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ listAccept(m_members, _visitor);
+ _visitor.endVisit(*this);
+}
+
void StructDefinition::checkValidityOfMembers()
{
checkMemberTypes();
@@ -77,6 +95,13 @@ void ParameterList::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void ParameterList::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ listAccept(m_parameters, _visitor);
+ _visitor.endVisit(*this);
+}
+
void FunctionDefinition::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -89,6 +114,18 @@ void FunctionDefinition::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void FunctionDefinition::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_parameters->accept(_visitor);
+ if (m_returnParameters)
+ m_returnParameters->accept(_visitor);
+ m_body->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void VariableDeclaration::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -97,24 +134,50 @@ void VariableDeclaration::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void VariableDeclaration::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ if (m_typeName)
+ m_typeName->accept(_visitor);
+ _visitor.endVisit(*this);
+}
+
void TypeName::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void TypeName::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
void ElementaryTypeName::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void ElementaryTypeName::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
void UserDefinedTypeName::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void UserDefinedTypeName::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
void Mapping::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -125,9 +188,13 @@ void Mapping::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
-void Statement::accept(ASTVisitor& _visitor)
+void Mapping::accept(ASTVisitor& _visitor) const
{
- _visitor.visit(*this);
+ if (_visitor.visit(*this))
+ {
+ m_keyType->accept(_visitor);
+ m_valueType->accept(_visitor);
+ }
_visitor.endVisit(*this);
}
@@ -138,6 +205,13 @@ void Block::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void Block::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ listAccept(m_statements, _visitor);
+ _visitor.endVisit(*this);
+}
+
void IfStatement::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -150,9 +224,15 @@ void IfStatement::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
-void BreakableStatement::accept(ASTVisitor& _visitor)
+void IfStatement::accept(ASTVisitor& _visitor) const
{
- _visitor.visit(*this);
+ if (_visitor.visit(*this))
+ {
+ m_condition->accept(_visitor);
+ m_trueBody->accept(_visitor);
+ if (m_falseBody)
+ m_falseBody->accept(_visitor);
+ }
_visitor.endVisit(*this);
}
@@ -166,18 +246,40 @@ void WhileStatement::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void WhileStatement::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_condition->accept(_visitor);
+ m_body->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void Continue::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void Continue::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
void Break::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void Break::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
void Return::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -186,6 +288,14 @@ void Return::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void Return::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ if (m_expression)
+ m_expression->accept(_visitor);
+ _visitor.endVisit(*this);
+}
+
void ExpressionStatement::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -194,6 +304,14 @@ void ExpressionStatement::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void ExpressionStatement::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ if (m_expression)
+ m_expression->accept(_visitor);
+ _visitor.endVisit(*this);
+}
+
void VariableDefinition::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -205,6 +323,17 @@ void VariableDefinition::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void VariableDefinition::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_variable->accept(_visitor);
+ if (m_value)
+ m_value->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void Assignment::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -215,6 +344,16 @@ void Assignment::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void Assignment::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_leftHandSide->accept(_visitor);
+ m_rightHandSide->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void UnaryOperation::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -222,6 +361,13 @@ void UnaryOperation::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void UnaryOperation::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ m_subExpression->accept(_visitor);
+ _visitor.endVisit(*this);
+}
+
void BinaryOperation::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -232,6 +378,16 @@ void BinaryOperation::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void BinaryOperation::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_left->accept(_visitor);
+ m_right->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void FunctionCall::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -242,6 +398,16 @@ void FunctionCall::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void FunctionCall::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_expression->accept(_visitor);
+ listAccept(m_arguments, _visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void MemberAccess::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -249,6 +415,13 @@ void MemberAccess::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void MemberAccess::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ m_expression->accept(_visitor);
+ _visitor.endVisit(*this);
+}
+
void IndexAccess::accept(ASTVisitor& _visitor)
{
if (_visitor.visit(*this))
@@ -259,24 +432,52 @@ void IndexAccess::accept(ASTVisitor& _visitor)
_visitor.endVisit(*this);
}
+void IndexAccess::accept(ASTVisitor& _visitor) const
+{
+ if (_visitor.visit(*this))
+ {
+ m_base->accept(_visitor);
+ m_index->accept(_visitor);
+ }
+ _visitor.endVisit(*this);
+}
+
void Identifier::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void Identifier::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
void ElementaryTypeNameExpression::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void ElementaryTypeNameExpression::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
void Literal::accept(ASTVisitor& _visitor)
{
_visitor.visit(*this);
_visitor.endVisit(*this);
}
+void Literal::accept(ASTVisitor& _visitor) const
+{
+ _visitor.visit(*this);
+ _visitor.endVisit(*this);
+}
+
TypeError ASTNode::createTypeError(string const& _description) const
{
return TypeError() << errinfo_sourceLocation(getLocation()) << errinfo_comment(_description);