diff options
author | Yoichi Hirai <i@yoichihirai.com> | 2017-01-10 23:26:13 +0800 |
---|---|---|
committer | Yoichi Hirai <i@yoichihirai.com> | 2017-01-12 02:55:50 +0800 |
commit | eda147f47bb5a0dfbed50aa2c2224daebafa76a8 (patch) | |
tree | 40d0bff7e542ba57fdaf72996a3255eb22a5159a /libsolidity/ast/AST.cpp | |
parent | e254a59bd29b7bf226197eaa836fc163be16ef09 (diff) | |
download | dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar.gz dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.tar.zst dexon-solidity-eda147f47bb5a0dfbed50aa2c2224daebafa76a8.zip |
ast: add Declaration::functionType()
Diffstat (limited to 'libsolidity/ast/AST.cpp')
-rw-r--r-- | libsolidity/ast/AST.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 78d8949c..ac92eaa3 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -274,6 +274,45 @@ TypeDeclarationAnnotation& EnumDefinition::annotation() const return static_cast<TypeDeclarationAnnotation&>(*m_annotation); } +shared_ptr<FunctionType const> FunctionDefinition::functionType(bool _internal) const +{ + if (_internal) + { + switch (visibility()) + { + case Declaration::Visibility::Default: + solAssert(false, "visibility() should not return Default"); + case Declaration::Visibility::Private: + case Declaration::Visibility::Internal: + case Declaration::Visibility::Public: + return make_shared<FunctionType const>(*this, _internal); + case Declaration::Visibility::External: + return {}; + default: + solAssert(false, "visibility() should not return a Visibility"); + } + } + else + { + switch (visibility()) + { + case Declaration::Visibility::Default: + solAssert(false, "visibility() should not return Default"); + case Declaration::Visibility::Private: + case Declaration::Visibility::Internal: + return {}; + case Declaration::Visibility::Public: + case Declaration::Visibility::External: + return make_shared<FunctionType const>(*this, _internal); + default: + solAssert(false, "visibility() should not return a Visibility"); + } + } + + // To make the compiler happy + return {}; +} + TypePointer FunctionDefinition::type() const { return make_shared<FunctionType>(*this); @@ -365,6 +404,28 @@ TypePointer VariableDeclaration::type() const return annotation().type; } +shared_ptr<FunctionType const> VariableDeclaration::functionType(bool _internal) const +{ + if (_internal) + return {}; + switch (visibility()) + { + case Declaration::Visibility::Default: + solAssert(false, "visibility() should not return Default"); + case Declaration::Visibility::Private: + case Declaration::Visibility::Internal: + return {}; + case Declaration::Visibility::Public: + case Declaration::Visibility::External: + return make_shared<FunctionType const>(*this); + default: + solAssert(false, "visibility() should not return a Visibility"); + } + + // To make the compiler happy + return {}; +} + VariableDeclarationAnnotation& VariableDeclaration::annotation() const { if (!m_annotation) |