diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2014-11-28 08:26:37 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2014-11-28 08:26:37 +0800 |
commit | e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166 (patch) | |
tree | a9681c93e79489ef0371b6e9191ea65bd499e809 | |
parent | 034870b4c0e7c2ea6b786e4a023dc8e64ae7314c (diff) | |
download | dexon-solidity-e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166.tar dexon-solidity-e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166.tar.gz dexon-solidity-e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166.tar.bz2 dexon-solidity-e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166.tar.lz dexon-solidity-e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166.tar.xz dexon-solidity-e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166.tar.zst dexon-solidity-e3e90c4e6bf3a5cb6399d6cfb8677d79a4a3f166.zip |
Solidity FunctionDefinition used ASTString shared ptr for docstrings
-rw-r--r-- | AST.h | 15 | ||||
-rw-r--r-- | Parser.cpp | 8 |
2 files changed, 16 insertions, 7 deletions
@@ -173,8 +173,9 @@ private: class FunctionDefinition: public Declaration { public: - FunctionDefinition(Location const& _location, ASTPointer<ASTString> const& _name, bool _isPublic, - std::string const& _documentation, + FunctionDefinition(Location const& _location, ASTPointer<ASTString> const& _name, + bool _isPublic, + ASTPointer<ASTString> const& _documentation, ASTPointer<ParameterList> const& _parameters, bool _isDeclaredConst, ASTPointer<ParameterList> const& _returnParameters, @@ -184,7 +185,9 @@ public: m_isDeclaredConst(_isDeclaredConst), m_returnParameters(_returnParameters), m_body(_body), - m_documentation(_documentation) {} + m_documentation(_documentation) + {} + virtual void accept(ASTVisitor& _visitor) override; bool isPublic() const { return m_isPublic; } @@ -194,7 +197,9 @@ public: std::vector<ASTPointer<VariableDeclaration>> const& getReturnParameters() const { return m_returnParameters->getParameters(); } ASTPointer<ParameterList> const& getReturnParameterList() const { return m_returnParameters; } Block& getBody() { return *m_body; } - std::string& getDocumentation() { return m_documentation; } + /// @return A shared pointer of an ASTString. + /// Can contain a nullptr in which case indicates absence of documentation + ASTPointer<ASTString> const& getDocumentation() { return m_documentation; } void addLocalVariable(VariableDeclaration const& _localVariable) { m_localVariables.push_back(&_localVariable); } std::vector<VariableDeclaration const*> const& getLocalVariables() const { return m_localVariables; } @@ -208,7 +213,7 @@ private: bool m_isDeclaredConst; ASTPointer<ParameterList> m_returnParameters; ASTPointer<Block> m_body; - std::string m_documentation; + ASTPointer<ASTString> m_documentation; std::vector<VariableDeclaration const*> m_localVariables; }; @@ -117,9 +117,13 @@ ASTPointer<ContractDefinition> Parser::parseContractDefinition() ASTPointer<FunctionDefinition> Parser::parseFunctionDefinition(bool _isPublic) { ASTNodeFactory nodeFactory(*this); + ASTPointer<ASTString> docstring; expectToken(Token::FUNCTION); - std::string docstring = m_scanner->getCurrentCommentLiteral(); - m_scanner->clearCurrentCommentLiteral(); + if (m_scanner->getCurrentCommentLiteral() != "") + { + docstring = std::make_shared<ASTString>(m_scanner->getCurrentCommentLiteral()); + m_scanner->clearCurrentCommentLiteral(); + } ASTPointer<ASTString> name(expectIdentifierToken()); ASTPointer<ParameterList> parameters(parseParameterList()); bool isDeclaredConst = false; |