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
@@ -2375,7 +2375,11 @@ string FunctionType::richIdentifier() const
|
||||
case Kind::ByteArrayPush: id += "bytearraypush"; break;
|
||||
case Kind::ObjectCreation: id += "objectcreation"; break;
|
||||
case Kind::Assert: id += "assert"; break;
|
||||
case Kind::Require: id += "require";break;
|
||||
case Kind::Require: id += "require"; break;
|
||||
case Kind::ABIEncode: id += "abiencode"; break;
|
||||
case Kind::ABIEncodePacked: id += "abiencodepacked"; break;
|
||||
case Kind::ABIEncodeWithSelector: id += "abiencodewithselector"; break;
|
||||
case Kind::ABIEncodeWithSignature: id += "abiencodewithsignature"; break;
|
||||
default: solAssert(false, "Unknown function location."); break;
|
||||
}
|
||||
id += "_" + stateMutabilityToString(m_stateMutability);
|
||||
@@ -2996,6 +3000,8 @@ string MagicType::richIdentifier() const
|
||||
return "t_magic_message";
|
||||
case Kind::Transaction:
|
||||
return "t_magic_transaction";
|
||||
case Kind::ABI:
|
||||
return "t_magic_abi";
|
||||
default:
|
||||
solAssert(false, "Unknown kind of magic");
|
||||
}
|
||||
@@ -3036,6 +3042,45 @@ MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const*) const
|
||||
{"origin", make_shared<IntegerType>(160, IntegerType::Modifier::Address)},
|
||||
{"gasprice", make_shared<IntegerType>(256)}
|
||||
});
|
||||
case Kind::ABI:
|
||||
return MemberList::MemberMap({
|
||||
{"encode", make_shared<FunctionType>(
|
||||
TypePointers(),
|
||||
TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
|
||||
strings{},
|
||||
strings{},
|
||||
FunctionType::Kind::ABIEncode,
|
||||
true,
|
||||
StateMutability::Pure
|
||||
)},
|
||||
{"encodePacked", make_shared<FunctionType>(
|
||||
TypePointers(),
|
||||
TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
|
||||
strings{},
|
||||
strings{},
|
||||
FunctionType::Kind::ABIEncodePacked,
|
||||
true,
|
||||
StateMutability::Pure
|
||||
)},
|
||||
{"encodeWithSelector", make_shared<FunctionType>(
|
||||
TypePointers{make_shared<FixedBytesType>(4)},
|
||||
TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
|
||||
strings{},
|
||||
strings{},
|
||||
FunctionType::Kind::ABIEncodeWithSelector,
|
||||
true,
|
||||
StateMutability::Pure
|
||||
)},
|
||||
{"encodeWithSignature", make_shared<FunctionType>(
|
||||
TypePointers{make_shared<ArrayType>(DataLocation::Memory, true)},
|
||||
TypePointers{make_shared<ArrayType>(DataLocation::Memory)},
|
||||
strings{},
|
||||
strings{},
|
||||
FunctionType::Kind::ABIEncodeWithSignature,
|
||||
true,
|
||||
StateMutability::Pure
|
||||
)}
|
||||
});
|
||||
default:
|
||||
solAssert(false, "Unknown kind of magic.");
|
||||
}
|
||||
@@ -3051,6 +3096,8 @@ string MagicType::toString(bool) const
|
||||
return "msg";
|
||||
case Kind::Transaction:
|
||||
return "tx";
|
||||
case Kind::ABI:
|
||||
return "abi";
|
||||
default:
|
||||
solAssert(false, "Unknown kind of magic.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user