Add payable and non-payable state mutability to AddressType.

This commit is contained in:
Daniel Kirchner
2018-09-13 15:15:49 +02:00
parent 9214c7c34f
commit 12aaca1645
47 changed files with 468 additions and 82 deletions
+7 -1
View File
@@ -242,8 +242,14 @@ string ABIFunctions::cleanupFunction(Type const& _type, bool _revertOnFailure)
break;
}
case Type::Category::Contract:
templ("body", "cleaned := " + cleanupFunction(AddressType()) + "(value)");
{
AddressType addressType(dynamic_cast<ContractType const&>(_type).isPayable() ?
StateMutability::Payable :
StateMutability::NonPayable
);
templ("body", "cleaned := " + cleanupFunction(addressType) + "(value)");
break;
}
case Type::Category::Enum:
{
size_t members = dynamic_cast<EnumType const&>(_type).numberOfMembers();
+13 -4
View File
@@ -1259,7 +1259,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
identifier = FunctionType(*function).externalIdentifier();
else
solAssert(false, "Contract member is neither variable nor function.");
utils().convertType(type, AddressType(), true);
utils().convertType(type, AddressType(type.isPayable() ? StateMutability::Payable : StateMutability::NonPayable), true);
m_context << identifier;
}
else
@@ -1277,15 +1277,24 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
{
utils().convertType(
*_memberAccess.expression().annotation().type,
AddressType(),
AddressType(StateMutability::NonPayable),
true
);
m_context << Instruction::BALANCE;
}
else if ((set<string>{"send", "transfer", "call", "callcode", "delegatecall", "staticcall"}).count(member))
else if ((set<string>{"send", "transfer"}).count(member))
{
solAssert(dynamic_cast<AddressType const&>(*_memberAccess.expression().annotation().type).stateMutability() == StateMutability::Payable, "");
utils().convertType(
*_memberAccess.expression().annotation().type,
AddressType(),
AddressType(StateMutability::Payable),
true
);
}
else if ((set<string>{"call", "callcode", "delegatecall", "staticcall"}).count(member))
utils().convertType(
*_memberAccess.expression().annotation().type,
AddressType(StateMutability::NonPayable),
true
);
else