aboutsummaryrefslogtreecommitdiffstats
path: root/AST.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-20 04:05:47 +0800
committerChristian <c@ethdev.com>2015-01-20 06:35:04 +0800
commitaf92f98d86ba1e15e3f41ac49bb9639be1ab4e41 (patch)
treee42cff46c9701491a43e58bebd8ead5b3e5241ec /AST.cpp
parent6e111d5d1da2a0ae397fa2bd846d13132cdd6dd9 (diff)
downloaddexon-solidity-af92f98d86ba1e15e3f41ac49bb9639be1ab4e41.tar.gz
dexon-solidity-af92f98d86ba1e15e3f41ac49bb9639be1ab4e41.tar.zst
dexon-solidity-af92f98d86ba1e15e3f41ac49bb9639be1ab4e41.zip
Constructor arguments for base classes.
Diffstat (limited to 'AST.cpp')
-rw-r--r--AST.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/AST.cpp b/AST.cpp
index e0ee5c09..2cb738d3 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -43,6 +43,9 @@ TypeError ASTNode::createTypeError(string const& _description) const
void ContractDefinition::checkTypeRequirements()
{
+ for (ASTPointer<InheritanceSpecifier> const& base: getBaseContracts())
+ base->checkTypeRequirements();
+
checkIllegalOverrides();
FunctionDefinition const* constructor = getConstructor();
@@ -123,6 +126,22 @@ vector<pair<FixedHash<4>, FunctionDefinition const*>> const& ContractDefinition:
return *m_interfaceFunctionList;
}
+void InheritanceSpecifier::checkTypeRequirements()
+{
+ m_baseName->checkTypeRequirements();
+ for (ASTPointer<Expression> const& argument: m_arguments)
+ argument->checkTypeRequirements();
+
+ ContractDefinition const* base = dynamic_cast<ContractDefinition const*>(m_baseName->getReferencedDeclaration());
+ solAssert(base, "Base contract not available.");
+ TypePointers parameterTypes = ContractType(*base).getConstructorType()->getParameterTypes();
+ if (parameterTypes.size() != m_arguments.size())
+ BOOST_THROW_EXCEPTION(createTypeError("Wrong argument count for constructor call."));
+ for (size_t i = 0; i < m_arguments.size(); ++i)
+ if (!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i]))
+ BOOST_THROW_EXCEPTION(createTypeError("Invalid type for argument in constructer call."));
+}
+
void StructDefinition::checkMemberTypes() const
{
for (ASTPointer<VariableDeclaration> const& member: getMembers())