diff options
author | Christian <c@ethdev.com> | 2014-11-01 00:20:27 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-11-01 00:20:27 +0800 |
commit | 25c0e08bdfd955d8fdc0e7563c718b6fbba6cd1c (patch) | |
tree | 78e49ce681d0b9c5ce6d76b7dc6f445d114f918f /AST.h | |
parent | a36db1f2412d700cc8b32f8331be103c73ea90cb (diff) | |
parent | c45495afb96fcd9bf8b3ad965144a3436fc101a5 (diff) | |
download | dexon-solidity-25c0e08bdfd955d8fdc0e7563c718b6fbba6cd1c.tar.gz dexon-solidity-25c0e08bdfd955d8fdc0e7563c718b6fbba6cd1c.tar.zst dexon-solidity-25c0e08bdfd955d8fdc0e7563c718b6fbba6cd1c.zip |
Merge remote-tracking branch 'ethereum/develop' into sol_contractCompiler
Conflicts:
libsolidity/AST.cpp
libsolidity/AST.h
libsolidity/Compiler.cpp
libsolidity/Compiler.h
libsolidity/NameAndTypeResolver.h
libsolidity/Types.cpp
solc/main.cpp
test/solidityCompiler.cpp
Diffstat (limited to 'AST.h')
-rw-r--r-- | AST.h | 150 |
1 files changed, 98 insertions, 52 deletions
@@ -41,9 +41,11 @@ namespace solidity class ASTVisitor; -/// The root (abstract) class of the AST inheritance tree. -/// It is possible to traverse all direct and indirect children of an AST node by calling -/// accept, providing an ASTVisitor. +/** + * The root (abstract) class of the AST inheritance tree. + * It is possible to traverse all direct and indirect children of an AST node by calling + * accept, providing an ASTVisitor. + */ class ASTNode: private boost::noncopyable { public: @@ -77,7 +79,9 @@ private: Location m_location; }; -/// Abstract AST class for a declaration (contract, function, struct, variable). +/** + * Abstract AST class for a declaration (contract, function, struct, variable). + */ class Declaration: public ASTNode { public: @@ -85,15 +89,17 @@ public: ASTNode(_location), m_name(_name) {} /// Returns the declared name. - const ASTString& getName() const { return *m_name; } + ASTString const& getName() const { return *m_name; } private: ASTPointer<ASTString> m_name; }; -/// Definition of a contract. This is the only AST nodes where child nodes are not visited in -/// document order. It first visits all struct declarations, then all variable declarations and -/// finally all function declarations. +/** + * Definition of a contract. This is the only AST nodes where child nodes are not visited in + * document order. It first visits all struct declarations, then all variable declarations and + * finally all function declarations. + */ class ContractDefinition: public Declaration { public: @@ -133,9 +139,11 @@ private: std::vector<ASTPointer<VariableDeclaration>> m_members; }; -/// Parameter list, used as function parameter list and return list. -/// None of the parameters is allowed to contain mappings (not even recursively -/// inside structs), but (@todo) this is not yet enforced. +/** + * Parameter list, used as function parameter list and return list. + * None of the parameters is allowed to contain mappings (not even recursively + * inside structs), but (@todo) this is not yet enforced. + */ class ParameterList: public ASTNode { public: @@ -183,8 +191,10 @@ private: std::vector<VariableDeclaration const*> m_localVariables; }; -/// Declaration of a variable. This can be used in various places, e.g. in function parameter -/// lists, struct definitions and even function bodys. +/** + * Declaration of a variable. This can be used in various places, e.g. in function parameter + * lists, struct definitions and even function bodys. + */ class VariableDeclaration: public Declaration { public: @@ -196,8 +206,8 @@ public: bool isTypeGivenExplicitly() const { return bool(m_typeName); } TypeName* getTypeName() const { return m_typeName.get(); } - //! Returns the declared or inferred type. Can be an empty pointer if no type was explicitly - //! declared and there is no assignment to the variable that fixes the type. + /// Returns the declared or inferred type. Can be an empty pointer if no type was explicitly + /// declared and there is no assignment to the variable that fixes the type. std::shared_ptr<Type const> const& getType() const { return m_type; } void setType(std::shared_ptr<Type const> const& _type) { m_type = _type; } @@ -210,7 +220,9 @@ private: /// Types /// @{ -/// Abstract base class of a type name, can be any built-in or user-defined type. +/** + * Abstract base class of a type name, can be any built-in or user-defined type. + */ class TypeName: public ASTNode { public: @@ -222,8 +234,10 @@ public: virtual std::shared_ptr<Type> toType() = 0; }; -/// Any pre-defined type name represented by a single keyword, i.e. it excludes mappings, -/// contracts, functions, etc. +/** + * Any pre-defined type name represented by a single keyword, i.e. it excludes mappings, + * contracts, functions, etc. + */ class ElementaryTypeName: public TypeName { public: @@ -238,8 +252,10 @@ private: Token::Value m_type; }; -/// Name referring to a user-defined type (i.e. a struct). -/// @todo some changes are necessary if this is also used to refer to contract types later +/** + * Name referring to a user-defined type (i.e. a struct). + * @todo some changes are necessary if this is also used to refer to contract types later + */ class UserDefinedTypeName: public TypeName { public: @@ -248,7 +264,7 @@ public: virtual void accept(ASTVisitor& _visitor) override; virtual std::shared_ptr<Type> toType() override { return Type::fromUserDefinedTypeName(*this); } - const ASTString& getName() const { return *m_name; } + ASTString const& getName() const { return *m_name; } void setReferencedStruct(StructDefinition& _referencedStruct) { m_referencedStruct = &_referencedStruct; } StructDefinition const* getReferencedStruct() const { return m_referencedStruct; } @@ -258,7 +274,9 @@ private: StructDefinition* m_referencedStruct; }; -/// A mapping type. Its source form is "mapping('keyType' => 'valueType')" +/** + * A mapping type. Its source form is "mapping('keyType' => 'valueType')" + */ class Mapping: public TypeName { public: @@ -279,20 +297,24 @@ private: /// @{ -/// Abstract base class for statements. +/** + * Abstract base class for statements. + */ class Statement: public ASTNode { public: 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. - //! This includes checking that operators are applicable to their arguments but also that - //! the number of function call arguments matches the number of formal parameters and so forth. + /// Check all type requirements, throws exception if some requirement is not met. + /// This includes checking that operators are applicable to their arguments but also that + /// the number of function call arguments matches the number of formal parameters and so forth. virtual void checkTypeRequirements() = 0; }; -/// Brace-enclosed block containing zero or more statements. +/** + * Brace-enclosed block containing zero or more statements. + */ class Block: public Statement { public: @@ -306,8 +328,10 @@ private: std::vector<ASTPointer<Statement>> m_statements; }; -/// If-statement with an optional "else" part. Note that "else if" is modeled by having a new -/// if-statement as the false (else) body. +/** + * If-statement with an optional "else" part. Note that "else if" is modeled by having a new + * if-statement as the false (else) body. + */ class IfStatement: public Statement { public: @@ -324,11 +348,13 @@ public: private: ASTPointer<Expression> m_condition; ASTPointer<Statement> m_trueBody; - ASTPointer<Statement> m_falseBody; //< "else" part, optional + ASTPointer<Statement> m_falseBody; ///< "else" part, optional }; -/// Statement in which a break statement is legal. -/// @todo actually check this requirement. +/** + * Statement in which a break statement is legal. + * @todo actually check this requirement. + */ class BreakableStatement: public Statement { public: @@ -381,15 +407,17 @@ public: Expression* getExpression() const { return m_expression.get(); } private: - ASTPointer<Expression> m_expression; //< value to return, optional + ASTPointer<Expression> m_expression; ///< value to return, optional /// Pointer to the parameter list of the function, filled by the @ref NameAndTypeResolver. ParameterList* m_returnParameters; }; -/// Definition of a variable as a statement inside a function. It requires a type name (which can -/// also be "var") but the actual assignment can be missing. -/// Examples: var a = 2; uint256 a; +/** + * Definition of a variable as a statement inside a function. It requires a type name (which can + * also be "var") but the actual assignment can be missing. + * Examples: var a = 2; uint256 a; + */ class VariableDefinition: public Statement { public: @@ -477,8 +505,10 @@ private: ASTPointer<Expression> m_rightHandSide; }; -/// Operation involving a unary operator, pre- or postfix. -/// Examples: ++i, delete x or !true +/** + * Operation involving a unary operator, pre- or postfix. + * Examples: ++i, delete x or !true + */ class UnaryOperation: public Expression { public: @@ -498,8 +528,10 @@ private: bool m_isPrefix; }; -/// Operation involving a binary operator. -/// Examples: 1 + 2, true && false or 1 <= 4 +/** + * Operation involving a binary operator. + * Examples: 1 + 2, true && false or 1 <= 4 + */ class BinaryOperation: public Expression { public: @@ -521,7 +553,9 @@ private: std::shared_ptr<Type const> m_commonType; }; -/// Can be ordinary function call, type cast or struct construction. +/** + * Can be ordinary function call, type cast or struct construction. + */ class FunctionCall: public Expression { public: @@ -543,7 +577,9 @@ private: std::vector<ASTPointer<Expression>> m_arguments; }; -/// Access to a member of an object. Example: x.name +/** + * Access to a member of an object. Example: x.name + */ class MemberAccess: public Expression { public: @@ -551,7 +587,7 @@ public: ASTPointer<ASTString> const& _memberName): Expression(_location), m_expression(_expression), m_memberName(_memberName) {} virtual void accept(ASTVisitor& _visitor) override; - const ASTString& getMemberName() const { return *m_memberName; } + ASTString const& getMemberName() const { return *m_memberName; } virtual void checkTypeRequirements() override; private: @@ -559,7 +595,9 @@ private: ASTPointer<ASTString> m_memberName; }; -/// Index access to an array. Example: a[2] +/** + * Index access to an array. Example: a[2] + */ class IndexAccess: public Expression { public: @@ -574,15 +612,19 @@ private: ASTPointer<Expression> m_index; }; -/// Primary expression, i.e. an expression that do not be divided any further like a literal or -/// a variable reference. +/** + * Primary expression, i.e. an expression that cannot be divided any further. Examples are literals + * or variable references. + */ class PrimaryExpression: public Expression { public: PrimaryExpression(Location const& _location): Expression(_location) {} }; -/// An identifier, i.e. a reference to a declaration by name like a variable or function. +/** + * An identifier, i.e. a reference to a declaration by name like a variable or function. + */ class Identifier: public PrimaryExpression { public: @@ -599,13 +641,15 @@ public: private: ASTPointer<ASTString> m_name; - //! Declaration the name refers to. + /// Declaration the name refers to. Declaration* m_referencedDeclaration; }; -/// An elementary type name expression is used in expressions like "a = uint32(2)" to change the -/// type of an expression explicitly. Here, "uint32" is the elementary type name expression and -/// "uint32(2)" is a @ref FunctionCall. +/** + * An elementary type name expression is used in expressions like "a = uint32(2)" to change the + * type of an expression explicitly. Here, "uint32" is the elementary type name expression and + * "uint32(2)" is a @ref FunctionCall. + */ class ElementaryTypeNameExpression: public PrimaryExpression { public: @@ -620,7 +664,9 @@ private: Token::Value m_typeToken; }; -/// A literal string or number. @see Type::literalToBigEndian is used to actually parse its value. +/** + * A literal string or number. @see Type::literalToBigEndian is used to actually parse its value. + */ class Literal: public PrimaryExpression { public: |