Small cleanup.

This commit is contained in:
Christian 2015-02-09 00:49:35 +01:00
parent a66db516fb
commit 106cda74f8
3 changed files with 10 additions and 14 deletions

18
AST.cpp
View File

@ -478,7 +478,7 @@ void FunctionCall::checkTypeRequirements()
if (m_arguments.size() != 1) if (m_arguments.size() != 1)
BOOST_THROW_EXCEPTION(createTypeError("More than one argument for explicit type conversion.")); BOOST_THROW_EXCEPTION(createTypeError("More than one argument for explicit type conversion."));
if (!m_names.empty()) if (!m_names.empty())
BOOST_THROW_EXCEPTION(createTypeError("Type conversion can't allow named arguments.")); BOOST_THROW_EXCEPTION(createTypeError("Type conversion cannot allow named arguments."));
if (!m_arguments.front()->getType()->isExplicitlyConvertibleTo(*type.getActualType())) if (!m_arguments.front()->getType()->isExplicitlyConvertibleTo(*type.getActualType()))
BOOST_THROW_EXCEPTION(createTypeError("Explicit type conversion not allowed.")); BOOST_THROW_EXCEPTION(createTypeError("Explicit type conversion not allowed."));
m_type = type.getActualType(); m_type = type.getActualType();
@ -497,23 +497,21 @@ void FunctionCall::checkTypeRequirements()
for (size_t i = 0; i < m_arguments.size(); ++i) for (size_t i = 0; i < m_arguments.size(); ++i)
if (functionType->getLocation() != FunctionType::Location::SHA3 && if (functionType->getLocation() != FunctionType::Location::SHA3 &&
!m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i])) !m_arguments[i]->getType()->isImplicitlyConvertibleTo(*parameterTypes[i]))
BOOST_THROW_EXCEPTION(createTypeError("Invalid type for argument in function call.")); BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError("Invalid type for argument in function call."));
} }
else if (functionType->getLocation() == FunctionType::Location::SHA3)
BOOST_THROW_EXCEPTION(createTypeError("Named arguments can't be used for SHA3."));
else else
{ {
if (functionType->getLocation() == FunctionType::Location::SHA3)
BOOST_THROW_EXCEPTION(createTypeError("Named arguments cannnot be used for SHA3."));
auto const& parameterNames = functionType->getParameterNames(); auto const& parameterNames = functionType->getParameterNames();
if (parameterNames.size() != m_names.size()) if (parameterNames.size() != m_names.size())
BOOST_THROW_EXCEPTION(createTypeError("Some argument names are missing.")); BOOST_THROW_EXCEPTION(createTypeError("Some argument names are missing."));
// check duplicate names // check duplicate names
for (size_t i = 0; i < m_names.size(); i++) { for (size_t i = 0; i < m_names.size(); i++)
for (size_t j = i + 1; j < m_names.size(); j++) { for (size_t j = i + 1; j < m_names.size(); j++)
if (*m_names[i] == *m_names[j]) if (*m_names[i] == *m_names[j])
BOOST_THROW_EXCEPTION(createTypeError("Duplicate named argument.")); BOOST_THROW_EXCEPTION(m_arguments[i]->createTypeError("Duplicate named argument."));
}
}
for (size_t i = 0; i < m_names.size(); i++) { for (size_t i = 0; i < m_names.size(); i++) {
bool found = false; bool found = false;
@ -528,7 +526,7 @@ void FunctionCall::checkTypeRequirements()
} }
} }
if (!found) if (!found)
BOOST_THROW_EXCEPTION(createTypeError("Named argument doesn't match function declaration.")); BOOST_THROW_EXCEPTION(createTypeError("Named argument does not match function declaration."));
} }
} }

View File

@ -360,7 +360,7 @@ u256 IntegerConstantType::literalValue(Literal const*) const
TypePointer IntegerConstantType::getRealType() const TypePointer IntegerConstantType::getRealType() const
{ {
auto intType = getIntegerType(); auto intType = getIntegerType();
solAssert(!!intType, std::string("getRealType called with invalid integer constant") + toString()); solAssert(!!intType, "getRealType called with invalid integer constant " + toString());
return intType; return intType;
} }

View File

@ -177,7 +177,6 @@ public:
virtual MemberList const& getMembers() const { return isAddress() ? AddressMemberList : EmptyMemberList; } virtual MemberList const& getMembers() const { return isAddress() ? AddressMemberList : EmptyMemberList; }
virtual std::string toString() const override; virtual std::string toString() const override;
virtual TypePointer getRealType() const { return std::make_shared<IntegerType>(m_bits, m_modifier); }
int getNumBits() const { return m_bits; } int getNumBits() const { return m_bits; }
bool isHash() const { return m_modifier == Modifier::HASH || m_modifier == Modifier::ADDRESS; } bool isHash() const { return m_modifier == Modifier::HASH || m_modifier == Modifier::ADDRESS; }
@ -248,7 +247,6 @@ public:
virtual std::string toString() const override { return "string" + dev::toString(m_bytes); } virtual std::string toString() const override { return "string" + dev::toString(m_bytes); }
virtual u256 literalValue(Literal const* _literal) const override; virtual u256 literalValue(Literal const* _literal) const override;
virtual TypePointer getRealType() const override { return std::make_shared<StaticStringType>(m_bytes); }
int getNumBytes() const { return m_bytes; } int getNumBytes() const { return m_bytes; }