diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-21 00:50:26 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-25 21:26:05 +0800 |
commit | 9d6d7ccab86da43da03b79f7b74bf7146c0c0b14 (patch) | |
tree | 63ac5a52c0064df5a9a87644a8638beb7f3424c2 /AST.h | |
parent | 8f8e407306172ab75f5b200c1f1df87bb55fa2a6 (diff) | |
download | dexon-solidity-9d6d7ccab86da43da03b79f7b74bf7146c0c0b14.tar.gz dexon-solidity-9d6d7ccab86da43da03b79f7b74bf7146c0c0b14.tar.zst dexon-solidity-9d6d7ccab86da43da03b79f7b74bf7146c0c0b14.zip |
Parsing of not fully implemented functions
- Adding the possibility of omitting a function body by simply ending a
function definition with a semicolon
- Such a function is marked as not fully implemented and any contract
that contains such a function is considered a not fully implemented contract
Diffstat (limited to 'AST.h')
-rw-r--r-- | AST.h | 85 |
1 files changed, 55 insertions, 30 deletions
@@ -196,6 +196,21 @@ protected: ASTPointer<ASTString> m_documentation; }; +/** + * Abstract class that is added to AST nodes that can be marked as not being fully implemented + */ +class ImplementationOptional +{ +public: + explicit ImplementationOptional(bool _implemented): m_implemented(_implemented) {} + + /// @return whether this node is fully implemented or not + bool isFullyImplemented() const { return m_implemented; } + +protected: + bool m_implemented; +}; + /// @} /** @@ -203,20 +218,25 @@ protected: * document order. It first visits all struct declarations, then all variable declarations and * finally all function declarations. */ -class ContractDefinition: public Declaration, public Documented +class ContractDefinition: public Declaration, public Documented, public ImplementationOptional { public: - ContractDefinition(SourceLocation const& _location, - ASTPointer<ASTString> const& _name, - ASTPointer<ASTString> const& _documentation, - std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts, - std::vector<ASTPointer<StructDefinition>> const& _definedStructs, - std::vector<ASTPointer<EnumDefinition>> const& _definedEnums, - std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables, - std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions, - std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers, - std::vector<ASTPointer<EventDefinition>> const& _events): - Declaration(_location, _name), Documented(_documentation), + ContractDefinition( + SourceLocation const& _location, + ASTPointer<ASTString> const& _name, + ASTPointer<ASTString> const& _documentation, + std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts, + std::vector<ASTPointer<StructDefinition>> const& _definedStructs, + std::vector<ASTPointer<EnumDefinition>> const& _definedEnums, + std::vector<ASTPointer<VariableDeclaration>> const& _stateVariables, + std::vector<ASTPointer<FunctionDefinition>> const& _definedFunctions, + std::vector<ASTPointer<ModifierDefinition>> const& _functionModifiers, + std::vector<ASTPointer<EventDefinition>> const& _events, + bool _isFullyImplemented + ): + Declaration(_location, _name), + Documented(_documentation), + ImplementationOptional(_isFullyImplemented), m_baseContracts(_baseContracts), m_definedStructs(_definedStructs), m_definedEnums(_definedEnums), @@ -224,7 +244,7 @@ public: m_definedFunctions(_definedFunctions), m_functionModifiers(_functionModifiers), m_events(_events) - {} + {} virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTConstVisitor& _visitor) const override; @@ -378,25 +398,30 @@ private: std::vector<ASTPointer<VariableDeclaration>> m_parameters; }; -class FunctionDefinition: public Declaration, public VariableScope, public Documented +class FunctionDefinition: public Declaration, public VariableScope, public Documented, public ImplementationOptional { public: - FunctionDefinition(SourceLocation const& _location, ASTPointer<ASTString> const& _name, - Declaration::Visibility _visibility, bool _isConstructor, - ASTPointer<ASTString> const& _documentation, - ASTPointer<ParameterList> const& _parameters, - bool _isDeclaredConst, - std::vector<ASTPointer<ModifierInvocation>> const& _modifiers, - ASTPointer<ParameterList> const& _returnParameters, - ASTPointer<Block> const& _body): - Declaration(_location, _name, _visibility), Documented(_documentation), - m_isConstructor(_isConstructor), - m_parameters(_parameters), - m_isDeclaredConst(_isDeclaredConst), - m_functionModifiers(_modifiers), - m_returnParameters(_returnParameters), - m_body(_body) - {} + FunctionDefinition( + SourceLocation const& _location, + ASTPointer<ASTString> const& _name, + Declaration::Visibility _visibility, bool _isConstructor, + ASTPointer<ASTString> const& _documentation, + ASTPointer<ParameterList> const& _parameters, + bool _isDeclaredConst, + std::vector<ASTPointer<ModifierInvocation>> const& _modifiers, + ASTPointer<ParameterList> const& _returnParameters, + ASTPointer<Block> const& _body + ): + Declaration(_location, _name, _visibility), + Documented(_documentation), + ImplementationOptional(_body != nullptr), + m_isConstructor(_isConstructor), + m_parameters(_parameters), + m_isDeclaredConst(_isDeclaredConst), + m_functionModifiers(_modifiers), + m_returnParameters(_returnParameters), + m_body(_body) + {} virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTConstVisitor& _visitor) const override; |