aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-09-25 16:41:04 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-09-25 17:57:21 +0800
commitcb6cdfe7801a3362a489d0fd39cc0ce5a7075fea (patch)
tree706860e394392df3956dc148ef4b8ba5d2cdd23d /libsolidity
parent74972f5fa6c0e59a5178e17ebdb48453528c7169 (diff)
downloaddexon-solidity-cb6cdfe7801a3362a489d0fd39cc0ce5a7075fea.tar.gz
dexon-solidity-cb6cdfe7801a3362a489d0fd39cc0ce5a7075fea.tar.zst
dexon-solidity-cb6cdfe7801a3362a489d0fd39cc0ce5a7075fea.zip
Simplify switch statements by refactoring internal break statements
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp12
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp36
2 files changed, 24 insertions, 24 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 4d273b87..c1171c1d 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -596,7 +596,6 @@ void CompilerUtils::convertType(
storeInMemoryDynamic(IntegerType(256));
// stack: mempos datapos
storeStringData(data);
- break;
}
else
solAssert(
@@ -820,15 +819,16 @@ void CompilerUtils::convertType(
// stack: <address> <function_id>
m_context << Instruction::POP;
- break;
}
-
- // All other types should not be convertible to non-equal types.
- solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
- if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
+ else
+ {
+ // All other types should not be convertible to non-equal types.
+ solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
+ if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
m_context
<< ((u256(1) << (8 * _targetType.storageBytes())) - 1)
<< Instruction::AND;
+ }
break;
}
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 63d7f1e6..b286594a 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1051,26 +1051,26 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
else
alsoSearchInteger = true;
- if (!alsoSearchInteger)
- break;
-
- if (member == "balance")
+ if (alsoSearchInteger)
{
- utils().convertType(
- *_memberAccess.expression().annotation().type,
- IntegerType(0, IntegerType::Modifier::Address),
- true
- );
- m_context << Instruction::BALANCE;
+ if (member == "balance")
+ {
+ utils().convertType(
+ *_memberAccess.expression().annotation().type,
+ IntegerType(0, IntegerType::Modifier::Address),
+ true
+ );
+ m_context << Instruction::BALANCE;
+ }
+ else if ((set<string>{"send", "transfer", "call", "callcode", "delegatecall"}).count(member))
+ utils().convertType(
+ *_memberAccess.expression().annotation().type,
+ IntegerType(0, IntegerType::Modifier::Address),
+ true
+ );
+ else
+ solAssert(false, "Invalid member access to integer");
}
- else if ((set<string>{"send", "transfer", "call", "callcode", "delegatecall"}).count(member))
- utils().convertType(
- *_memberAccess.expression().annotation().type,
- IntegerType(0, IntegerType::Modifier::Address),
- true
- );
- else
- solAssert(false, "Invalid member access to integer");
break;
}
case Type::Category::Function: