aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-26 03:35:55 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-03-02 18:51:13 +0800
commit5e4665b84deda7943edf1fab0ab32c48c4629fac (patch)
tree26655e77e3a428539843046262886beb6b44f482 /AST.cpp
parenta5b4f18dd7291e403237061d5f9660db0299601d (diff)
downloaddexon-solidity-5e4665b84deda7943edf1fab0ab32c48c4629fac.tar.gz
dexon-solidity-5e4665b84deda7943edf1fab0ab32c48c4629fac.tar.zst
dexon-solidity-5e4665b84deda7943edf1fab0ab32c48c4629fac.zip
Adding inheritable members to a contract
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/AST.cpp b/AST.cpp
index c37e8c37..b61eb011 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -209,6 +209,33 @@ vector<pair<FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::getIn
return *m_interfaceFunctionList;
}
+vector<ASTPointer<Declaration>> const& ContractDefinition::getInheritableMembers() const
+{
+ if (!m_inheritableMembers)
+ {
+ set<string> memberSeen;
+ m_inheritableMembers.reset(new vector<ASTPointer<Declaration>>());
+ for (ContractDefinition const* contract: getLinearizedBaseContracts())
+ {
+ for (ASTPointer<FunctionDefinition> const& f: contract->getDefinedFunctions())
+ if (f->isPublic() && !f->isConstructor() && !f->getName().empty()
+ && memberSeen.count(f->getName()) == 0 && f->isVisibleInDerivedContracts())
+ {
+ memberSeen.insert(f->getName());
+ m_inheritableMembers->push_back(f);
+ }
+
+ for (ASTPointer<VariableDeclaration> const& v: contract->getStateVariables())
+ if (v->isPublic() && memberSeen.count(v->getName()) == 0)
+ {
+ memberSeen.insert(v->getName());
+ m_inheritableMembers->push_back(v);
+ }
+ }
+ }
+ return *m_inheritableMembers;
+}
+
TypePointer EnumValue::getType(ContractDefinition const*) const
{
EnumDefinition const* parentDef = dynamic_cast<EnumDefinition const*>(getScope());