mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Rename FunctionKind SHA3 to KECCAK256 (as the instruction was renamed in libevmasm)
This commit is contained in:
parent
478012a000
commit
ed52f422b7
@ -42,7 +42,7 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{
|
|||||||
make_shared<MagicVariableDeclaration>("blockhash", make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"}, FunctionType::Kind::BlockHash, false, StateMutability::View)),
|
make_shared<MagicVariableDeclaration>("blockhash", make_shared<FunctionType>(strings{"uint256"}, strings{"bytes32"}, FunctionType::Kind::BlockHash, false, StateMutability::View)),
|
||||||
make_shared<MagicVariableDeclaration>("ecrecover", make_shared<FunctionType>(strings{"bytes32", "uint8", "bytes32", "bytes32"}, strings{"address"}, FunctionType::Kind::ECRecover, false, StateMutability::Pure)),
|
make_shared<MagicVariableDeclaration>("ecrecover", make_shared<FunctionType>(strings{"bytes32", "uint8", "bytes32", "bytes32"}, strings{"address"}, FunctionType::Kind::ECRecover, false, StateMutability::Pure)),
|
||||||
make_shared<MagicVariableDeclaration>("gasleft", make_shared<FunctionType>(strings(), strings{"uint256"}, FunctionType::Kind::GasLeft, false, StateMutability::View)),
|
make_shared<MagicVariableDeclaration>("gasleft", make_shared<FunctionType>(strings(), strings{"uint256"}, FunctionType::Kind::GasLeft, false, StateMutability::View)),
|
||||||
make_shared<MagicVariableDeclaration>("keccak256", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::SHA3, false, StateMutability::Pure)),
|
make_shared<MagicVariableDeclaration>("keccak256", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::KECCAK256, false, StateMutability::Pure)),
|
||||||
make_shared<MagicVariableDeclaration>("log0", make_shared<FunctionType>(strings{"bytes32"}, strings{}, FunctionType::Kind::Log0)),
|
make_shared<MagicVariableDeclaration>("log0", make_shared<FunctionType>(strings{"bytes32"}, strings{}, FunctionType::Kind::Log0)),
|
||||||
make_shared<MagicVariableDeclaration>("log1", make_shared<FunctionType>(strings{"bytes32", "bytes32"}, strings{}, FunctionType::Kind::Log1)),
|
make_shared<MagicVariableDeclaration>("log1", make_shared<FunctionType>(strings{"bytes32", "bytes32"}, strings{}, FunctionType::Kind::Log1)),
|
||||||
make_shared<MagicVariableDeclaration>("log2", make_shared<FunctionType>(strings{"bytes32", "bytes32", "bytes32"}, strings{}, FunctionType::Kind::Log2)),
|
make_shared<MagicVariableDeclaration>("log2", make_shared<FunctionType>(strings{"bytes32", "bytes32", "bytes32"}, strings{}, FunctionType::Kind::Log2)),
|
||||||
@ -58,7 +58,7 @@ m_magicVariables(vector<shared_ptr<MagicVariableDeclaration const>>{
|
|||||||
make_shared<MagicVariableDeclaration>("ripemd160", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes20"}, FunctionType::Kind::RIPEMD160, false, StateMutability::Pure)),
|
make_shared<MagicVariableDeclaration>("ripemd160", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes20"}, FunctionType::Kind::RIPEMD160, false, StateMutability::Pure)),
|
||||||
make_shared<MagicVariableDeclaration>("selfdestruct", make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Kind::Selfdestruct)),
|
make_shared<MagicVariableDeclaration>("selfdestruct", make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Kind::Selfdestruct)),
|
||||||
make_shared<MagicVariableDeclaration>("sha256", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::SHA256, false, StateMutability::Pure)),
|
make_shared<MagicVariableDeclaration>("sha256", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::SHA256, false, StateMutability::Pure)),
|
||||||
make_shared<MagicVariableDeclaration>("sha3", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::SHA3, false, StateMutability::Pure)),
|
make_shared<MagicVariableDeclaration>("sha3", make_shared<FunctionType>(strings{"bytes memory"}, strings{"bytes32"}, FunctionType::Kind::KECCAK256, false, StateMutability::Pure)),
|
||||||
make_shared<MagicVariableDeclaration>("suicide", make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Kind::Selfdestruct)),
|
make_shared<MagicVariableDeclaration>("suicide", make_shared<FunctionType>(strings{"address"}, strings{}, FunctionType::Kind::Selfdestruct)),
|
||||||
make_shared<MagicVariableDeclaration>("tx", make_shared<MagicType>(MagicType::Kind::Transaction))
|
make_shared<MagicVariableDeclaration>("tx", make_shared<MagicType>(MagicType::Kind::Transaction))
|
||||||
})
|
})
|
||||||
|
@ -1685,7 +1685,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
|
|||||||
|
|
||||||
if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression()))
|
if (auto functionName = dynamic_cast<Identifier const*>(&_functionCall.expression()))
|
||||||
{
|
{
|
||||||
if (functionName->name() == "sha3" && functionType->kind() == FunctionType::Kind::SHA3)
|
if (functionName->name() == "sha3" && functionType->kind() == FunctionType::Kind::KECCAK256)
|
||||||
m_errorReporter.typeError(_functionCall.location(), "\"sha3\" has been deprecated in favour of \"keccak256\"");
|
m_errorReporter.typeError(_functionCall.location(), "\"sha3\" has been deprecated in favour of \"keccak256\"");
|
||||||
else if (functionName->name() == "suicide" && functionType->kind() == FunctionType::Kind::Selfdestruct)
|
else if (functionName->name() == "suicide" && functionType->kind() == FunctionType::Kind::Selfdestruct)
|
||||||
m_errorReporter.typeError(_functionCall.location(), "\"suicide\" has been deprecated in favour of \"selfdestruct\"");
|
m_errorReporter.typeError(_functionCall.location(), "\"suicide\" has been deprecated in favour of \"selfdestruct\"");
|
||||||
@ -1759,7 +1759,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
|
|||||||
msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.";
|
msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.";
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
functionType->kind() == FunctionType::Kind::SHA3 ||
|
functionType->kind() == FunctionType::Kind::KECCAK256 ||
|
||||||
functionType->kind() == FunctionType::Kind::SHA256 ||
|
functionType->kind() == FunctionType::Kind::SHA256 ||
|
||||||
functionType->kind() == FunctionType::Kind::RIPEMD160
|
functionType->kind() == FunctionType::Kind::RIPEMD160
|
||||||
)
|
)
|
||||||
@ -1804,7 +1804,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
|
|||||||
)
|
)
|
||||||
msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.";
|
msg += " This function requires a single bytes argument. If all your arguments are value types, you can use abi.encode(...) to properly generate it.";
|
||||||
else if (
|
else if (
|
||||||
functionType->kind() == FunctionType::Kind::SHA3 ||
|
functionType->kind() == FunctionType::Kind::KECCAK256 ||
|
||||||
functionType->kind() == FunctionType::Kind::SHA256 ||
|
functionType->kind() == FunctionType::Kind::SHA256 ||
|
||||||
functionType->kind() == FunctionType::Kind::RIPEMD160
|
functionType->kind() == FunctionType::Kind::RIPEMD160
|
||||||
)
|
)
|
||||||
|
@ -2509,7 +2509,7 @@ string FunctionType::richIdentifier() const
|
|||||||
case Kind::Creation: id += "creation"; break;
|
case Kind::Creation: id += "creation"; break;
|
||||||
case Kind::Send: id += "send"; break;
|
case Kind::Send: id += "send"; break;
|
||||||
case Kind::Transfer: id += "transfer"; break;
|
case Kind::Transfer: id += "transfer"; break;
|
||||||
case Kind::SHA3: id += "sha3"; break;
|
case Kind::KECCAK256: id += "keccak256"; break;
|
||||||
case Kind::Selfdestruct: id += "selfdestruct"; break;
|
case Kind::Selfdestruct: id += "selfdestruct"; break;
|
||||||
case Kind::Revert: id += "revert"; break;
|
case Kind::Revert: id += "revert"; break;
|
||||||
case Kind::ECRecover: id += "ecrecover"; break;
|
case Kind::ECRecover: id += "ecrecover"; break;
|
||||||
@ -2894,7 +2894,7 @@ bool FunctionType::isPure() const
|
|||||||
// FIXME: replace this with m_stateMutability == StateMutability::Pure once
|
// FIXME: replace this with m_stateMutability == StateMutability::Pure once
|
||||||
// the callgraph analyzer is in place
|
// the callgraph analyzer is in place
|
||||||
return
|
return
|
||||||
m_kind == Kind::SHA3 ||
|
m_kind == Kind::KECCAK256 ||
|
||||||
m_kind == Kind::ECRecover ||
|
m_kind == Kind::ECRecover ||
|
||||||
m_kind == Kind::SHA256 ||
|
m_kind == Kind::SHA256 ||
|
||||||
m_kind == Kind::RIPEMD160 ||
|
m_kind == Kind::RIPEMD160 ||
|
||||||
@ -2999,7 +2999,7 @@ bool FunctionType::padArguments() const
|
|||||||
case Kind::BareDelegateCall:
|
case Kind::BareDelegateCall:
|
||||||
case Kind::SHA256:
|
case Kind::SHA256:
|
||||||
case Kind::RIPEMD160:
|
case Kind::RIPEMD160:
|
||||||
case Kind::SHA3:
|
case Kind::KECCAK256:
|
||||||
case Kind::ABIEncodePacked:
|
case Kind::ABIEncodePacked:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
|
@ -899,7 +899,7 @@ public:
|
|||||||
Creation, ///< external call using CREATE
|
Creation, ///< external call using CREATE
|
||||||
Send, ///< CALL, but without data and gas
|
Send, ///< CALL, but without data and gas
|
||||||
Transfer, ///< CALL, but without data and throws on error
|
Transfer, ///< CALL, but without data and throws on error
|
||||||
SHA3, ///< SHA3
|
KECCAK256, ///< KECCAK256
|
||||||
Selfdestruct, ///< SELFDESTRUCT
|
Selfdestruct, ///< SELFDESTRUCT
|
||||||
Revert, ///< REVERT
|
Revert, ///< REVERT
|
||||||
ECRecover, ///< CALL to special contract for ecrecover
|
ECRecover, ///< CALL to special contract for ecrecover
|
||||||
@ -1070,7 +1070,7 @@ public:
|
|||||||
{
|
{
|
||||||
switch (m_kind)
|
switch (m_kind)
|
||||||
{
|
{
|
||||||
case FunctionType::Kind::SHA3:
|
case FunctionType::Kind::KECCAK256:
|
||||||
case FunctionType::Kind::SHA256:
|
case FunctionType::Kind::SHA256:
|
||||||
case FunctionType::Kind::RIPEMD160:
|
case FunctionType::Kind::RIPEMD160:
|
||||||
case FunctionType::Kind::BareCall:
|
case FunctionType::Kind::BareCall:
|
||||||
|
@ -701,7 +701,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
m_context.appendRevert();
|
m_context.appendRevert();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FunctionType::Kind::SHA3:
|
case FunctionType::Kind::KECCAK256:
|
||||||
{
|
{
|
||||||
solAssert(arguments.size() == 1, "");
|
solAssert(arguments.size() == 1, "");
|
||||||
solAssert(!function.padArguments(), "");
|
solAssert(!function.padArguments(), "");
|
||||||
|
@ -195,11 +195,11 @@ BOOST_AUTO_TEST_CASE(type_identifiers)
|
|||||||
TupleType t({e.type(), s.type(), stringArray, nullptr});
|
TupleType t({e.type(), s.type(), stringArray, nullptr});
|
||||||
BOOST_CHECK_EQUAL(t.identifier(), "t_tuple$_t_type$_t_enum$_Enum_$4_$_$_t_type$_t_struct$_Struct_$3_storage_ptr_$_$_t_array$_t_string_storage_$20_storage_ptr_$__$");
|
BOOST_CHECK_EQUAL(t.identifier(), "t_tuple$_t_type$_t_enum$_Enum_$4_$_$_t_type$_t_struct$_Struct_$3_storage_ptr_$_$_t_array$_t_string_storage_$20_storage_ptr_$__$");
|
||||||
|
|
||||||
TypePointer sha3fun = make_shared<FunctionType>(strings{}, strings{}, FunctionType::Kind::SHA3);
|
TypePointer keccak256fun = make_shared<FunctionType>(strings{}, strings{}, FunctionType::Kind::KECCAK256);
|
||||||
BOOST_CHECK_EQUAL(sha3fun->identifier(), "t_function_sha3_nonpayable$__$returns$__$");
|
BOOST_CHECK_EQUAL(keccak256fun->identifier(), "t_function_keccak256_nonpayable$__$returns$__$");
|
||||||
|
|
||||||
FunctionType metaFun(TypePointers{sha3fun}, TypePointers{s.type()});
|
FunctionType metaFun(TypePointers{keccak256fun}, TypePointers{s.type()});
|
||||||
BOOST_CHECK_EQUAL(metaFun.identifier(), "t_function_internal_nonpayable$_t_function_sha3_nonpayable$__$returns$__$_$returns$_t_type$_t_struct$_Struct_$3_storage_ptr_$_$");
|
BOOST_CHECK_EQUAL(metaFun.identifier(), "t_function_internal_nonpayable$_t_function_keccak256_nonpayable$__$returns$__$_$returns$_t_type$_t_struct$_Struct_$3_storage_ptr_$_$");
|
||||||
|
|
||||||
TypePointer m = make_shared<MappingType>(Type::fromElementaryTypeName("bytes32"), s.type());
|
TypePointer m = make_shared<MappingType>(Type::fromElementaryTypeName("bytes32"), s.type());
|
||||||
MappingType m2(Type::fromElementaryTypeName("uint64"), m);
|
MappingType m2(Type::fromElementaryTypeName("uint64"), m);
|
||||||
|
Loading…
Reference in New Issue
Block a user