diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-06-29 01:15:41 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-09-13 18:40:57 +0800 |
commit | fd1f8ab38ba7f2bb04e67a44ea5e947eddcf9b13 (patch) | |
tree | f26a3d511fb37abc12b67070582acc20cac3d156 | |
parent | 88946f9f03625fab345572c66b33ee3e05a07159 (diff) | |
download | dexon-solidity-fd1f8ab38ba7f2bb04e67a44ea5e947eddcf9b13.tar.gz dexon-solidity-fd1f8ab38ba7f2bb04e67a44ea5e947eddcf9b13.tar.zst dexon-solidity-fd1f8ab38ba7f2bb04e67a44ea5e947eddcf9b13.zip |
Rename .sig to .selector on function types
-rw-r--r-- | Changelog.md | 2 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 2 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 6 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 22 |
5 files changed, 17 insertions, 17 deletions
diff --git a/Changelog.md b/Changelog.md index 49fbf8f1..d90cd3f6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,7 +1,7 @@ ### 0.4.17 (unreleased) Features: - * Code Generator: Added ``.sig`` member on external function types to retrieve their signature. + * Code Generator: Added ``.selector`` member on external function types to retrieve their signature. * Optimizer: Add new optimization step to remove unused ``JUMPDEST``s. * Type Checker: Display helpful warning for unused function arguments/return parameters. * Type Checker: Do not show the same error multiple times for events. diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 5aa52383..705d0f7f 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -2438,7 +2438,7 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con MemberList::MemberMap members; if (m_kind == Kind::External) members.push_back(MemberList::Member( - "sig", + "selector", make_shared<FixedBytesType>(4) )); if (m_kind != Kind::BareDelegateCall && m_kind != Kind::DelegateCall) diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index b7aadc12..631a25ff 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1068,7 +1068,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) solAssert(false, "Invalid member access to integer"); break; case Type::Category::Function: - if (member == "sig") + if (member == "selector") { m_context << Instruction::SWAP1 << Instruction::POP; /// need to store store it as bytes4 diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index f3d0fde3..661d184a 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -10056,16 +10056,16 @@ BOOST_AUTO_TEST_CASE(function_types_sig) char const* sourceCode = R"( contract C { function f() returns (bytes4) { - return this.f.sig; + return this.f.selector; } function g() returns (bytes4) { function () external returns (bytes4) fun = this.f; - return fun.sig; + return fun.selector; } function h() returns (bytes4) { function () external returns (bytes4) fun = this.f; var funvar = fun; - return funvar.sig; + return funvar.selector; } } )"; diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 6576634f..9f33c5b3 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -6290,34 +6290,34 @@ BOOST_AUTO_TEST_CASE(function_types_sig) char const* text = R"( contract C { function f() returns (bytes4) { - return f.sig; + return f.selector; } } )"; - CHECK_ERROR(text, TypeError, "Member \"sig\" not found"); + CHECK_ERROR(text, TypeError, "Member \"selector\" not found"); text = R"( contract C { function g() internal { } function f() returns (bytes4) { - return g.sig; + return g.selector; } } )"; - CHECK_ERROR(text, TypeError, "Member \"sig\" not found"); + CHECK_ERROR(text, TypeError, "Member \"selector\" not found"); text = R"( contract C { function f() returns (bytes4) { function () g; - return g.sig; + return g.selector; } } )"; - CHECK_ERROR(text, TypeError, "Member \"sig\" not found"); + CHECK_ERROR(text, TypeError, "Member \"selector\" not found"); text = R"( contract C { function f() returns (bytes4) { - return this.f.sig; + return this.f.selector; } } )"; @@ -6325,7 +6325,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig) text = R"( contract C { function f() external returns (bytes4) { - return this.f.sig; + return this.f.selector; } } )"; @@ -6336,7 +6336,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig) } function f() external returns (bytes4) { var g = this.h; - return g.sig; + return g.selector; } } )"; @@ -6347,7 +6347,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig) } function f() external returns (bytes4) { function () external g = this.h; - return g.sig; + return g.selector; } } )"; @@ -6359,7 +6359,7 @@ BOOST_AUTO_TEST_CASE(function_types_sig) function f() external returns (bytes4) { function () external g = this.h; var i = g; - return i.sig; + return i.selector; } } )"; |