aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-01 07:55:13 +0800
committerchriseth <chris@ethereum.org>2018-04-12 04:32:10 +0800
commitd56acb68abdda19d0e5a684cdf8d40c3d7ce277e (patch)
tree01d40a2d33c083708ba0d289f1ce3a7fa84b5bad /libsolidity/analysis
parentee5d0ef79bee71a47249ed36081738dd34707900 (diff)
downloaddexon-solidity-d56acb68abdda19d0e5a684cdf8d40c3d7ce277e.tar.gz
dexon-solidity-d56acb68abdda19d0e5a684cdf8d40c3d7ce277e.tar.zst
dexon-solidity-d56acb68abdda19d0e5a684cdf8d40c3d7ce277e.zip
Add abi.encode, abi.encodePacked, abi.encodeWithSelector and abi.encodeWithSignature.
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r--libsolidity/analysis/GlobalContext.cpp1
-rw-r--r--libsolidity/analysis/ViewPureChecker.cpp7
2 files changed, 7 insertions, 1 deletions
diff --git a/libsolidity/analysis/GlobalContext.cpp b/libsolidity/analysis/GlobalContext.cpp
index 6a858d36..ef1a59fe 100644
--- a/libsolidity/analysis/GlobalContext.cpp
+++ b/libsolidity/analysis/GlobalContext.cpp
@@ -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)),
diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp
index 13c3ab68..d9843012 100644
--- a/libsolidity/analysis/ViewPureChecker.cpp
+++ b/libsolidity/analysis/ViewPureChecker.cpp
@@ -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))