aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-09-14 00:35:48 +0800
committerGitHub <noreply@github.com>2017-09-14 00:35:48 +0800
commit5c9dbd50839ac153f367ce69abb10dd22877842e (patch)
tree98e3b524aaacdafb2c30feb04567159591bad562 /libsolidity
parent3f3bcc4f8a0d12e9b92d6b63e7cfd92cbbfa775d (diff)
parent8b166c36369d0d1b39a4c537bc6ee8a08f3c6e5a (diff)
downloaddexon-solidity-5c9dbd50839ac153f367ce69abb10dd22877842e.tar.gz
dexon-solidity-5c9dbd50839ac153f367ce69abb10dd22877842e.tar.zst
dexon-solidity-5c9dbd50839ac153f367ce69abb10dd22877842e.zip
Merge pull request #2473 from ethereum/functiontype-sig
Add .selector member on function types
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/ast/Types.cpp5
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp9
2 files changed, 13 insertions, 1 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 10424858..705d0f7f 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -2436,6 +2436,11 @@ MemberList::MemberMap FunctionType::nativeMembers(ContractDefinition const*) con
case Kind::BareDelegateCall:
{
MemberList::MemberMap members;
+ if (m_kind == Kind::External)
+ members.push_back(MemberList::Member(
+ "selector",
+ make_shared<FixedBytesType>(4)
+ ));
if (m_kind != Kind::BareDelegateCall && m_kind != Kind::DelegateCall)
{
if (isPayable())
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index 5c9b743a..631a25ff 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1068,7 +1068,14 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
solAssert(false, "Invalid member access to integer");
break;
case Type::Category::Function:
- solAssert(!!_memberAccess.expression().annotation().type->memberType(member),
+ if (member == "selector")
+ {
+ m_context << Instruction::SWAP1 << Instruction::POP;
+ /// need to store store it as bytes4
+ utils().leftShiftNumberOnStack(224);
+ }
+ else
+ solAssert(!!_memberAccess.expression().annotation().type->memberType(member),
"Invalid member access to function.");
break;
case Type::Category::Magic: