aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-04-17 22:17:21 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-04-17 22:17:21 +0800
commitc558aa06567f4e6e28b8f15c3dee73867fde447b (patch)
tree80b964e954b49c636bf1e800b350c6ead64231f3 /AST.cpp
parent1a19d436db535b2ea1325b7c00295befdb8be216 (diff)
downloaddexon-solidity-c558aa06567f4e6e28b8f15c3dee73867fde447b.tar.gz
dexon-solidity-c558aa06567f4e6e28b8f15c3dee73867fde447b.tar.zst
dexon-solidity-c558aa06567f4e6e28b8f15c3dee73867fde447b.zip
Fixing detection of abstract contract
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/AST.cpp b/AST.cpp
index 1c12ef5a..5f681205 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -155,45 +155,40 @@ void ContractDefinition::checkAbstractFunctions()
void ContractDefinition::checkAbstractConstructors()
{
- set<FunctionDefinition const*> argumentsNeeded;
- set<FunctionDefinition const*> argumentsProvided;
+ set<ContractDefinition const*> argumentsNeeded;
// check that we get arguments for all base constructors that need it.
// If not mark the contract as abstract (not fully implemented)
+
vector<ContractDefinition const*> const& bases = getLinearizedBaseContracts();
for (ContractDefinition const* contract: bases)
+ if (FunctionDefinition const* constructor = contract->getConstructor())
+ if (contract != this && !constructor->getParameters().empty())
+ argumentsNeeded.insert(contract);
+
+ for (ContractDefinition const* contract: bases)
{
- FunctionDefinition const* constructor = contract->getConstructor();
- if (constructor)
- {
- if (!constructor->getParameters().empty())
- argumentsNeeded.insert(constructor);
+ if (FunctionDefinition const* constructor = contract->getConstructor())
for (auto const& modifier: constructor->getModifiers())
{
auto baseContract = dynamic_cast<ContractDefinition const*>(
- modifier->getName()->getReferencedDeclaration());
+ modifier->getName()->getReferencedDeclaration()
+ );
if (baseContract)
- {
- FunctionDefinition const* baseConstructor = baseContract->getConstructor();
- if (argumentsNeeded.count(baseConstructor) == 1)
- argumentsProvided.insert(baseConstructor);
- }
+ argumentsNeeded.erase(baseContract);
}
- }
+
for (ASTPointer<InheritanceSpecifier> const& base: contract->getBaseContracts())
{
- ContractDefinition const* baseContract = dynamic_cast<ContractDefinition const*>(
- base->getName()->getReferencedDeclaration());
+ auto baseContract = dynamic_cast<ContractDefinition const*>(
+ base->getName()->getReferencedDeclaration()
+ );
solAssert(baseContract, "");
- FunctionDefinition const* baseConstructor = baseContract->getConstructor();
- if (argumentsNeeded.count(baseConstructor) == 1)
- argumentsProvided.insert(baseConstructor);
+ if (!base->getArguments().empty())
+ argumentsNeeded.erase(baseContract);
}
}
- // add this contract's constructor to the provided too
- if (getConstructor() && !getConstructor()->getParameters().empty())
- argumentsProvided.insert(getConstructor());
- if (argumentsProvided != argumentsNeeded)
+ if (!argumentsNeeded.empty())
setFullyImplemented(false);
}