mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
libsolidity: Be more restrictive to not allow any copy constructors at all in Type system.
This enforces us to be a little bit more historical in how to initialize our std::array<>'s in TypeProvider.
This commit is contained in:
parent
a2a3b007f3
commit
59d4f54729
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
#include <libsolidity/ast/AST.h>
|
#include <libsolidity/ast/AST.h>
|
||||||
#include <libsolidity/ast/TypeProvider.h>
|
#include <libsolidity/ast/TypeProvider.h>
|
||||||
#include <libdevcore/make_array.h>
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/split.hpp>
|
#include <boost/algorithm/string/split.hpp>
|
||||||
|
|
||||||
@ -25,18 +24,6 @@ using namespace std;
|
|||||||
using namespace dev;
|
using namespace dev;
|
||||||
using namespace solidity;
|
using namespace solidity;
|
||||||
|
|
||||||
template <size_t... N>
|
|
||||||
constexpr array<IntegerType, sizeof...(N)> createIntegerTypes(IntegerType::Modifier _modifier, index_sequence<N...>)
|
|
||||||
{
|
|
||||||
return make_array<IntegerType>(IntegerType((static_cast<unsigned>(N) + 1) * 8, _modifier)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t... N>
|
|
||||||
constexpr array<FixedBytesType, sizeof...(N)> createFixedBytesTypes(index_sequence<N...>)
|
|
||||||
{
|
|
||||||
return make_array<FixedBytesType>(FixedBytesType(static_cast<unsigned>(N) + 1)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
BoolType const TypeProvider::m_boolType{};
|
BoolType const TypeProvider::m_boolType{};
|
||||||
InaccessibleDynamicType const TypeProvider::m_inaccessibleDynamicType{};
|
InaccessibleDynamicType const TypeProvider::m_inaccessibleDynamicType{};
|
||||||
ArrayType const TypeProvider::m_bytesStorageType{DataLocation::Storage, false};
|
ArrayType const TypeProvider::m_bytesStorageType{DataLocation::Storage, false};
|
||||||
@ -46,9 +33,112 @@ ArrayType const TypeProvider::m_stringMemoryType{DataLocation::Memory, true};
|
|||||||
TupleType const TypeProvider::m_emptyTupleType{};
|
TupleType const TypeProvider::m_emptyTupleType{};
|
||||||
AddressType const TypeProvider::m_payableAddressType{StateMutability::Payable};
|
AddressType const TypeProvider::m_payableAddressType{StateMutability::Payable};
|
||||||
AddressType const TypeProvider::m_addressType{StateMutability::NonPayable};
|
AddressType const TypeProvider::m_addressType{StateMutability::NonPayable};
|
||||||
array<IntegerType, 32> const TypeProvider::m_intM{createIntegerTypes(IntegerType::Modifier::Signed, make_index_sequence<32>{})};
|
|
||||||
array<IntegerType, 32> const TypeProvider::m_uintM{createIntegerTypes(IntegerType::Modifier::Unsigned, make_index_sequence<32>{})};
|
array<IntegerType, 32> const TypeProvider::m_intM{
|
||||||
array<FixedBytesType, 32> const TypeProvider::m_bytesM{createFixedBytesTypes(make_index_sequence<32>{})};
|
IntegerType{8 * 1, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 2, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 3, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 4, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 5, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 6, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 7, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 8, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 9, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 10, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 11, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 12, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 13, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 14, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 15, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 16, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 17, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 18, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 19, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 20, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 21, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 22, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 23, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 24, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 25, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 26, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 27, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 28, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 29, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 30, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 31, IntegerType::Modifier::Signed},
|
||||||
|
IntegerType{8 * 32, IntegerType::Modifier::Signed}
|
||||||
|
};
|
||||||
|
|
||||||
|
array<IntegerType, 32> const TypeProvider::m_uintM{
|
||||||
|
IntegerType{8 * 1, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 2, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 3, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 4, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 5, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 6, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 7, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 8, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 9, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 10, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 11, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 12, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 13, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 14, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 15, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 16, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 17, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 18, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 19, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 20, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 21, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 22, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 23, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 24, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 25, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 26, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 27, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 28, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 29, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 30, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 31, IntegerType::Modifier::Unsigned},
|
||||||
|
IntegerType{8 * 32, IntegerType::Modifier::Unsigned}
|
||||||
|
};
|
||||||
|
|
||||||
|
array<FixedBytesType, 32> const TypeProvider::m_bytesM{
|
||||||
|
FixedBytesType{1},
|
||||||
|
FixedBytesType{2},
|
||||||
|
FixedBytesType{3},
|
||||||
|
FixedBytesType{4},
|
||||||
|
FixedBytesType{5},
|
||||||
|
FixedBytesType{6},
|
||||||
|
FixedBytesType{7},
|
||||||
|
FixedBytesType{8},
|
||||||
|
FixedBytesType{9},
|
||||||
|
FixedBytesType{10},
|
||||||
|
FixedBytesType{11},
|
||||||
|
FixedBytesType{12},
|
||||||
|
FixedBytesType{13},
|
||||||
|
FixedBytesType{14},
|
||||||
|
FixedBytesType{15},
|
||||||
|
FixedBytesType{16},
|
||||||
|
FixedBytesType{17},
|
||||||
|
FixedBytesType{18},
|
||||||
|
FixedBytesType{19},
|
||||||
|
FixedBytesType{20},
|
||||||
|
FixedBytesType{21},
|
||||||
|
FixedBytesType{22},
|
||||||
|
FixedBytesType{23},
|
||||||
|
FixedBytesType{24},
|
||||||
|
FixedBytesType{25},
|
||||||
|
FixedBytesType{26},
|
||||||
|
FixedBytesType{27},
|
||||||
|
FixedBytesType{28},
|
||||||
|
FixedBytesType{29},
|
||||||
|
FixedBytesType{30},
|
||||||
|
FixedBytesType{31},
|
||||||
|
FixedBytesType{32}
|
||||||
|
};
|
||||||
|
|
||||||
array<MagicType, 4> const TypeProvider::m_magicTypes{
|
array<MagicType, 4> const TypeProvider::m_magicTypes{
|
||||||
MagicType{MagicType::Kind::Block},
|
MagicType{MagicType::Kind::Block},
|
||||||
MagicType{MagicType::Kind::Message},
|
MagicType{MagicType::Kind::Message},
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <libdevcore/Result.h>
|
#include <libdevcore/Result.h>
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/noncopyable.hpp>
|
|
||||||
#include <boost/rational.hpp>
|
#include <boost/rational.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -155,9 +154,9 @@ class Type
|
|||||||
public:
|
public:
|
||||||
Type() = default;
|
Type() = default;
|
||||||
Type(Type const&) = delete;
|
Type(Type const&) = delete;
|
||||||
Type(Type&&) = default;
|
Type(Type&&) = delete;
|
||||||
Type& operator=(Type const&) = delete;
|
Type& operator=(Type const&) = delete;
|
||||||
Type& operator=(Type&&) = default;
|
Type& operator=(Type&&) = delete;
|
||||||
virtual ~Type() = default;
|
virtual ~Type() = default;
|
||||||
|
|
||||||
enum class Category
|
enum class Category
|
||||||
@ -382,12 +381,6 @@ public:
|
|||||||
|
|
||||||
Category category() const override { return Category::Integer; }
|
Category category() const override { return Category::Integer; }
|
||||||
|
|
||||||
IntegerType(IntegerType&&) = default;
|
|
||||||
IntegerType& operator=(IntegerType&&) = default;
|
|
||||||
IntegerType(IntegerType const&) = default;
|
|
||||||
IntegerType& operator=(IntegerType const&) = default;
|
|
||||||
~IntegerType() = default;
|
|
||||||
|
|
||||||
std::string richIdentifier() const override;
|
std::string richIdentifier() const override;
|
||||||
BoolResult isImplicitlyConvertibleTo(Type const& _convertTo) const override;
|
BoolResult isImplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||||
BoolResult isExplicitlyConvertibleTo(Type const& _convertTo) const override;
|
BoolResult isExplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||||
@ -578,12 +571,6 @@ public:
|
|||||||
|
|
||||||
Category category() const override { return Category::FixedBytes; }
|
Category category() const override { return Category::FixedBytes; }
|
||||||
|
|
||||||
FixedBytesType(FixedBytesType const&) = delete;
|
|
||||||
FixedBytesType& operator=(FixedBytesType const&) = delete;
|
|
||||||
FixedBytesType(FixedBytesType&&) = default;
|
|
||||||
FixedBytesType& operator=(FixedBytesType&&) = default;
|
|
||||||
~FixedBytesType() = default;
|
|
||||||
|
|
||||||
BoolResult isImplicitlyConvertibleTo(Type const& _convertTo) const override;
|
BoolResult isImplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||||
BoolResult isExplicitlyConvertibleTo(Type const& _convertTo) const override;
|
BoolResult isExplicitlyConvertibleTo(Type const& _convertTo) const override;
|
||||||
std::string richIdentifier() const override;
|
std::string richIdentifier() const override;
|
||||||
@ -613,8 +600,6 @@ private:
|
|||||||
class BoolType: public Type
|
class BoolType: public Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoolType() = default;
|
|
||||||
|
|
||||||
Category category() const override { return Category::Bool; }
|
Category category() const override { return Category::Bool; }
|
||||||
std::string richIdentifier() const override { return "t_bool"; }
|
std::string richIdentifier() const override { return "t_bool"; }
|
||||||
TypeResult unaryOperatorResult(Token _operator) const override;
|
TypeResult unaryOperatorResult(Token _operator) const override;
|
||||||
@ -950,8 +935,6 @@ public:
|
|||||||
explicit TupleType(std::vector<TypePointer> _types = {}): m_components(std::move(_types)) {}
|
explicit TupleType(std::vector<TypePointer> _types = {}): m_components(std::move(_types)) {}
|
||||||
|
|
||||||
Category category() const override { return Category::Tuple; }
|
Category category() const override { return Category::Tuple; }
|
||||||
TupleType(TupleType&&) = default;
|
|
||||||
TupleType& operator=(TupleType&) = default;
|
|
||||||
|
|
||||||
BoolResult isImplicitlyConvertibleTo(Type const& _other) const override;
|
BoolResult isImplicitlyConvertibleTo(Type const& _other) const override;
|
||||||
std::string richIdentifier() const override;
|
std::string richIdentifier() const override;
|
||||||
@ -1398,8 +1381,6 @@ private:
|
|||||||
class InaccessibleDynamicType: public Type
|
class InaccessibleDynamicType: public Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InaccessibleDynamicType() = default;
|
|
||||||
|
|
||||||
Category category() const override { return Category::InaccessibleDynamic; }
|
Category category() const override { return Category::InaccessibleDynamic; }
|
||||||
|
|
||||||
std::string richIdentifier() const override { return "t_inaccessible"; }
|
std::string richIdentifier() const override { return "t_inaccessible"; }
|
||||||
|
Loading…
Reference in New Issue
Block a user