aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-06-27 17:25:36 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-09-13 18:40:57 +0800
commit58f7a27ee0336423fa7dc76b8a160b78301bbdd2 (patch)
tree0a5913c37d415d853df6f430dc3b1ff4934579b1
parent8bb96eaaf533b17cd9c9109642455408f551348c (diff)
downloaddexon-solidity-58f7a27ee0336423fa7dc76b8a160b78301bbdd2.tar.gz
dexon-solidity-58f7a27ee0336423fa7dc76b8a160b78301bbdd2.tar.zst
dexon-solidity-58f7a27ee0336423fa7dc76b8a160b78301bbdd2.zip
Add sig member on function type
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/ast/Types.cpp5
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp9
3 files changed, 14 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md
index d3627565..49fbf8f1 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,6 +1,7 @@
### 0.4.17 (unreleased)
Features:
+ * Code Generator: Added ``.sig`` 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 10424858..5aa52383 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(
+ "sig",
+ 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..b7aadc12 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 == "sig")
+ {
+ 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: