diff options
author | Christian <c@ethdev.com> | 2014-10-17 05:49:45 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-17 18:37:51 +0800 |
commit | a7f9815c0f68a7cb9571193ded851fbedb418422 (patch) | |
tree | 09adba8ef0aa273f5a84251ed53662b7d7fe3972 /AST.h | |
parent | 8a506b505f4725e8a76bbad8399562099e4510c3 (diff) | |
download | dexon-solidity-a7f9815c0f68a7cb9571193ded851fbedb418422.tar.gz dexon-solidity-a7f9815c0f68a7cb9571193ded851fbedb418422.tar.zst dexon-solidity-a7f9815c0f68a7cb9571193ded851fbedb418422.zip |
Coding style and cleanup
Diffstat (limited to 'AST.h')
-rw-r--r-- | AST.h | 138 |
1 files changed, 59 insertions, 79 deletions
@@ -40,7 +40,7 @@ namespace solidity class ASTVisitor; -class ASTNode : private boost::noncopyable +class ASTNode: private boost::noncopyable { public: explicit ASTNode(Location const& _location) @@ -53,7 +53,7 @@ public: template <class T> static void listAccept(vecptr<T>& _list, ASTVisitor& _visitor) { - for (ptr<T>& element : _list) + for (ptr<T>& element: _list) element->accept(_visitor); } @@ -62,7 +62,7 @@ private: Location m_location; }; -class Declaration : public ASTNode +class Declaration: public ASTNode { public: Declaration(Location const& _location, ptr<ASTString> const& _name) @@ -73,7 +73,7 @@ private: ptr<ASTString> m_name; }; -class ContractDefinition : public Declaration +class ContractDefinition: public Declaration { public: ContractDefinition(Location const& _location, @@ -98,14 +98,13 @@ private: vecptr<FunctionDefinition> m_definedFunctions; }; -class StructDefinition : public Declaration +class StructDefinition: public Declaration { public: StructDefinition(Location const& _location, ptr<ASTString> const& _name, vecptr<VariableDeclaration> const& _members) - : Declaration(_location, _name), m_members(_members) - {} + : Declaration(_location, _name), m_members(_members) {} virtual void accept(ASTVisitor& _visitor) override; private: @@ -115,12 +114,11 @@ private: /// Used as function parameter list and return list /// None of the parameters is allowed to contain mappings (not even recursively /// inside structs) -class ParameterList : public ASTNode +class ParameterList: public ASTNode { public: ParameterList(Location const& _location, vecptr<VariableDeclaration> const& _parameters) - : ASTNode(_location), m_parameters(_parameters) - {} + : ASTNode(_location), m_parameters(_parameters) {} virtual void accept(ASTVisitor& _visitor) override; vecptr<VariableDeclaration> const& getParameters() { return m_parameters; } @@ -128,7 +126,7 @@ private: vecptr<VariableDeclaration> m_parameters; }; -class FunctionDefinition : public Declaration +class FunctionDefinition: public Declaration { public: FunctionDefinition(Location const& _location, ptr<ASTString> const& _name, bool _isPublic, @@ -138,8 +136,7 @@ public: ptr<Block> const& _body) : Declaration(_location, _name), m_isPublic(_isPublic), m_parameters(_parameters), m_isDeclaredConst(_isDeclaredConst), m_returnParameters(_returnParameters), - m_body(_body) - {} + m_body(_body) {} virtual void accept(ASTVisitor& _visitor) override; bool isPublic() const { return m_isPublic; } @@ -156,14 +153,12 @@ private: ptr<Block> m_body; }; -class VariableDeclaration : public Declaration +class VariableDeclaration: public Declaration { public: - VariableDeclaration(Location const& _location, - ptr<TypeName> const& _type, + VariableDeclaration(Location const& _location, ptr<TypeName> const& _type, ptr<ASTString> const& _name) - : Declaration(_location, _name), m_typeName(_type) - {} + : Declaration(_location, _name), m_typeName(_type) {} virtual void accept(ASTVisitor& _visitor) override; bool isTypeGivenExplicitly() const { return m_typeName.get() != nullptr; } @@ -182,22 +177,21 @@ private: /// types /// @{ -class TypeName : public ASTNode +class TypeName: public ASTNode { public: - explicit TypeName(Location const& _location) : ASTNode(_location) {} + explicit TypeName(Location const& _location): ASTNode(_location) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> toType() = 0; }; /// any pre-defined type that is not a mapping -class ElementaryTypeName : public TypeName +class ElementaryTypeName: public TypeName { public: explicit ElementaryTypeName(Location const& _location, Token::Value _type) - : TypeName(_location), m_type(_type) - {} + : TypeName(_location), m_type(_type) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> toType() override { return Type::fromElementaryTypeName(m_type); } @@ -206,12 +200,11 @@ private: Token::Value m_type; }; -class UserDefinedTypeName : public TypeName +class UserDefinedTypeName: public TypeName { public: UserDefinedTypeName(Location const& _location, ptr<ASTString> const& _name) - : TypeName(_location), m_name(_name) - {} + : TypeName(_location), m_name(_name) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> toType() override { return Type::fromUserDefinedTypeName(*this); } @@ -224,13 +217,12 @@ private: StructDefinition* m_referencedStruct; }; -class Mapping : public TypeName +class Mapping: public TypeName { public: Mapping(Location const& _location, ptr<ElementaryTypeName> const& _keyType, ptr<TypeName> const& _valueType) - : TypeName(_location), m_keyType(_keyType), m_valueType(_valueType) - {} + : TypeName(_location), m_keyType(_keyType), m_valueType(_valueType) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> toType() override { return Type::fromMapping(*this); } private: @@ -243,10 +235,10 @@ private: /// Statements /// @{ -class Statement : public ASTNode +class Statement: public ASTNode { public: - explicit Statement(Location const& _location) : ASTNode(_location) {} + explicit Statement(Location const& _location): ASTNode(_location) {} virtual void accept(ASTVisitor& _visitor) override; //! Check all type requirements, throws exception if some requirement is not met. @@ -259,12 +251,11 @@ protected: void expectType(Expression& _expression, Type const& _expectedType); }; -class Block : public Statement +class Block: public Statement { public: Block(Location const& _location, vecptr<Statement> const& _statements) - : Statement(_location), m_statements(_statements) - {} + : Statement(_location), m_statements(_statements) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; @@ -272,14 +263,13 @@ private: vecptr<Statement> m_statements; }; -class IfStatement : public Statement +class IfStatement: public Statement { public: IfStatement(Location const& _location, ptr<Expression> const& _condition, ptr<Statement> const& _trueBody, ptr<Statement> const& _falseBody) : Statement(_location), m_condition(_condition), - m_trueBody(_trueBody), m_falseBody(_falseBody) - {} + m_trueBody(_trueBody), m_falseBody(_falseBody) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; private: @@ -288,20 +278,19 @@ private: ptr<Statement> m_falseBody; //< "else" part, optional }; -class BreakableStatement : public Statement +class BreakableStatement: public Statement { public: - BreakableStatement(Location const& _location) : Statement(_location) {} + BreakableStatement(Location const& _location): Statement(_location) {} virtual void accept(ASTVisitor& _visitor) override; }; -class WhileStatement : public BreakableStatement +class WhileStatement: public BreakableStatement { public: WhileStatement(Location const& _location, ptr<Expression> const& _condition, ptr<Statement> const& _body) - : BreakableStatement(_location), m_condition(_condition), m_body(_body) - {} + : BreakableStatement(_location), m_condition(_condition), m_body(_body) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; private: @@ -309,28 +298,27 @@ private: ptr<Statement> m_body; }; -class Continue : public Statement +class Continue: public Statement { public: - Continue(Location const& _location) : Statement(_location) {} + Continue(Location const& _location): Statement(_location) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; }; -class Break : public Statement +class Break: public Statement { public: - Break(Location const& _location) : Statement(_location) {} + Break(Location const& _location): Statement(_location) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; }; -class Return : public Statement +class Return: public Statement { public: Return(Location const& _location, ptr<Expression> _expression) - : Statement(_location), m_expression(_expression) - {} + : Statement(_location), m_expression(_expression) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; @@ -341,13 +329,12 @@ private: ParameterList* m_returnParameters; //< extracted from the function declaration }; -class VariableDefinition : public Statement +class VariableDefinition: public Statement { public: VariableDefinition(Location const& _location, ptr<VariableDeclaration> _variable, ptr<Expression> _value) - : Statement(_location), m_variable(_variable), m_value(_value) - {} + : Statement(_location), m_variable(_variable), m_value(_value) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; @@ -356,10 +343,10 @@ private: ptr<Expression> m_value; ///< can be missing }; -class Expression : public Statement +class Expression: public Statement { public: - Expression(Location const& _location) : Statement(_location) {} + Expression(Location const& _location): Statement(_location) {} ptr<Type> const& getType() { return m_type; } protected: ptr<Type> m_type; @@ -370,14 +357,13 @@ protected: /// Expressions /// @{ -class Assignment : public Expression +class Assignment: public Expression { public: Assignment(Location const& _location, ptr<Expression> const& _leftHandSide, Token::Value _assignmentOperator, ptr<Expression> const& _rightHandSide) : Expression(_location), m_leftHandSide(_leftHandSide), - m_assigmentOperator(_assignmentOperator), m_rightHandSide(_rightHandSide) - {} + m_assigmentOperator(_assignmentOperator), m_rightHandSide(_rightHandSide) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; @@ -388,14 +374,13 @@ private: ptr<Expression> m_rightHandSide; }; -class UnaryOperation : public Expression +class UnaryOperation: public Expression { public: UnaryOperation(Location const& _location, Token::Value _operator, ptr<Expression> const& _subExpression, bool _isPrefix) : Expression(_location), m_operator(_operator), - m_subExpression(_subExpression), m_isPrefix(_isPrefix) - {} + m_subExpression(_subExpression), m_isPrefix(_isPrefix) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; @@ -407,13 +392,12 @@ private: bool m_isPrefix; }; -class BinaryOperation : public Expression +class BinaryOperation: public Expression { public: BinaryOperation(Location const& _location, ptr<Expression> const& _left, Token::Value _operator, ptr<Expression> const& _right) - : Expression(_location), m_left(_left), m_operator(_operator), m_right(_right) - {} + : Expression(_location), m_left(_left), m_operator(_operator), m_right(_right) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; @@ -427,13 +411,12 @@ private: }; /// Can be ordinary function call, type cast or struct construction. -class FunctionCall : public Expression +class FunctionCall: public Expression { public: FunctionCall(Location const& _location, ptr<Expression> const& _expression, vecptr<Expression> const& _arguments) - : Expression(_location), m_expression(_expression), m_arguments(_arguments) - {} + : Expression(_location), m_expression(_expression), m_arguments(_arguments) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; private: @@ -441,13 +424,12 @@ private: vecptr<Expression> m_arguments; }; -class MemberAccess : public Expression +class MemberAccess: public Expression { public: MemberAccess(Location const& _location, ptr<Expression> _expression, ptr<ASTString> const& _memberName) - : Expression(_location), m_expression(_expression), m_memberName(_memberName) - {} + : Expression(_location), m_expression(_expression), m_memberName(_memberName) {} virtual void accept(ASTVisitor& _visitor) override; const ASTString& getMemberName() const { return *m_memberName; } virtual ptr<Type> checkTypeRequirements() override; @@ -456,13 +438,12 @@ private: ptr<ASTString> m_memberName; }; -class IndexAccess : public Expression +class IndexAccess: public Expression { public: IndexAccess(Location const& _location, ptr<Expression> const& _base, ptr<Expression> const& _index) - : Expression(_location), m_base(_base), m_index(_index) - {} + : Expression(_location), m_base(_base), m_index(_index) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; private: @@ -470,13 +451,13 @@ private: ptr<Expression> m_index; }; -class PrimaryExpression : public Expression +class PrimaryExpression: public Expression { public: - PrimaryExpression(Location const& _location) : Expression(_location) {} + PrimaryExpression(Location const& _location): Expression(_location) {} }; -class Identifier : public PrimaryExpression +class Identifier: public PrimaryExpression { public: Identifier(Location const& _location, ptr<ASTString> const& _name) @@ -494,7 +475,7 @@ private: Declaration* m_referencedDeclaration; }; -class ElementaryTypeNameExpression : public PrimaryExpression +class ElementaryTypeNameExpression: public PrimaryExpression { public: ElementaryTypeNameExpression(Location const& _location, Token::Value _typeToken) @@ -507,12 +488,11 @@ private: Token::Value m_typeToken; }; -class Literal : public PrimaryExpression +class Literal: public PrimaryExpression { public: Literal(Location const& _location, Token::Value _token, ptr<ASTString> const& _value) - : PrimaryExpression(_location), m_token(_token), m_value(_value) - {} + : PrimaryExpression(_location), m_token(_token), m_value(_value) {} virtual void accept(ASTVisitor& _visitor) override; virtual ptr<Type> checkTypeRequirements() override; |