mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add abi.encode, abi.encodePacked, abi.encodeWithSelector and abi.encodeWithSignature.
This commit is contained in:
committed by
chriseth
parent
ee5d0ef79b
commit
d56acb68ab
@@ -35,6 +35,7 @@ namespace solidity
|
||||
|
||||
GlobalContext::GlobalContext():
|
||||
m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{
|
||||
make_shared<MagicVariableDeclaration>("abi", make_shared<MagicType>(MagicType::Kind::ABI)),
|
||||
make_shared<MagicVariableDeclaration>("addmod", make_shared<FunctionType>(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Kind::AddMod, false, StateMutability::Pure)),
|
||||
make_shared<MagicVariableDeclaration>("assert", make_shared<FunctionType>(strings{"bool"}, strings{}, FunctionType::Kind::Assert, false, StateMutability::Pure)),
|
||||
make_shared<MagicVariableDeclaration>("block", make_shared<MagicType>(MagicType::Kind::Block)),
|
||||
|
||||
@@ -305,10 +305,15 @@ void ViewPureChecker::endVisit(MemberAccess const& _memberAccess)
|
||||
mutability = StateMutability::View;
|
||||
break;
|
||||
case Type::Category::Magic:
|
||||
{
|
||||
// we can ignore the kind of magic and only look at the name of the member
|
||||
if (member != "data" && member != "sig" && member != "blockhash")
|
||||
set<string> static const pureMembers{
|
||||
"encode", "encodePacked", "encodeWithSelector", "encodeWithSignature", "data", "sig", "blockhash"
|
||||
};
|
||||
if (!pureMembers.count(member))
|
||||
mutability = StateMutability::View;
|
||||
break;
|
||||
}
|
||||
case Type::Category::Struct:
|
||||
{
|
||||
if (_memberAccess.expression().annotation().type->dataStoredIn(DataLocation::Storage))
|
||||
|
||||
Reference in New Issue
Block a user