mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #2934 from ethereum/fallthrough
Remove last two instances of switch fall-through
This commit is contained in:
commit
af4d8779bb
@ -596,7 +596,6 @@ void CompilerUtils::convertType(
|
|||||||
storeInMemoryDynamic(IntegerType(256));
|
storeInMemoryDynamic(IntegerType(256));
|
||||||
// stack: mempos datapos
|
// stack: mempos datapos
|
||||||
storeStringData(data);
|
storeStringData(data);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
solAssert(
|
solAssert(
|
||||||
@ -810,9 +809,8 @@ void CompilerUtils::convertType(
|
|||||||
if (_cleanupNeeded)
|
if (_cleanupNeeded)
|
||||||
m_context << Instruction::ISZERO << Instruction::ISZERO;
|
m_context << Instruction::ISZERO << Instruction::ISZERO;
|
||||||
break;
|
break;
|
||||||
case Type::Category::Function:
|
default:
|
||||||
{
|
if (stackTypeCategory == Type::Category::Function && targetTypeCategory == Type::Category::Integer)
|
||||||
if (targetTypeCategory == Type::Category::Integer)
|
|
||||||
{
|
{
|
||||||
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_targetType);
|
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_targetType);
|
||||||
solAssert(targetType.isAddress(), "Function type can only be converted to address.");
|
solAssert(targetType.isAddress(), "Function type can only be converted to address.");
|
||||||
@ -821,17 +819,16 @@ void CompilerUtils::convertType(
|
|||||||
|
|
||||||
// stack: <address> <function_id>
|
// stack: <address> <function_id>
|
||||||
m_context << Instruction::POP;
|
m_context << Instruction::POP;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
// fall-through
|
{
|
||||||
default:
|
// All other types should not be convertible to non-equal types.
|
||||||
// All other types should not be convertible to non-equal types.
|
solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
|
||||||
solAssert(_typeOnStack == _targetType, "Invalid type conversion requested.");
|
if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
|
||||||
if (_cleanupNeeded && _targetType.canBeStored() && _targetType.storageBytes() < 32)
|
|
||||||
m_context
|
m_context
|
||||||
<< ((u256(1) << (8 * _targetType.storageBytes())) - 1)
|
<< ((u256(1) << (8 * _targetType.storageBytes())) - 1)
|
||||||
<< Instruction::AND;
|
<< Instruction::AND;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,59 +1014,65 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
|
|||||||
switch (_memberAccess.expression().annotation().type->category())
|
switch (_memberAccess.expression().annotation().type->category())
|
||||||
{
|
{
|
||||||
case Type::Category::Contract:
|
case Type::Category::Contract:
|
||||||
|
case Type::Category::Integer:
|
||||||
{
|
{
|
||||||
bool alsoSearchInteger = false;
|
bool alsoSearchInteger = false;
|
||||||
ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.expression().annotation().type);
|
if (_memberAccess.expression().annotation().type->category() == Type::Category::Contract)
|
||||||
if (type.isSuper())
|
|
||||||
{
|
{
|
||||||
solAssert(!!_memberAccess.annotation().referencedDeclaration, "Referenced declaration not resolved.");
|
ContractType const& type = dynamic_cast<ContractType const&>(*_memberAccess.expression().annotation().type);
|
||||||
utils().pushCombinedFunctionEntryLabel(m_context.superFunction(
|
if (type.isSuper())
|
||||||
dynamic_cast<FunctionDefinition const&>(*_memberAccess.annotation().referencedDeclaration),
|
|
||||||
type.contractDefinition()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// ordinary contract type
|
|
||||||
if (Declaration const* declaration = _memberAccess.annotation().referencedDeclaration)
|
|
||||||
{
|
{
|
||||||
u256 identifier;
|
solAssert(!!_memberAccess.annotation().referencedDeclaration, "Referenced declaration not resolved.");
|
||||||
if (auto const* variable = dynamic_cast<VariableDeclaration const*>(declaration))
|
utils().pushCombinedFunctionEntryLabel(m_context.superFunction(
|
||||||
identifier = FunctionType(*variable).externalIdentifier();
|
dynamic_cast<FunctionDefinition const&>(*_memberAccess.annotation().referencedDeclaration),
|
||||||
else if (auto const* function = dynamic_cast<FunctionDefinition const*>(declaration))
|
type.contractDefinition()
|
||||||
identifier = FunctionType(*function).externalIdentifier();
|
));
|
||||||
else
|
|
||||||
solAssert(false, "Contract member is neither variable nor function.");
|
|
||||||
utils().convertType(type, IntegerType(0, IntegerType::Modifier::Address), true);
|
|
||||||
m_context << identifier;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// not found in contract, search in members inherited from address
|
{
|
||||||
alsoSearchInteger = true;
|
// ordinary contract type
|
||||||
|
if (Declaration const* declaration = _memberAccess.annotation().referencedDeclaration)
|
||||||
|
{
|
||||||
|
u256 identifier;
|
||||||
|
if (auto const* variable = dynamic_cast<VariableDeclaration const*>(declaration))
|
||||||
|
identifier = FunctionType(*variable).externalIdentifier();
|
||||||
|
else if (auto const* function = dynamic_cast<FunctionDefinition const*>(declaration))
|
||||||
|
identifier = FunctionType(*function).externalIdentifier();
|
||||||
|
else
|
||||||
|
solAssert(false, "Contract member is neither variable nor function.");
|
||||||
|
utils().convertType(type, IntegerType(0, IntegerType::Modifier::Address), true);
|
||||||
|
m_context << identifier;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// not found in contract, search in members inherited from address
|
||||||
|
alsoSearchInteger = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!alsoSearchInteger)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// fall-through
|
|
||||||
case Type::Category::Integer:
|
|
||||||
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
|
else
|
||||||
solAssert(false, "Invalid member access to integer");
|
alsoSearchInteger = true;
|
||||||
|
|
||||||
|
if (alsoSearchInteger)
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Type::Category::Function:
|
case Type::Category::Function:
|
||||||
if (member == "selector")
|
if (member == "selector")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user