From a7f9815c0f68a7cb9571193ded851fbedb418422 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 16 Oct 2014 23:49:45 +0200 Subject: Coding style and cleanup --- AST.cpp | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'AST.cpp') diff --git a/AST.cpp b/AST.cpp index 355ff1bd..c1a3faa5 100644 --- a/AST.cpp +++ b/AST.cpp @@ -45,18 +45,14 @@ void ContractDefinition::accept(ASTVisitor& _visitor) void StructDefinition::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - { listAccept(m_members, _visitor); - } _visitor.endVisit(*this); } void ParameterList::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - { listAccept(m_parameters, _visitor); - } _visitor.endVisit(*this); } @@ -75,10 +71,8 @@ void FunctionDefinition::accept(ASTVisitor& _visitor) void VariableDeclaration::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - { if (m_typeName) m_typeName->accept(_visitor); - } _visitor.endVisit(*this); } @@ -119,9 +113,7 @@ void Statement::accept(ASTVisitor& _visitor) void Block::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - { listAccept(m_statements, _visitor); - } _visitor.endVisit(*this); } @@ -168,10 +160,8 @@ void Break::accept(ASTVisitor& _visitor) void Return::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - { if (m_expression) m_expression->accept(_visitor); - } _visitor.endVisit(*this); } @@ -199,9 +189,7 @@ void Assignment::accept(ASTVisitor& _visitor) void UnaryOperation::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - { m_subExpression->accept(_visitor); - } _visitor.endVisit(*this); } @@ -228,9 +216,7 @@ void FunctionCall::accept(ASTVisitor& _visitor) void MemberAccess::accept(ASTVisitor& _visitor) { if (_visitor.visit(*this)) - { m_expression->accept(_visitor); - } _visitor.endVisit(*this); } @@ -272,7 +258,7 @@ void Statement::expectType(Expression& _expression, const Type& _expectedType) ptr Block::checkTypeRequirements() { - for (ptr const & statement : m_statements) + for (ptr const& statement: m_statements) statement->checkTypeRequirements(); return ptr(); } @@ -281,7 +267,8 @@ ptr IfStatement::checkTypeRequirements() { expectType(*m_condition, BoolType()); m_trueBody->checkTypeRequirements(); - if (m_falseBody) m_falseBody->checkTypeRequirements(); + if (m_falseBody) + m_falseBody->checkTypeRequirements(); return ptr(); } @@ -324,14 +311,10 @@ ptr VariableDefinition::checkTypeRequirements() if (m_value) { if (m_variable->getType()) - { expectType(*m_value, *m_variable->getType()); - } else - { // no type declared and no previous assignment, infer the type m_variable->setType(m_value->checkTypeRequirements()); - } } return ptr(); } @@ -371,9 +354,7 @@ ptr BinaryOperation::checkTypeRequirements() else BOOST_THROW_EXCEPTION(TypeError() << errinfo_comment("No common type found in binary operation.")); if (Token::isCompareOp(m_operator)) - { m_type = std::make_shared(); - } else { BOOST_ASSERT(Token::isBinaryOp(m_operator)); @@ -387,7 +368,7 @@ ptr BinaryOperation::checkTypeRequirements() ptr FunctionCall::checkTypeRequirements() { m_expression->checkTypeRequirements(); - for (ptr const & argument : m_arguments) + for (ptr const& argument: m_arguments) argument->checkTypeRequirements(); ptr expressionType = m_expression->getType(); Type::Category const category = expressionType->getCategory(); @@ -418,11 +399,9 @@ ptr FunctionCall::checkTypeRequirements() BOOST_THROW_EXCEPTION(TypeError() << errinfo_comment("Wrong argument count for " "function call.")); for (size_t i = 0; i < m_arguments.size(); ++i) - { if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameters[i]->getType())) BOOST_THROW_EXCEPTION(TypeError() << errinfo_comment("Invalid type for argument in " "function call.")); - } // @todo actually the return type should be an anonymous struct, // but we change it to the type of the first return value until we have structs if (fun.getReturnParameterList()->getParameters().empty()) -- cgit