diff options
author | Christian <c@ethdev.com> | 2015-01-21 18:16:18 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-01-26 17:23:39 +0800 |
commit | 19793dab093ae36b5f2b4d1cabfbf54bed3125b1 (patch) | |
tree | 94070079e892a1681fa82a0d4a9db315ce152573 /AST.h | |
parent | 570e49c03ab9e09d538218839696fc6159b0a2f1 (diff) | |
download | dexon-solidity-19793dab093ae36b5f2b4d1cabfbf54bed3125b1.tar.gz dexon-solidity-19793dab093ae36b5f2b4d1cabfbf54bed3125b1.tar.zst dexon-solidity-19793dab093ae36b5f2b4d1cabfbf54bed3125b1.zip |
Function modifier parsing.
Diffstat (limited to 'AST.h')
-rwxr-xr-x | AST.h | 53 |
1 files changed, 52 insertions, 1 deletions
@@ -161,12 +161,14 @@ public: std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts, std::vector<ASTPointer<StructDefinition>> const& _definedStructs, std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables, - std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions): + std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions, + std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers): Declaration(_location, _name), m_baseContracts(_baseContracts), m_definedStructs(_definedStructs), m_stateVariables(_stateVariables), m_definedFunctions(_definedFunctions), + m_functionModifiers(_functionModifiers), m_documentation(_documentation) {} @@ -207,6 +209,7 @@ private: std::vector<ASTPointer<StructDefinition>> m_definedStructs; std::vector<ASTPointer<VariableDeclaration>> m_stateVariables; std::vector<ASTPointer<FunctionDefinition>> m_definedFunctions; + std::vector<ASTPointer<ModifierDefinition>> m_functionModifiers; ASTPointer<ASTString> m_documentation; std::vector<ContractDefinition const*> m_linearizedBaseContracts; @@ -362,6 +365,39 @@ private: }; /** + * Definition of a function modifier. + */ +class ModifierDefinition: public Declaration +{ +public: + ModifierDefinition(Location const& _location, + ASTPointer<ASTString> const& _name, + ASTPointer<ASTString> const& _documentation, + ASTPointer<ParameterList> const& _parameters, + ASTPointer<Block> const& _body): + Declaration(_location, _name), m_documentation(_documentation), + m_parameters(_parameters), m_body(_body) {} + + virtual void accept(ASTVisitor& _visitor) override; + virtual void accept(ASTConstVisitor& _visitor) const override; + + std::vector<ASTPointer<VariableDeclaration>> const& getParameters() const { return m_parameters->getParameters(); } + ParameterList const& getParameterList() const { return *m_parameters; } + Block const& getBody() const { return *m_body; } + + /// @return A shared pointer of an ASTString. + /// Can contain a nullptr in which case indicates absence of documentation + ASTPointer<ASTString> const& getDocumentation() const { return m_documentation; } + + void checkTypeRequirements(); + +private: + ASTPointer<ASTString> m_documentation; + ASTPointer<ParameterList> m_parameters; + ASTPointer<Block> m_body; +}; + +/** * Pseudo AST node that is used as declaration for "this", "msg", "tx", "block" and the global * functions when such an identifier is encountered. Will never have a valid location in the source code. */ @@ -503,6 +539,21 @@ private: }; /** + * Special placeholder statement denoted by "_" used in function modifiers. This is replaced by + * the original function when the modifier is applied. + */ +class PlaceholderStatement: public Statement +{ +public: + PlaceholderStatement(Location const& _location): Statement(_location) {} + + virtual void accept(ASTVisitor& _visitor) override; + virtual void accept(ASTConstVisitor& _visitor) const override; + + virtual void checkTypeRequirements() override { } +}; + +/** * If-statement with an optional "else" part. Note that "else if" is modeled by having a new * if-statement as the false (else) body. */ |