aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast/AST.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-01-13 16:36:00 +0800
committerGitHub <noreply@github.com>2017-01-13 16:36:00 +0800
commitbde0b40634121e761133ff1d4c28ae7657a46149 (patch)
tree0108593b65c0650763509f14952e6cc4e18b3506 /libsolidity/ast/AST.cpp
parent14703ca002adba39e18f3f0d1aef1cf74b191349 (diff)
parentabc24420a7837557e5160db8af83ea3be5a371c3 (diff)
downloaddexon-solidity-bde0b40634121e761133ff1d4c28ae7657a46149.tar
dexon-solidity-bde0b40634121e761133ff1d4c28ae7657a46149.tar.gz
dexon-solidity-bde0b40634121e761133ff1d4c28ae7657a46149.tar.bz2
dexon-solidity-bde0b40634121e761133ff1d4c28ae7657a46149.tar.lz
dexon-solidity-bde0b40634121e761133ff1d4c28ae7657a46149.tar.xz
dexon-solidity-bde0b40634121e761133ff1d4c28ae7657a46149.tar.zst
dexon-solidity-bde0b40634121e761133ff1d4c28ae7657a46149.zip
Merge pull request #1479 from ethereum/function_variable_mixin
Disallow mixin of functions and attributes under the same name
Diffstat (limited to 'libsolidity/ast/AST.cpp')
-rw-r--r--libsolidity/ast/AST.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp
index 78d8949c..6f7a64dc 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> 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>(*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>(*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);
@@ -308,6 +347,14 @@ TypePointer EventDefinition::type() const
return make_shared<FunctionType>(*this);
}
+std::shared_ptr<FunctionType> EventDefinition::functionType(bool _internal) const
+{
+ if (_internal)
+ return make_shared<FunctionType>(*this);
+ else
+ return {};
+}
+
EventDefinitionAnnotation& EventDefinition::annotation() const
{
if (!m_annotation)
@@ -365,6 +412,28 @@ TypePointer VariableDeclaration::type() const
return annotation().type;
}
+shared_ptr<FunctionType> 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>(*this);
+ default:
+ solAssert(false, "visibility() should not return a Visibility");
+ }
+
+ // To make the compiler happy
+ return {};
+}
+
VariableDeclarationAnnotation& VariableDeclaration::annotation() const
{
if (!m_annotation)