aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/ASTJsonConverter.cpp2
-rw-r--r--libsolidity/ast/ExperimentalFeatures.h3
-rw-r--r--libsolidity/ast/Types.cpp37
-rw-r--r--libsolidity/ast/Types.h2
4 files changed, 25 insertions, 19 deletions
diff --git a/libsolidity/ast/ASTJsonConverter.cpp b/libsolidity/ast/ASTJsonConverter.cpp
index a8ede66a..72b20b3b 100644
--- a/libsolidity/ast/ASTJsonConverter.cpp
+++ b/libsolidity/ast/ASTJsonConverter.cpp
@@ -126,7 +126,7 @@ string ASTJsonConverter::sourceLocationToString(SourceLocation const& _location)
int length = -1;
if (_location.start >= 0 && _location.end >= 0)
length = _location.end - _location.start;
- return std::to_string(_location.start) + ":" + std::to_string(length) + ":" + std::to_string(sourceIndex);
+ return to_string(_location.start) + ":" + to_string(length) + ":" + to_string(sourceIndex);
}
string ASTJsonConverter::namePathToString(std::vector<ASTString> const& _namePath)
diff --git a/libsolidity/ast/ExperimentalFeatures.h b/libsolidity/ast/ExperimentalFeatures.h
index c66a3659..54aad573 100644
--- a/libsolidity/ast/ExperimentalFeatures.h
+++ b/libsolidity/ast/ExperimentalFeatures.h
@@ -31,7 +31,6 @@ enum class ExperimentalFeature
{
ABIEncoderV2, // new ABI encoder that makes use of Yul
SMTChecker,
- V050, // v0.5.0 breaking changes
Test,
TestOnlyAnalysis
};
@@ -40,14 +39,12 @@ static const std::map<ExperimentalFeature, bool> ExperimentalFeatureOnlyAnalysis
{
{ ExperimentalFeature::SMTChecker, true },
{ ExperimentalFeature::TestOnlyAnalysis, true },
- { ExperimentalFeature::V050, true }
};
static const std::map<std::string, ExperimentalFeature> ExperimentalFeatureNames =
{
{ "ABIEncoderV2", ExperimentalFeature::ABIEncoderV2 },
{ "SMTChecker", ExperimentalFeature::SMTChecker },
- { "v0.5.0", ExperimentalFeature::V050 },
{ "__test", ExperimentalFeature::Test },
{ "__testOnlyAnalysis", ExperimentalFeature::TestOnlyAnalysis },
};
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 0094c5ed..3dbbca91 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -255,6 +255,17 @@ string Type::escapeIdentifier(string const& _identifier)
return ret;
}
+string Type::identifier() const
+{
+ string ret = escapeIdentifier(richIdentifier());
+ solAssert(ret.find_first_of("0123456789") != 0, "Identifier cannot start with a number.");
+ solAssert(
+ ret.find_first_not_of("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMONPQRSTUVWXYZ_$") == string::npos,
+ "Identifier contains invalid characters."
+ );
+ return ret;
+}
+
TypePointer Type::fromElementaryTypeName(ElementaryTypeNameToken const& _type)
{
solAssert(Token::isElementaryTypeName(_type.token()),
@@ -468,7 +479,7 @@ string IntegerType::richIdentifier() const
if (isAddress())
return "t_address";
else
- return "t_" + string(isSigned() ? "" : "u") + "int" + std::to_string(numBits());
+ return "t_" + string(isSigned() ? "" : "u") + "int" + to_string(numBits());
}
bool IntegerType::isImplicitlyConvertibleTo(Type const& _convertTo) const
@@ -634,7 +645,7 @@ FixedPointType::FixedPointType(unsigned _totalBits, unsigned _fractionalDigits,
string FixedPointType::richIdentifier() const
{
- return "t_" + string(isSigned() ? "" : "u") + "fixed" + std::to_string(m_totalBits) + "x" + std::to_string(m_fractionalDigits);
+ return "t_" + string(isSigned() ? "" : "u") + "fixed" + to_string(m_totalBits) + "x" + to_string(m_fractionalDigits);
}
bool FixedPointType::isImplicitlyConvertibleTo(Type const& _convertTo) const
@@ -1383,7 +1394,7 @@ MemberList::MemberMap FixedBytesType::nativeMembers(const ContractDefinition*) c
string FixedBytesType::richIdentifier() const
{
- return "t_bytes" + std::to_string(m_bytes);
+ return "t_bytes" + to_string(m_bytes);
}
bool FixedBytesType::operator==(Type const& _other) const
@@ -1826,7 +1837,7 @@ TypePointer ArrayType::copyForLocation(DataLocation _location, bool _isPointer)
string ContractType::richIdentifier() const
{
- return (m_super ? "t_super" : "t_contract") + parenthesizeUserIdentifier(m_contract.name()) + std::to_string(m_contract.id());
+ return (m_super ? "t_super" : "t_contract") + parenthesizeUserIdentifier(m_contract.name()) + to_string(m_contract.id());
}
bool ContractType::operator==(Type const& _other) const
@@ -1940,7 +1951,7 @@ bool StructType::isImplicitlyConvertibleTo(const Type& _convertTo) const
string StructType::richIdentifier() const
{
- return "t_struct" + parenthesizeUserIdentifier(m_struct.name()) + std::to_string(m_struct.id()) + identifierLocationSuffix();
+ return "t_struct" + parenthesizeUserIdentifier(m_struct.name()) + to_string(m_struct.id()) + identifierLocationSuffix();
}
bool StructType::operator==(Type const& _other) const
@@ -2166,7 +2177,7 @@ TypePointer EnumType::unaryOperatorResult(Token::Value _operator) const
string EnumType::richIdentifier() const
{
- return "t_enum" + parenthesizeUserIdentifier(m_enum.name()) + std::to_string(m_enum.id());
+ return "t_enum" + parenthesizeUserIdentifier(m_enum.name()) + to_string(m_enum.id());
}
bool EnumType::operator==(Type const& _other) const
@@ -2297,16 +2308,14 @@ TypePointer TupleType::closestTemporaryType(TypePointer const& _targetType) cons
{
solAssert(!!_targetType, "");
TypePointers const& targetComponents = dynamic_cast<TupleType const&>(*_targetType).components();
- bool fillRight = !targetComponents.empty() && (!targetComponents.back() || targetComponents.front());
+ solAssert(components().size() == targetComponents.size(), "");
TypePointers tempComponents(targetComponents.size());
- for (size_t i = 0; i < min(targetComponents.size(), components().size()); ++i)
+ for (size_t i = 0; i < targetComponents.size(); ++i)
{
- size_t si = fillRight ? i : components().size() - i - 1;
- size_t ti = fillRight ? i : targetComponents.size() - i - 1;
- if (components()[si] && targetComponents[ti])
+ if (components()[i] && targetComponents[i])
{
- tempComponents[ti] = components()[si]->closestTemporaryType(targetComponents[ti]);
- solAssert(tempComponents[ti], "");
+ tempComponents[i] = components()[i]->closestTemporaryType(targetComponents[i]);
+ solAssert(tempComponents[i], "");
}
}
return make_shared<TupleType>(tempComponents);
@@ -3138,7 +3147,7 @@ string ModifierType::toString(bool _short) const
string ModuleType::richIdentifier() const
{
- return "t_module_" + std::to_string(m_sourceUnit.id());
+ return "t_module_" + to_string(m_sourceUnit.id());
}
bool ModuleType::operator==(Type const& _other) const
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index 09323d05..1fa2b2f5 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -172,7 +172,7 @@ public:
/// only if they have the same identifier.
/// The identifier should start with "t_".
/// Will not contain any character which would be invalid as an identifier.
- std::string identifier() const { return escapeIdentifier(richIdentifier()); }
+ std::string identifier() const;
/// More complex identifier strings use "parentheses", where $_ is interpreted as as
/// "opening parenthesis", _$ as "closing parenthesis", _$_ as "comma" and any $ that