From c633c0eacba12e940b12c6ff58b5c6c55dc0122c Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 2 Mar 2018 17:58:27 +0100 Subject: Move msg.gas to global function gasleft(). Closes #2971. --- libsolidity/ast/Types.cpp | 14 ++++++++++---- libsolidity/ast/Types.h | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'libsolidity/ast') diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 771ae643..bde0dd6e 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -3000,8 +3000,10 @@ bool MagicType::operator==(Type const& _other) const return other.m_kind == m_kind; } -MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const*) const +MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const *_contract) const { + solAssert(_contract, ""); + const bool v050 = _contract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); switch (m_kind) { case Kind::Block: @@ -3014,13 +3016,17 @@ MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const*) const {"gaslimit", make_shared(256)} }); case Kind::Message: - return MemberList::MemberMap({ + { + std::vector members = { {"sender", make_shared(160, IntegerType::Modifier::Address)}, - {"gas", make_shared(256)}, {"value", make_shared(256)}, {"data", make_shared(DataLocation::CallData)}, {"sig", make_shared(4)} - }); + }; + if (!v050) + members.emplace_back("gas", make_shared(256)); + return MemberList::MemberMap(members); + } case Kind::Transaction: return MemberList::MemberMap({ {"origin", make_shared(160, IntegerType::Modifier::Address)}, diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 7985521e..c20a025f 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -902,7 +902,8 @@ public: ByteArrayPush, ///< .push() to a dynamically sized byte array in storage ObjectCreation, ///< array creation using new Assert, ///< assert() - Require ///< require() + Require, ///< require() + GasLeft ///< gasleft() }; virtual Category category() const override { return Category::Function; } -- cgit From 3340053fd95b73facc8a1534a130f58698808f2e Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 5 Mar 2018 17:00:37 +0100 Subject: Style improvements. --- libsolidity/ast/Types.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libsolidity/ast') diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index bde0dd6e..26bde1c4 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -3000,7 +3000,7 @@ bool MagicType::operator==(Type const& _other) const return other.m_kind == m_kind; } -MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const *_contract) const +MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const* _contract) const { solAssert(_contract, ""); const bool v050 = _contract->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050); @@ -3025,7 +3025,7 @@ MemberList::MemberMap MagicType::nativeMembers(ContractDefinition const *_contra }; if (!v050) members.emplace_back("gas", make_shared(256)); - return MemberList::MemberMap(members); + return members; } case Kind::Transaction: return MemberList::MemberMap({ -- cgit