Browse Source

Asterisk-syntax for doxygen class documentation.

cl-refactor
Christian 10 years ago
parent
commit
17f5470540
  1. 140
      libsolidity/AST.h
  2. 4
      libsolidity/ASTPrinter.h
  3. 24
      libsolidity/Compiler.h
  4. 19
      libsolidity/NameAndTypeResolver.h
  5. 6
      libsolidity/Scope.h
  6. 40
      libsolidity/Types.h
  7. 4
      solc/main.cpp

140
libsolidity/AST.h

@ -41,9 +41,11 @@ namespace solidity
class ASTVisitor; 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 * The root (abstract) class of the AST inheritance tree.
/// accept, providing an ASTVisitor. * 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 class ASTNode: private boost::noncopyable
{ {
public: public:
@ -77,7 +79,9 @@ private:
Location m_location; 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 class Declaration: public ASTNode
{ {
public: public:
@ -91,9 +95,11 @@ private:
ASTPointer<ASTString> m_name; 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 * Definition of a contract. This is the only AST nodes where child nodes are not visited in
/// finally all function declarations. * document order. It first visits all struct declarations, then all variable declarations and
* finally all function declarations.
*/
class ContractDefinition: public Declaration class ContractDefinition: public Declaration
{ {
public: public:
@ -133,9 +139,11 @@ private:
std::vector<ASTPointer<VariableDeclaration>> m_members; 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 * Parameter list, used as function parameter list and return list.
/// inside structs), but (@todo) this is not yet enforced. * 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 class ParameterList: public ASTNode
{ {
public: public:
@ -178,8 +186,10 @@ private:
ASTPointer<Block> m_body; ASTPointer<Block> m_body;
}; };
/// 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 class VariableDeclaration: public Declaration
{ {
public: public:
@ -205,7 +215,9 @@ private:
/// Types /// 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 class TypeName: public ASTNode
{ {
public: public:
@ -217,8 +229,10 @@ public:
virtual std::shared_ptr<Type> toType() = 0; 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 class ElementaryTypeName: public TypeName
{ {
public: public:
@ -233,8 +247,10 @@ private:
Token::Value m_type; 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 class UserDefinedTypeName: public TypeName
{ {
public: public:
@ -253,7 +269,9 @@ private:
StructDefinition* m_referencedStruct; 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 class Mapping: public TypeName
{ {
public: public:
@ -274,7 +292,9 @@ private:
/// @{ /// @{
/// Abstract base class for statements. /**
* Abstract base class for statements.
*/
class Statement: public ASTNode class Statement: public ASTNode
{ {
public: public:
@ -292,7 +312,9 @@ protected:
void expectType(Expression& _expression, Type const& _expectedType); void expectType(Expression& _expression, Type const& _expectedType);
}; };
/// Brace-enclosed block containing zero or more statements. /**
* Brace-enclosed block containing zero or more statements.
*/
class Block: public Statement class Block: public Statement
{ {
public: public:
@ -306,8 +328,10 @@ private:
std::vector<ASTPointer<Statement>> m_statements; 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 class IfStatement: public Statement
{ {
public: public:
@ -324,8 +348,10 @@ private:
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 class BreakableStatement: public Statement
{ {
public: public:
@ -380,9 +406,11 @@ private:
ParameterList* m_returnParameters; 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. * Definition of a variable as a statement inside a function. It requires a type name (which can
/// Examples: var a = 2; uint256 a; * also be "var") but the actual assignment can be missing.
* Examples: var a = 2; uint256 a;
*/
class VariableDefinition: public Statement class VariableDefinition: public Statement
{ {
public: public:
@ -397,8 +425,10 @@ private:
ASTPointer<Expression> m_value; ///< the assigned value, can be missing ASTPointer<Expression> m_value; ///< the assigned value, can be missing
}; };
/// An expression, i.e. something that has a value (which can also be of type "void" in case /**
/// of function calls). * An expression, i.e. something that has a value (which can also be of type "void" in case
* of function calls).
*/
class Expression: public Statement class Expression: public Statement
{ {
public: public:
@ -416,8 +446,10 @@ protected:
/// Expressions /// Expressions
/// @{ /// @{
/// Assignment, can also be a compound assignment. /**
/// Examples: (a = 7 + 8) or (a *= 2) * Assignment, can also be a compound assignment.
* Examples: (a = 7 + 8) or (a *= 2)
*/
class Assignment: public Expression class Assignment: public Expression
{ {
public: public:
@ -438,8 +470,10 @@ private:
ASTPointer<Expression> m_rightHandSide; 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 class UnaryOperation: public Expression
{ {
public: public:
@ -459,8 +493,10 @@ private:
bool m_isPrefix; 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 class BinaryOperation: public Expression
{ {
public: public:
@ -482,7 +518,9 @@ private:
std::shared_ptr<Type const> m_commonType; 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 class FunctionCall: public Expression
{ {
public: public:
@ -501,7 +539,9 @@ private:
std::vector<ASTPointer<Expression>> m_arguments; 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 class MemberAccess: public Expression
{ {
public: public:
@ -517,7 +557,9 @@ private:
ASTPointer<ASTString> m_memberName; ASTPointer<ASTString> m_memberName;
}; };
/// Index access to an array. Example: a[2] /**
* Index access to an array. Example: a[2]
*/
class IndexAccess: public Expression class IndexAccess: public Expression
{ {
public: public:
@ -532,15 +574,19 @@ private:
ASTPointer<Expression> m_index; ASTPointer<Expression> m_index;
}; };
/// Primary expression, i.e. an expression that cannot be divided any further. Examples are literals /**
/// or variable references. * Primary expression, i.e. an expression that cannot be divided any further. Examples are literals
* or variable references.
*/
class PrimaryExpression: public Expression class PrimaryExpression: public Expression
{ {
public: public:
PrimaryExpression(Location const& _location): Expression(_location) {} 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 class Identifier: public PrimaryExpression
{ {
public: public:
@ -561,9 +607,11 @@ private:
Declaration* m_referencedDeclaration; 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 * An elementary type name expression is used in expressions like "a = uint32(2)" to change the
/// "uint32(2)" is a @ref FunctionCall. * type of an expression explicitly. Here, "uint32" is the elementary type name expression and
* "uint32(2)" is a @ref FunctionCall.
*/
class ElementaryTypeNameExpression: public PrimaryExpression class ElementaryTypeNameExpression: public PrimaryExpression
{ {
public: public:
@ -578,7 +626,9 @@ private:
Token::Value m_typeToken; 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 class Literal: public PrimaryExpression
{ {
public: public:

4
libsolidity/ASTPrinter.h

@ -30,7 +30,9 @@ namespace dev
namespace solidity namespace solidity
{ {
/// Pretty-printer for the abstract syntax tree (the "pretty" is arguable) for debugging purposes. /**
* Pretty-printer for the abstract syntax tree (the "pretty" is arguable) for debugging purposes.
*/
class ASTPrinter: public ASTVisitor class ASTPrinter: public ASTVisitor
{ {
public: public:

24
libsolidity/Compiler.h

@ -28,9 +28,11 @@
namespace dev { namespace dev {
namespace solidity { namespace solidity {
/// A single item of compiled code that can be assembled to a single byte value in the final /**
/// bytecode. Its main purpose is to inject jump labels and label references into the opcode stream, * A single item of compiled code that can be assembled to a single byte value in the final
/// which can be resolved in the final step. * bytecode. Its main purpose is to inject jump labels and label references into the opcode stream,
* which can be resolved in the final step.
*/
class AssemblyItem class AssemblyItem
{ {
public: public:
@ -64,9 +66,11 @@ private:
using AssemblyItems = std::vector<AssemblyItem>; using AssemblyItems = std::vector<AssemblyItem>;
/// Context to be shared by all units that compile the same contract. Its current usage only /**
/// concerns dispensing unique jump label IDs and storing their actual positions in the bytecode * Context to be shared by all units that compile the same contract. Its current usage only
/// stream. * concerns dispensing unique jump label IDs and storing their actual positions in the bytecode
* stream.
*/
class CompilerContext class CompilerContext
{ {
public: public:
@ -81,9 +85,11 @@ private:
std::map<uint32_t, uint32_t> m_labelPositions; std::map<uint32_t, uint32_t> m_labelPositions;
}; };
/// Compiler for expressions, i.e. converts an AST tree whose root is an Expression into a stream /**
/// of EVM instructions. It needs a compiler context that is the same for the whole compilation * Compiler for expressions, i.e. converts an AST tree whose root is an Expression into a stream
/// unit. * of EVM instructions. It needs a compiler context that is the same for the whole compilation
* unit.
*/
class ExpressionCompiler: public ASTVisitor class ExpressionCompiler: public ASTVisitor
{ {
public: public:

19
libsolidity/NameAndTypeResolver.h

@ -33,8 +33,11 @@ namespace dev
namespace solidity namespace solidity
{ {
/// Resolves name references, resolves all types and checks that all operations are valid for the /**
/// inferred types. An exception is throw on the first error. * Resolves name references, types and checks types of all expressions.
* Specifically, it checks that all operations are valid for the inferred types.
* An exception is throw on the first error.
*/
class NameAndTypeResolver: private boost::noncopyable class NameAndTypeResolver: private boost::noncopyable
{ {
public: public:
@ -53,8 +56,10 @@ private:
Scope* m_currentScope; Scope* m_currentScope;
}; };
/// Traverses the given AST upon construction and fills _scopes with all declarations inside the /**
/// AST. * Traverses the given AST upon construction and fills _scopes with all declarations inside the
* AST.
*/
class DeclarationRegistrationHelper: private ASTVisitor class DeclarationRegistrationHelper: private ASTVisitor
{ {
public: public:
@ -78,8 +83,10 @@ private:
Scope* m_currentScope; Scope* m_currentScope;
}; };
/// Resolves references to declarations (of variables and types) and also establishes the link /**
/// between a return statement and the return parameter list. * Resolves references to declarations (of variables and types) and also establishes the link
* between a return statement and the return parameter list.
*/
class ReferencesResolver: private ASTVisitor class ReferencesResolver: private ASTVisitor
{ {
public: public:

6
libsolidity/Scope.h

@ -32,8 +32,10 @@ namespace dev
namespace solidity namespace solidity
{ {
/// Container that stores mappings betwee names and declarations. It also contains a link to the /**
/// enclosing scope. * Container that stores mappings betwee names and declarations. It also contains a link to the
* enclosing scope.
*/
class Scope class Scope
{ {
public: public:

40
libsolidity/Types.h

@ -36,7 +36,9 @@ namespace solidity
// @todo realMxN, string<N>, mapping // @todo realMxN, string<N>, mapping
/// Abstract base class that forms the root of the type hierarchy. /**
* Abstract base class that forms the root of the type hierarchy.
*/
class Type: private boost::noncopyable class Type: private boost::noncopyable
{ {
public: public:
@ -72,7 +74,9 @@ public:
virtual bytes literalToBigEndian(Literal const&) const { return NullBytes; } virtual bytes literalToBigEndian(Literal const&) const { return NullBytes; }
}; };
/// Any kind of integer type including hash and address. /**
* Any kind of integer type including hash and address.
*/
class IntegerType: public Type class IntegerType: public Type
{ {
public: public:
@ -106,7 +110,9 @@ private:
Modifier m_modifier; Modifier m_modifier;
}; };
/// The boolean type. /**
* The boolean type.
*/
class BoolType: public Type class BoolType: public Type
{ {
public: public:
@ -125,7 +131,9 @@ public:
virtual bytes literalToBigEndian(Literal const& _literal) const override; virtual bytes literalToBigEndian(Literal const& _literal) const override;
}; };
/// The type of a contract instance, there is one distinct type for each contract definition. /**
* The type of a contract instance, there is one distinct type for each contract definition.
*/
class ContractType: public Type class ContractType: public Type
{ {
public: public:
@ -140,7 +148,9 @@ private:
ContractDefinition const& m_contract; ContractDefinition const& m_contract;
}; };
/// The type of a struct instance, there is one distinct type per struct definition. /**
* The type of a struct instance, there is one distinct type per struct definition.
*/
class StructType: public Type class StructType: public Type
{ {
public: public:
@ -159,7 +169,9 @@ private:
StructDefinition const& m_struct; StructDefinition const& m_struct;
}; };
/// The type of a function, there is one distinct type per function definition. /**
* The type of a function, there is one distinct type per function definition.
*/
class FunctionType: public Type class FunctionType: public Type
{ {
public: public:
@ -176,7 +188,9 @@ private:
FunctionDefinition const& m_function; FunctionDefinition const& m_function;
}; };
/// The type of a mapping, there is one distinct type per key/value type pair. /**
* The type of a mapping, there is one distinct type per key/value type pair.
*/
class MappingType: public Type class MappingType: public Type
{ {
public: public:
@ -191,8 +205,10 @@ private:
std::shared_ptr<Type const> m_valueType; std::shared_ptr<Type const> m_valueType;
}; };
/// The void type, can only be implicitly used as the type that is returned by functions without /**
/// return parameters. * The void type, can only be implicitly used as the type that is returned by functions without
* return parameters.
*/
class VoidType: public Type class VoidType: public Type
{ {
public: public:
@ -202,8 +218,10 @@ public:
virtual std::string toString() const override { return "void"; } virtual std::string toString() const override { return "void"; }
}; };
/// The type of a type reference. The type of "uint32" when used in "a = uint32(2)" is an example /**
/// of a TypeType. * The type of a type reference. The type of "uint32" when used in "a = uint32(2)" is an example
* of a TypeType.
*/
class TypeType: public Type class TypeType: public Type
{ {
public: public:

4
solc/main.cpp

@ -36,7 +36,9 @@ void version()
} }
/// Helper class that extracts the first expression in an AST. /**
* Helper class that extracts the first expression in an AST.
*/
class FirstExpressionExtractor: private ASTVisitor class FirstExpressionExtractor: private ASTVisitor
{ {
public: public:

Loading…
Cancel
Save