mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Simplify if/else statements in Types
This commit is contained in:
parent
abe6eb9830
commit
3dcf089c3f
@ -525,19 +525,20 @@ bool FixedPointType::isExplicitlyConvertibleTo(Type const& _convertTo) const
|
|||||||
|
|
||||||
TypePointer FixedPointType::unaryOperatorResult(Token::Value _operator) const
|
TypePointer FixedPointType::unaryOperatorResult(Token::Value _operator) const
|
||||||
{
|
{
|
||||||
// "delete" is ok for all fixed types
|
switch(_operator)
|
||||||
if (_operator == Token::Delete)
|
{
|
||||||
|
case Token::Delete:
|
||||||
|
// "delete" is ok for all fixed types
|
||||||
return make_shared<TupleType>();
|
return make_shared<TupleType>();
|
||||||
// for fixed, we allow +, -, ++ and --
|
case Token::Add:
|
||||||
else if (
|
case Token::Sub:
|
||||||
_operator == Token::Add ||
|
case Token::Inc:
|
||||||
_operator == Token::Sub ||
|
case Token::Dec:
|
||||||
_operator == Token::Inc ||
|
// for fixed, we allow +, -, ++ and --
|
||||||
_operator == Token::Dec
|
|
||||||
)
|
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
else
|
default:
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FixedPointType::operator==(Type const& _other) const
|
bool FixedPointType::operator==(Type const& _other) const
|
||||||
@ -2354,14 +2355,26 @@ unsigned FunctionType::sizeOnStack() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned size = 0;
|
unsigned size = 0;
|
||||||
if (kind == Kind::External || kind == Kind::CallCode || kind == Kind::DelegateCall)
|
|
||||||
|
switch(kind)
|
||||||
|
{
|
||||||
|
case Kind::External:
|
||||||
|
case Kind::CallCode:
|
||||||
|
case Kind::DelegateCall:
|
||||||
size = 2;
|
size = 2;
|
||||||
else if (kind == Kind::BareCall || kind == Kind::BareCallCode || kind == Kind::BareDelegateCall)
|
break;
|
||||||
size = 1;
|
case Kind::BareCall:
|
||||||
else if (kind == Kind::Internal)
|
case Kind::BareCallCode:
|
||||||
size = 1;
|
case Kind::BareDelegateCall:
|
||||||
else if (kind == Kind::ArrayPush || kind == Kind::ByteArrayPush)
|
case Kind::Internal:
|
||||||
|
case Kind::ArrayPush:
|
||||||
|
case Kind::ByteArrayPush:
|
||||||
size = 1;
|
size = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_gasSet)
|
if (m_gasSet)
|
||||||
size++;
|
size++;
|
||||||
if (m_valueSet)
|
if (m_valueSet)
|
||||||
|
Loading…
Reference in New Issue
Block a user