From aa94000a91be455af7b9436db172ffa86cc57494 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 28 Aug 2017 13:35:28 +0100 Subject: Mark all built in functions with appropriate statemutability --- libsolidity/analysis/GlobalContext.cpp | 20 ++++++++++---------- libsolidity/analysis/TypeChecker.cpp | 5 ++++- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'libsolidity/analysis') diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp index a54b8c8d..62dbd394 100644 --- a/libsolidity/analysis/GlobalContext.cpp +++ b/libsolidity/analysis/GlobalContext.cpp @@ -43,13 +43,13 @@ m_magicVariables(vector>{make_shared< make_shared("selfdestruct", make_shared(strings{"address"}, strings{}, FunctionType::Kind::Selfdestruct)), make_shared("addmod", - make_shared(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Kind::AddMod)), + make_shared(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Kind::AddMod, false, StateMutability::Pure)), make_shared("mulmod", - make_shared(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Kind::MulMod)), + make_shared(strings{"uint256", "uint256", "uint256"}, strings{"uint256"}, FunctionType::Kind::MulMod, false, StateMutability::Pure)), make_shared("sha3", - make_shared(strings(), strings{"bytes32"}, FunctionType::Kind::SHA3, true)), + make_shared(strings(), strings{"bytes32"}, FunctionType::Kind::SHA3, true, StateMutability::Pure)), make_shared("keccak256", - make_shared(strings(), strings{"bytes32"}, FunctionType::Kind::SHA3, true)), + make_shared(strings(), strings{"bytes32"}, FunctionType::Kind::SHA3, true, StateMutability::Pure)), make_shared("log0", make_shared(strings{"bytes32"}, strings{}, FunctionType::Kind::Log0)), make_shared("log1", @@ -61,17 +61,17 @@ m_magicVariables(vector>{make_shared< make_shared("log4", make_shared(strings{"bytes32", "bytes32", "bytes32", "bytes32", "bytes32"}, strings{}, FunctionType::Kind::Log4)), make_shared("sha256", - make_shared(strings(), strings{"bytes32"}, FunctionType::Kind::SHA256, true)), + make_shared(strings(), strings{"bytes32"}, FunctionType::Kind::SHA256, true, StateMutability::Pure)), make_shared("ecrecover", - make_shared(strings{"bytes32", "uint8", "bytes32", "bytes32"}, strings{"address"}, FunctionType::Kind::ECRecover)), + make_shared(strings{"bytes32", "uint8", "bytes32", "bytes32"}, strings{"address"}, FunctionType::Kind::ECRecover, false, StateMutability::Pure)), make_shared("ripemd160", - make_shared(strings(), strings{"bytes20"}, FunctionType::Kind::RIPEMD160, true)), + make_shared(strings(), strings{"bytes20"}, FunctionType::Kind::RIPEMD160, true, StateMutability::Pure)), make_shared("assert", - make_shared(strings{"bool"}, strings{}, FunctionType::Kind::Assert)), + make_shared(strings{"bool"}, strings{}, FunctionType::Kind::Assert, false, StateMutability::Pure)), make_shared("require", - make_shared(strings{"bool"}, strings{}, FunctionType::Kind::Require)), + make_shared(strings{"bool"}, strings{}, FunctionType::Kind::Require, false, StateMutability::Pure)), make_shared("revert", - make_shared(strings(), strings(), FunctionType::Kind::Revert))}) + make_shared(strings(), strings(), FunctionType::Kind::Revert, false, StateMutability::Pure))}) { } diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index d594a060..c70b0497 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1626,7 +1626,10 @@ void TypeChecker::endVisit(NewExpression const& _newExpression) TypePointers{type}, strings(), strings(), - FunctionType::Kind::ObjectCreation + FunctionType::Kind::ObjectCreation, + false, + nullptr, + StateMutability::Pure ); _newExpression.annotation().isPure = true; } -- cgit