aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-08-11 17:46:16 +0800
committerGitHub <noreply@github.com>2017-08-11 17:46:16 +0800
commita7a9ed4718654c38622b4254538c925d68a245c3 (patch)
treea7a56aacd2079df71d96b6a675ab5a04630a7d91 /libsolidity
parentbd639b9c6b627c26bea21cbf4e54fd5c0604be75 (diff)
parent3dcf089c3fd92e5f1c8323826fd5d28e470e1059 (diff)
downloaddexon-solidity-a7a9ed4718654c38622b4254538c925d68a245c3.tar.gz
dexon-solidity-a7a9ed4718654c38622b4254538c925d68a245c3.tar.zst
dexon-solidity-a7a9ed4718654c38622b4254538c925d68a245c3.zip
Merge pull request #2727 from ethereum/simplify-types
Simplify if/else statements in Types
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/ast/Types.cpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 8af60317..a66ccda5 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -525,19 +525,20 @@ bool FixedPointType::isExplicitlyConvertibleTo(Type const& _convertTo) const
TypePointer FixedPointType::unaryOperatorResult(Token::Value _operator) const
{
- // "delete" is ok for all fixed types
- if (_operator == Token::Delete)
+ switch(_operator)
+ {
+ case Token::Delete:
+ // "delete" is ok for all fixed types
return make_shared<TupleType>();
- // for fixed, we allow +, -, ++ and --
- else if (
- _operator == Token::Add ||
- _operator == Token::Sub ||
- _operator == Token::Inc ||
- _operator == Token::Dec
- )
+ case Token::Add:
+ case Token::Sub:
+ case Token::Inc:
+ case Token::Dec:
+ // for fixed, we allow +, -, ++ and --
return shared_from_this();
- else
+ default:
return TypePointer();
+ }
}
bool FixedPointType::operator==(Type const& _other) const
@@ -2355,14 +2356,26 @@ unsigned FunctionType::sizeOnStack() const
}
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;
- else if (kind == Kind::BareCall || kind == Kind::BareCallCode || kind == Kind::BareDelegateCall)
- size = 1;
- else if (kind == Kind::Internal)
- size = 1;
- else if (kind == Kind::ArrayPush || kind == Kind::ByteArrayPush)
+ break;
+ case Kind::BareCall:
+ case Kind::BareCallCode:
+ case Kind::BareDelegateCall:
+ case Kind::Internal:
+ case Kind::ArrayPush:
+ case Kind::ByteArrayPush:
size = 1;
+ break;
+ default:
+ break;
+ }
+
if (m_gasSet)
size++;
if (m_valueSet)