mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Assume that enums always take 1-byte in the codegen and type system
This commit is contained in:
parent
1bf700e088
commit
ade71d58f8
@ -2629,7 +2629,8 @@ vector<Type const*> StructType::decomposition() const
|
||||
|
||||
TypePointer EnumType::encodingType() const
|
||||
{
|
||||
return TypeProvider::uint(8 * storageBytes());
|
||||
solAssert(numberOfMembers() <= 256, "");
|
||||
return TypeProvider::uint(8);
|
||||
}
|
||||
|
||||
TypeResult EnumType::unaryOperatorResult(Token _operator) const
|
||||
@ -2652,11 +2653,8 @@ bool EnumType::operator==(Type const& _other) const
|
||||
|
||||
unsigned EnumType::storageBytes() const
|
||||
{
|
||||
size_t elements = numberOfMembers();
|
||||
if (elements <= 1)
|
||||
solAssert(numberOfMembers() <= 256, "");
|
||||
return 1;
|
||||
else
|
||||
return util::bytesRequired(elements - 1);
|
||||
}
|
||||
|
||||
string EnumType::toString(bool) const
|
||||
|
@ -203,8 +203,8 @@ string YulUtilFunctions::leftAlignFunction(Type const& _type)
|
||||
break;
|
||||
case Type::Category::Enum:
|
||||
{
|
||||
unsigned storageBytes = dynamic_cast<EnumType const&>(_type).storageBytes();
|
||||
templ("body", "aligned := " + leftAlignFunction(IntegerType(8 * storageBytes)) + "(value)");
|
||||
solAssert(dynamic_cast<EnumType const&>(_type).storageBytes() == 1, "");
|
||||
templ("body", "aligned := " + leftAlignFunction(IntegerType(8)) + "(value)");
|
||||
break;
|
||||
}
|
||||
case Type::Category::InaccessibleDynamic:
|
||||
|
Loading…
Reference in New Issue
Block a user