diff options
author | chriseth <c@ethdev.com> | 2015-10-26 22:13:36 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-26 22:24:36 +0800 |
commit | b4f561680a2a5169d1245271245e2b71822cb73a (patch) | |
tree | 6e3acecc9bbe825400e4297a32ff641df27d1943 /libsolidity/ast | |
parent | d6e77ce0e1da577e5f2c000f89b4fba3505d84a0 (diff) | |
download | dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.tar.gz dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.tar.zst dexon-solidity-b4f561680a2a5169d1245271245e2b71822cb73a.zip |
Store docstrings in AST annotations.
Diffstat (limited to 'libsolidity/ast')
-rw-r--r-- | libsolidity/ast/AST.cpp | 21 | ||||
-rw-r--r-- | libsolidity/ast/AST.h | 6 | ||||
-rw-r--r-- | libsolidity/ast/ASTAnnotations.h | 27 |
3 files changed, 53 insertions, 1 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 71d80a36..9d1fb811 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -248,16 +248,37 @@ string FunctionDefinition::externalSignature() const return FunctionType(*this).externalSignature(); } +FunctionDefinitionAnnotation& FunctionDefinition::annotation() const +{ + if (!m_annotation) + m_annotation = new FunctionDefinitionAnnotation(); + return static_cast<FunctionDefinitionAnnotation&>(*m_annotation); +} + TypePointer ModifierDefinition::type(ContractDefinition const*) const { return make_shared<ModifierType>(*this); } +ModifierDefinitionAnnotation& ModifierDefinition::annotation() const +{ + if (!m_annotation) + m_annotation = new ModifierDefinitionAnnotation(); + return static_cast<ModifierDefinitionAnnotation&>(*m_annotation); +} + TypePointer EventDefinition::type(ContractDefinition const*) const { return make_shared<FunctionType>(*this); } +EventDefinitionAnnotation& EventDefinition::annotation() const +{ + if (!m_annotation) + m_annotation = new EventDefinitionAnnotation(); + return static_cast<EventDefinitionAnnotation&>(*m_annotation); +} + UserDefinedTypeNameAnnotation& UserDefinedTypeName::annotation() const { if (!m_annotation) diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index 3fe447eb..6a593d3e 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -492,6 +492,8 @@ public: virtual TypePointer type(ContractDefinition const* m_currentContract) const override; + virtual FunctionDefinitionAnnotation& annotation() const override; + private: bool m_isConstructor; bool m_isDeclaredConst; @@ -593,6 +595,8 @@ public: virtual TypePointer type(ContractDefinition const* m_currentContract) const override; + virtual ModifierDefinitionAnnotation& annotation() const override; + private: ASTPointer<Block> m_body; }; @@ -647,6 +651,8 @@ public: virtual TypePointer type(ContractDefinition const* m_currentContract) const override; + virtual EventDefinitionAnnotation& annotation() const override; + private: bool m_anonymous = false; }; diff --git a/libsolidity/ast/ASTAnnotations.h b/libsolidity/ast/ASTAnnotations.h index d112b1ef..094a178e 100644 --- a/libsolidity/ast/ASTAnnotations.h +++ b/libsolidity/ast/ASTAnnotations.h @@ -41,13 +41,26 @@ struct ASTAnnotation virtual ~ASTAnnotation() {} }; +struct DocTag +{ + std::string content; ///< The text content of the tag. + std::string paramName; ///< Only used for @param, stores the parameter name. +}; + +struct DocumentedAnnotation +{ + virtual ~DocumentedAnnotation() {} + /// Mapping docstring tag name -> content. + std::multimap<std::string, DocTag> docTags; +}; + struct TypeDeclarationAnnotation: ASTAnnotation { /// The name of this type, prefixed by proper namespaces if globally accessible. std::string canonicalName; }; -struct ContractDefinitionAnnotation: TypeDeclarationAnnotation +struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, DocumentedAnnotation { /// Whether all functions are implemented. bool isFullyImplemented = true; @@ -59,6 +72,18 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation std::set<ContractDefinition const*> contractDependencies; }; +struct FunctionDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation +{ +}; + +struct EventDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation +{ +}; + +struct ModifierDefinitionAnnotation: ASTAnnotation, DocumentedAnnotation +{ +}; + struct VariableDeclarationAnnotation: ASTAnnotation { /// Type of variable (type of identifier referencing this variable). |